@@ -2,19 +2,17 @@ use rustc_data_structures::fx::FxHashMap;
22use rustc_data_structures:: sorted_map:: SortedMap ;
33use rustc_hir as hir;
44use rustc_hir:: def_id:: LocalDefId ;
5- use rustc_hir:: definitions;
65use rustc_hir:: intravisit:: { self , Visitor } ;
76use rustc_hir:: * ;
87use rustc_index:: { Idx , IndexVec } ;
98use rustc_middle:: span_bug;
10- use rustc_session:: Session ;
11- use rustc_span:: source_map:: SourceMap ;
9+ use rustc_middle:: ty:: TyCtxt ;
1210use rustc_span:: { Span , DUMMY_SP } ;
1311
1412/// A visitor that walks over the HIR and collects `Node`s into a HIR map.
1513pub ( super ) struct NodeCollector < ' a , ' hir > {
16- /// Source map
17- source_map : & ' a SourceMap ,
14+ tcx : TyCtxt < ' hir > ,
15+
1816 bodies : & ' a SortedMap < ItemLocalId , & ' hir Body < ' hir > > ,
1917
2018 /// Outputs
@@ -25,14 +23,11 @@ pub(super) struct NodeCollector<'a, 'hir> {
2523 parent_node : hir:: ItemLocalId ,
2624
2725 owner : OwnerId ,
28-
29- definitions : & ' a definitions:: Definitions ,
3026}
3127
32- #[ instrument( level = "debug" , skip( sess , definitions , bodies) ) ]
28+ #[ instrument( level = "debug" , skip( tcx , bodies) ) ]
3329pub ( super ) fn index_hir < ' hir > (
34- sess : & Session ,
35- definitions : & definitions:: Definitions ,
30+ tcx : TyCtxt < ' hir > ,
3631 item : hir:: OwnerNode < ' hir > ,
3732 bodies : & SortedMap < ItemLocalId , & ' hir Body < ' hir > > ,
3833) -> ( IndexVec < ItemLocalId , Option < ParentedNode < ' hir > > > , FxHashMap < LocalDefId , ItemLocalId > ) {
@@ -42,8 +37,7 @@ pub(super) fn index_hir<'hir>(
4237 // used.
4338 nodes. push ( Some ( ParentedNode { parent : ItemLocalId :: INVALID , node : item. into ( ) } ) ) ;
4439 let mut collector = NodeCollector {
45- source_map : sess. source_map ( ) ,
46- definitions,
40+ tcx,
4741 owner : item. def_id ( ) ,
4842 parent_node : ItemLocalId :: new ( 0 ) ,
4943 nodes,
@@ -79,11 +73,17 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
7973 span,
8074 "inconsistent HirId at `{:?}` for `{:?}`: \
8175 current_dep_node_owner={} ({:?}), hir_id.owner={} ({:?})",
82- self . source_map. span_to_diagnostic_string( span) ,
76+ self . tcx . sess . source_map( ) . span_to_diagnostic_string( span) ,
8377 node,
84- self . definitions. def_path( self . owner. def_id) . to_string_no_crate_verbose( ) ,
78+ self . tcx
79+ . definitions_untracked( )
80+ . def_path( self . owner. def_id)
81+ . to_string_no_crate_verbose( ) ,
8582 self . owner,
86- self . definitions. def_path( hir_id. owner. def_id) . to_string_no_crate_verbose( ) ,
83+ self . tcx
84+ . definitions_untracked( )
85+ . def_path( hir_id. owner. def_id)
86+ . to_string_no_crate_verbose( ) ,
8787 hir_id. owner,
8888 )
8989 }
0 commit comments