@@ -142,7 +142,7 @@ pub use {
142142 name:: Name ,
143143 prettify_macro_expansion,
144144 proc_macro:: { ProcMacros , ProcMacrosBuilder } ,
145- tt, ExpandResult , HirFileId , HirFileIdExt , MacroFileId , MacroFileIdExt ,
145+ tt, ExpandResult , HirFileId , HirFileIdExt , MacroFileId , MacroFileIdExt , MacroKind ,
146146 } ,
147147 hir_ty:: {
148148 consteval:: ConstEvalError ,
@@ -699,7 +699,10 @@ impl Module {
699699 let source_map = tree_source_maps. impl_ ( loc. id . value ) . item ( ) ;
700700 let node = & tree[ loc. id . value ] ;
701701 let file_id = loc. id . file_id ( ) ;
702- if file_id. macro_file ( ) . is_some_and ( |it| it. is_builtin_derive ( db. upcast ( ) ) ) {
702+ if file_id
703+ . macro_file ( )
704+ . is_some_and ( |it| it. kind ( db. upcast ( ) ) == MacroKind :: DeriveBuiltIn )
705+ {
703706 // these expansion come from us, diagnosing them is a waste of resources
704707 // FIXME: Once we diagnose the inputs to builtin derives, we should at least extract those diagnostics somehow
705708 continue ;
@@ -3049,20 +3052,6 @@ impl BuiltinType {
30493052 }
30503053}
30513054
3052- #[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash ) ]
3053- pub enum MacroKind {
3054- /// `macro_rules!` or Macros 2.0 macro.
3055- Declarative ,
3056- /// A built-in or custom derive.
3057- Derive ,
3058- /// A built-in function-like macro.
3059- BuiltIn ,
3060- /// A procedural attribute macro.
3061- Attr ,
3062- /// A function-like procedural macro.
3063- ProcMacro ,
3064- }
3065-
30663055#[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash ) ]
30673056pub struct Macro {
30683057 pub ( crate ) id : MacroId ,
@@ -3093,15 +3082,19 @@ impl Macro {
30933082 match self . id {
30943083 MacroId :: Macro2Id ( it) => match it. lookup ( db. upcast ( ) ) . expander {
30953084 MacroExpander :: Declarative => MacroKind :: Declarative ,
3096- MacroExpander :: BuiltIn ( _) | MacroExpander :: BuiltInEager ( _) => MacroKind :: BuiltIn ,
3097- MacroExpander :: BuiltInAttr ( _) => MacroKind :: Attr ,
3098- MacroExpander :: BuiltInDerive ( _) => MacroKind :: Derive ,
3085+ MacroExpander :: BuiltIn ( _) | MacroExpander :: BuiltInEager ( _) => {
3086+ MacroKind :: DeclarativeBuiltIn
3087+ }
3088+ MacroExpander :: BuiltInAttr ( _) => MacroKind :: AttrBuiltIn ,
3089+ MacroExpander :: BuiltInDerive ( _) => MacroKind :: DeriveBuiltIn ,
30993090 } ,
31003091 MacroId :: MacroRulesId ( it) => match it. lookup ( db. upcast ( ) ) . expander {
31013092 MacroExpander :: Declarative => MacroKind :: Declarative ,
3102- MacroExpander :: BuiltIn ( _) | MacroExpander :: BuiltInEager ( _) => MacroKind :: BuiltIn ,
3103- MacroExpander :: BuiltInAttr ( _) => MacroKind :: Attr ,
3104- MacroExpander :: BuiltInDerive ( _) => MacroKind :: Derive ,
3093+ MacroExpander :: BuiltIn ( _) | MacroExpander :: BuiltInEager ( _) => {
3094+ MacroKind :: DeclarativeBuiltIn
3095+ }
3096+ MacroExpander :: BuiltInAttr ( _) => MacroKind :: AttrBuiltIn ,
3097+ MacroExpander :: BuiltInDerive ( _) => MacroKind :: DeriveBuiltIn ,
31053098 } ,
31063099 MacroId :: ProcMacroId ( it) => match it. lookup ( db. upcast ( ) ) . kind {
31073100 ProcMacroKind :: CustomDerive => MacroKind :: Derive ,
@@ -3112,10 +3105,10 @@ impl Macro {
31123105 }
31133106
31143107 pub fn is_fn_like ( & self , db : & dyn HirDatabase ) -> bool {
3115- match self . kind ( db ) {
3116- MacroKind :: Declarative | MacroKind :: BuiltIn | MacroKind :: ProcMacro => true ,
3117- MacroKind :: Attr | MacroKind :: Derive => false ,
3118- }
3108+ matches ! (
3109+ self . kind ( db ) ,
3110+ MacroKind :: Declarative | MacroKind :: DeclarativeBuiltIn | MacroKind :: ProcMacro
3111+ )
31193112 }
31203113
31213114 pub fn is_builtin_derive ( & self , db : & dyn HirDatabase ) -> bool {
@@ -3155,11 +3148,11 @@ impl Macro {
31553148 }
31563149
31573150 pub fn is_attr ( & self , db : & dyn HirDatabase ) -> bool {
3158- matches ! ( self . kind( db) , MacroKind :: Attr )
3151+ matches ! ( self . kind( db) , MacroKind :: Attr | MacroKind :: AttrBuiltIn )
31593152 }
31603153
31613154 pub fn is_derive ( & self , db : & dyn HirDatabase ) -> bool {
3162- matches ! ( self . kind( db) , MacroKind :: Derive )
3155+ matches ! ( self . kind( db) , MacroKind :: Derive | MacroKind :: DeriveBuiltIn )
31633156 }
31643157}
31653158
0 commit comments