@@ -12,8 +12,8 @@ use stdx::format_to;
12
12
use syntax:: ast;
13
13
14
14
use crate :: {
15
- db:: DefDatabase , per_ns:: PerNs , visibility:: Visibility , AdtId , BuiltinType , ConstId , ImplId ,
16
- LocalModuleId , MacroDefId , ModuleDefId , ModuleId , TraitId ,
15
+ attr :: AttrId , db:: DefDatabase , per_ns:: PerNs , visibility:: Visibility , AdtId , BuiltinType ,
16
+ ConstId , ImplId , LocalModuleId , MacroDefId , ModuleDefId , ModuleId , TraitId ,
17
17
} ;
18
18
19
19
#[ derive( Copy , Clone ) ]
@@ -61,6 +61,7 @@ pub struct ItemScope {
61
61
// be all resolved to the last one defined if shadowing happens.
62
62
legacy_macros : FxHashMap < Name , MacroDefId > ,
63
63
attr_macros : FxHashMap < AstId < ast:: Item > , MacroCallId > ,
64
+ derive_macros : FxHashMap < AstId < ast:: Item > , ( AttrId , MacroCallId ) > ,
64
65
}
65
66
66
67
pub ( crate ) static BUILTIN_SCOPE : Lazy < FxHashMap < Name , PerNs > > = Lazy :: new ( || {
@@ -182,6 +183,21 @@ impl ItemScope {
182
183
self . attr_macros . iter ( ) . map ( |( k, v) | ( * k, * v) )
183
184
}
184
185
186
+ pub ( crate ) fn add_derive_macro_invoc (
187
+ & mut self ,
188
+ item : AstId < ast:: Item > ,
189
+ call : MacroCallId ,
190
+ attr_id : AttrId ,
191
+ ) {
192
+ self . derive_macros . insert ( item, ( attr_id, call) ) ;
193
+ }
194
+
195
+ pub ( crate ) fn derive_macro_invocs (
196
+ & self ,
197
+ ) -> impl Iterator < Item = ( AstId < ast:: Item > , ( AttrId , MacroCallId ) ) > + ' _ {
198
+ self . derive_macros . iter ( ) . map ( |( k, v) | ( * k, * v) )
199
+ }
200
+
185
201
pub ( crate ) fn unnamed_trait_vis ( & self , tr : TraitId ) -> Option < Visibility > {
186
202
self . unnamed_trait_imports . get ( & tr) . copied ( )
187
203
}
@@ -320,6 +336,7 @@ impl ItemScope {
320
336
unnamed_trait_imports,
321
337
legacy_macros,
322
338
attr_macros,
339
+ derive_macros,
323
340
} = self ;
324
341
types. shrink_to_fit ( ) ;
325
342
values. shrink_to_fit ( ) ;
@@ -331,6 +348,7 @@ impl ItemScope {
331
348
unnamed_trait_imports. shrink_to_fit ( ) ;
332
349
legacy_macros. shrink_to_fit ( ) ;
333
350
attr_macros. shrink_to_fit ( ) ;
351
+ derive_macros. shrink_to_fit ( ) ;
334
352
}
335
353
}
336
354
0 commit comments