@@ -157,8 +157,13 @@ pub struct Definitions {
157
157
node_to_def_index : NodeMap < DefIndex > ,
158
158
def_index_to_node : [ Vec < ast:: NodeId > ; 2 ] ,
159
159
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 > ,
162
167
next_disambiguator : FxHashMap < ( DefIndex , DefPathData ) , u32 > ,
163
168
def_index_to_span : FxHashMap < DefIndex , Span > ,
164
169
}
@@ -175,8 +180,8 @@ impl Clone for Definitions {
175
180
self . def_index_to_node [ 1 ] . clone ( ) ,
176
181
] ,
177
182
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 ( ) ,
180
185
next_disambiguator : self . next_disambiguator . clone ( ) ,
181
186
def_index_to_span : self . def_index_to_span . clone ( ) ,
182
187
}
@@ -397,8 +402,8 @@ impl Definitions {
397
402
node_to_def_index : NodeMap ( ) ,
398
403
def_index_to_node : [ vec ! [ ] , vec ! [ ] ] ,
399
404
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 ( ) ,
402
407
next_disambiguator : FxHashMap ( ) ,
403
408
def_index_to_span : FxHashMap ( ) ,
404
409
}
@@ -580,7 +585,7 @@ impl Definitions {
580
585
581
586
let expansion = expansion. modern ( ) ;
582
587
if expansion != Mark :: root ( ) {
583
- self . expansions . insert ( index, expansion) ;
588
+ self . opaque_expansions_that_defined . insert ( index, expansion) ;
584
589
}
585
590
586
591
// The span is added if it isn't DUMMY_SP
@@ -600,16 +605,16 @@ impl Definitions {
600
605
self . node_to_hir_id = mapping;
601
606
}
602
607
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 ( ) )
605
610
}
606
611
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]
609
614
}
610
615
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 ) ;
613
618
}
614
619
}
615
620
0 commit comments