From 8c639a87bdbd08b10d4eb84d00f25ba7bcd56be0 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Sat, 29 May 2021 20:32:57 +0200 Subject: Thread proc-macro types through the HIR --- crates/hir/src/lib.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'crates/hir/src/lib.rs') diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 01b2de515..975ae4869 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -1282,10 +1282,16 @@ impl BuiltinType { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum MacroKind { + /// `macro_rules!` or Macros 2.0 macro. Declarative, - ProcMacro, + /// A built-in or custom derive. Derive, + /// A built-in function-like macro. BuiltIn, + /// A procedural attribute macro. + Attr, + /// A function-like procedural macro. + ProcMacro, } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] @@ -1315,11 +1321,13 @@ impl MacroDef { pub fn kind(&self) -> MacroKind { match self.id.kind { MacroDefKind::Declarative(_) => MacroKind::Declarative, - MacroDefKind::BuiltIn(_, _) => MacroKind::BuiltIn, + MacroDefKind::BuiltIn(_, _) | MacroDefKind::BuiltInEager(_, _) => MacroKind::BuiltIn, MacroDefKind::BuiltInDerive(_, _) => MacroKind::Derive, - MacroDefKind::BuiltInEager(_, _) => MacroKind::BuiltIn, - // FIXME might be a derive - MacroDefKind::ProcMacro(_, _) => MacroKind::ProcMacro, + MacroDefKind::ProcMacro(_, base_db::ProcMacroKind::CustomDerive, _) => { + MacroKind::Derive + } + MacroDefKind::ProcMacro(_, base_db::ProcMacroKind::Attr, _) => MacroKind::Attr, + MacroDefKind::ProcMacro(_, base_db::ProcMacroKind::FuncLike, _) => MacroKind::ProcMacro, } } } -- cgit v1.2.3