@@ -182,6 +182,10 @@ impl<'a> base::Resolver for Resolver<'a> {
182182
183183 fn resolve_macro_invocation ( & mut self , invoc : & Invocation , invoc_id : ExpnId , force : bool )
184184 -> 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 ;
185189 let ( path, kind, derives_in_scope, after_derive) = match invoc. kind {
186190 InvocationKind :: Attr { ref attr, ref derives, after_derive, .. } =>
187191 ( & attr. path , MacroKind :: Attr , derives. clone ( ) , after_derive) ,
@@ -201,7 +205,7 @@ impl<'a> base::Resolver for Resolver<'a> {
201205 match self . resolve_macro_path ( path, Some ( MacroKind :: Derive ) ,
202206 parent_scope, true , force) {
203207 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 ) ;
205209 return Ok ( None ) ;
206210 }
207211 Err ( Determinacy :: Undetermined ) => result = Err ( Indeterminate ) ,
@@ -217,17 +221,15 @@ impl<'a> base::Resolver for Resolver<'a> {
217221 let ( ext, res) = self . smart_resolve_macro_path ( path, kind, parent_scope, force) ?;
218222
219223 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) ) ) ;
221225
222226 if let Res :: Def ( _, def_id) = res {
223227 if after_derive {
224228 self . session . span_err ( span, "macro attributes must be placed before `#[derive]`" ) ;
225229 }
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) ;
231233 }
232234
233235 Ok ( Some ( ext) )
0 commit comments