@@ -157,8 +157,13 @@ pub struct Definitions {
157157 node_to_def_index : NodeMap < DefIndex > ,
158158 def_index_to_node : [ Vec < ast:: NodeId > ; 2 ] ,
159159 pub ( super ) node_to_hir_id : IndexVec < ast:: NodeId , hir:: HirId > ,
160- macro_def_scopes : FxHashMap < Mark , DefId > ,
161- expansions : FxHashMap < DefIndex , Mark > ,
160+ /// If `Mark` is an ID of some macro expansion,
161+ /// then `DefId` is the normal module (`mod`) in which the expanded macro was defined.
162+ parent_modules_of_macro_defs : FxHashMap < Mark , DefId > ,
163+ /// Item with a given `DefIndex` was defined during opaque macro expansion with ID `Mark`.
164+ /// It can actually be defined during transparent macro expansions inside that opaque expansion,
165+ /// but transparent expansions are ignored here.
166+ opaque_expansions_that_defined : FxHashMap < DefIndex , Mark > ,
162167 next_disambiguator : FxHashMap < ( DefIndex , DefPathData ) , u32 > ,
163168 def_index_to_span : FxHashMap < DefIndex , Span > ,
164169}
@@ -175,8 +180,8 @@ impl Clone for Definitions {
175180 self . def_index_to_node [ 1 ] . clone ( ) ,
176181 ] ,
177182 node_to_hir_id : self . node_to_hir_id . clone ( ) ,
178- macro_def_scopes : self . macro_def_scopes . clone ( ) ,
179- expansions : self . expansions . clone ( ) ,
183+ parent_modules_of_macro_defs : self . parent_modules_of_macro_defs . clone ( ) ,
184+ opaque_expansions_that_defined : self . opaque_expansions_that_defined . clone ( ) ,
180185 next_disambiguator : self . next_disambiguator . clone ( ) ,
181186 def_index_to_span : self . def_index_to_span . clone ( ) ,
182187 }
@@ -397,8 +402,8 @@ impl Definitions {
397402 node_to_def_index : NodeMap ( ) ,
398403 def_index_to_node : [ vec ! [ ] , vec ! [ ] ] ,
399404 node_to_hir_id : IndexVec :: new ( ) ,
400- macro_def_scopes : FxHashMap ( ) ,
401- expansions : FxHashMap ( ) ,
405+ parent_modules_of_macro_defs : FxHashMap ( ) ,
406+ opaque_expansions_that_defined : FxHashMap ( ) ,
402407 next_disambiguator : FxHashMap ( ) ,
403408 def_index_to_span : FxHashMap ( ) ,
404409 }
@@ -580,7 +585,7 @@ impl Definitions {
580585
581586 let expansion = expansion. modern ( ) ;
582587 if expansion != Mark :: root ( ) {
583- self . expansions . insert ( index, expansion) ;
588+ self . opaque_expansions_that_defined . insert ( index, expansion) ;
584589 }
585590
586591 // The span is added if it isn't DUMMY_SP
@@ -600,16 +605,16 @@ impl Definitions {
600605 self . node_to_hir_id = mapping;
601606 }
602607
603- pub fn expansion ( & self , index : DefIndex ) -> Mark {
604- self . expansions . get ( & index) . cloned ( ) . unwrap_or ( Mark :: root ( ) )
608+ pub fn opaque_expansion_that_defined ( & self , index : DefIndex ) -> Mark {
609+ self . opaque_expansions_that_defined . get ( & index) . cloned ( ) . unwrap_or ( Mark :: root ( ) )
605610 }
606611
607- pub fn macro_def_scope ( & self , mark : Mark ) -> DefId {
608- self . macro_def_scopes [ & mark]
612+ pub fn parent_module_of_macro_def ( & self , mark : Mark ) -> DefId {
613+ self . parent_modules_of_macro_defs [ & mark]
609614 }
610615
611- pub fn add_macro_def_scope ( & mut self , mark : Mark , scope : DefId ) {
612- self . macro_def_scopes . insert ( mark, scope ) ;
616+ pub fn add_parent_module_of_macro_def ( & mut self , mark : Mark , module : DefId ) {
617+ self . parent_modules_of_macro_defs . insert ( mark, module ) ;
613618 }
614619}
615620
0 commit comments