@@ -319,8 +319,10 @@ impl HirFileId {
319319 } )
320320 }
321321
322- /// Indicate it is macro file generated for builtin derive
323- pub fn is_builtin_derive ( & self , db : & dyn db:: ExpandDatabase ) -> Option < InFile < ast:: Attr > > {
322+ pub fn as_builtin_derive_attr_node (
323+ & self ,
324+ db : & dyn db:: ExpandDatabase ,
325+ ) -> Option < InFile < ast:: Attr > > {
324326 let macro_file = self . macro_file ( ) ?;
325327 let loc: MacroCallLoc = db. lookup_intern_macro_call ( macro_file. macro_call_id ) ;
326328 let attr = match loc. def . kind {
@@ -333,8 +335,22 @@ impl HirFileId {
333335 pub fn is_custom_derive ( & self , db : & dyn db:: ExpandDatabase ) -> bool {
334336 match self . macro_file ( ) {
335337 Some ( macro_file) => {
336- let loc: MacroCallLoc = db. lookup_intern_macro_call ( macro_file. macro_call_id ) ;
337- matches ! ( loc. def. kind, MacroDefKind :: ProcMacro ( _, ProcMacroKind :: CustomDerive , _) )
338+ matches ! (
339+ db. lookup_intern_macro_call( macro_file. macro_call_id) . def. kind,
340+ MacroDefKind :: ProcMacro ( _, ProcMacroKind :: CustomDerive , _)
341+ )
342+ }
343+ None => false ,
344+ }
345+ }
346+
347+ pub fn is_builtin_derive ( & self , db : & dyn db:: ExpandDatabase ) -> bool {
348+ match self . macro_file ( ) {
349+ Some ( macro_file) => {
350+ matches ! (
351+ db. lookup_intern_macro_call( macro_file. macro_call_id) . def. kind,
352+ MacroDefKind :: BuiltInDerive ( ..)
353+ )
338354 }
339355 None => false ,
340356 }
@@ -344,8 +360,7 @@ impl HirFileId {
344360 pub fn is_include_macro ( & self , db : & dyn db:: ExpandDatabase ) -> bool {
345361 match self . macro_file ( ) {
346362 Some ( macro_file) => {
347- let loc: MacroCallLoc = db. lookup_intern_macro_call ( macro_file. macro_call_id ) ;
348- loc. def . is_include ( )
363+ db. lookup_intern_macro_call ( macro_file. macro_call_id ) . def . is_include ( )
349364 }
350365 _ => false ,
351366 }
0 commit comments