From fee74851b02fb69c32291f3051438901faaf667f Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sat, 2 May 2020 22:24:27 +0300 Subject: Propose custom derives in completion --- crates/ra_hir/src/code_model.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'crates/ra_hir/src') diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index af59aa1b6..a004363ee 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -19,7 +19,7 @@ use hir_def::{ use hir_expand::{ diagnostics::DiagnosticSink, name::{name, AsName}, - MacroDefId, + MacroDefId, MacroDefKind, }; use hir_ty::{ autoderef, display::HirFormatter, expr::ExprValidator, method_resolution, ApplicationTy, @@ -762,13 +762,12 @@ impl MacroDef { /// Indicate it is a proc-macro pub fn is_proc_macro(&self) -> bool { - match self.id.kind { - hir_expand::MacroDefKind::Declarative => false, - hir_expand::MacroDefKind::BuiltIn(_) => false, - hir_expand::MacroDefKind::BuiltInDerive(_) => false, - hir_expand::MacroDefKind::BuiltInEager(_) => false, - hir_expand::MacroDefKind::CustomDerive(_) => true, - } + matches!(self.id.kind, MacroDefKind::CustomDerive(_)) + } + + /// Indicate it is a derive macro + pub fn is_derive_macro(&self) -> bool { + matches!(self.id.kind, MacroDefKind::CustomDerive(_) | MacroDefKind::BuiltInDerive(_)) } } -- cgit v1.2.3