@@ -182,6 +182,10 @@ impl<'a> base::Resolver for Resolver<'a> {
182
182
183
183
fn resolve_macro_invocation ( & mut self , invoc : & Invocation , invoc_id : ExpnId , force : bool )
184
184
-> Result < Option < Lrc < SyntaxExtension > > , Indeterminate > {
185
+ if !self . invocations . contains_key ( & invoc. expansion_data . id ) {
186
+ self . invocations . insert ( invoc. expansion_data . id , self . invocations [ & invoc_id] ) ;
187
+ }
188
+ let invoc_id = invoc. expansion_data . id ;
185
189
let ( path, kind, derives_in_scope, after_derive) = match invoc. kind {
186
190
InvocationKind :: Attr { ref attr, ref derives, after_derive, .. } =>
187
191
( & attr. path , MacroKind :: Attr , derives. clone ( ) , after_derive) ,
@@ -201,7 +205,7 @@ impl<'a> base::Resolver for Resolver<'a> {
201
205
match self . resolve_macro_path ( path, Some ( MacroKind :: Derive ) ,
202
206
parent_scope, true , force) {
203
207
Ok ( ( Some ( ref ext) , _) ) if ext. is_derive_copy => {
204
- self . add_derives ( invoc . expansion_data . id , SpecialDerives :: COPY ) ;
208
+ self . add_derives ( invoc_id , SpecialDerives :: COPY ) ;
205
209
return Ok ( None ) ;
206
210
}
207
211
Err ( Determinacy :: Undetermined ) => result = Err ( Indeterminate ) ,
@@ -217,17 +221,15 @@ impl<'a> base::Resolver for Resolver<'a> {
217
221
let ( ext, res) = self . smart_resolve_macro_path ( path, kind, parent_scope, force) ?;
218
222
219
223
let span = invoc. span ( ) ;
220
- invoc . expansion_data . id . set_expn_info ( ext. expn_info ( span, fast_print_path ( path) ) ) ;
224
+ invoc_id . set_expn_info ( ext. expn_info ( span, fast_print_path ( path) ) ) ;
221
225
222
226
if let Res :: Def ( _, def_id) = res {
223
227
if after_derive {
224
228
self . session . span_err ( span, "macro attributes must be placed before `#[derive]`" ) ;
225
229
}
226
- self . macro_defs . insert ( invoc. expansion_data . id , def_id) ;
227
- let normal_module_def_id =
228
- self . macro_def_scope ( invoc. expansion_data . id ) . normal_ancestor_id ;
229
- self . definitions . add_parent_module_of_macro_def ( invoc. expansion_data . id ,
230
- normal_module_def_id) ;
230
+ self . macro_defs . insert ( invoc_id, def_id) ;
231
+ let normal_module_def_id = self . macro_def_scope ( invoc_id) . normal_ancestor_id ;
232
+ self . definitions . add_parent_module_of_macro_def ( invoc_id, normal_module_def_id) ;
231
233
}
232
234
233
235
Ok ( Some ( ext) )
0 commit comments