@@ -319,8 +319,10 @@ impl HirFileId {
319
319
} )
320
320
}
321
321
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 > > {
324
326
let macro_file = self . macro_file ( ) ?;
325
327
let loc: MacroCallLoc = db. lookup_intern_macro_call ( macro_file. macro_call_id ) ;
326
328
let attr = match loc. def . kind {
@@ -333,8 +335,22 @@ impl HirFileId {
333
335
pub fn is_custom_derive ( & self , db : & dyn db:: ExpandDatabase ) -> bool {
334
336
match self . macro_file ( ) {
335
337
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
+ )
338
354
}
339
355
None => false ,
340
356
}
@@ -344,8 +360,7 @@ impl HirFileId {
344
360
pub fn is_include_macro ( & self , db : & dyn db:: ExpandDatabase ) -> bool {
345
361
match self . macro_file ( ) {
346
362
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 ( )
349
364
}
350
365
_ => false ,
351
366
}
0 commit comments