11use crate :: hir:: def_id:: { DefId , DefIndex , CRATE_DEF_INDEX } ;
22use crate :: hir:: { self , intravisit, HirId , ItemLocalId } ;
3- use syntax:: ast:: NodeId ;
43use crate :: hir:: itemlikevisit:: ItemLikeVisitor ;
54use rustc_data_structures:: fx:: FxHashSet ;
65use rustc_data_structures:: sync:: { Lock , ParallelIterator , par_iter} ;
@@ -112,19 +111,9 @@ impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> {
112111
113112 trace ! ( "missing hir id {:#?}" , hir_id) ;
114113
115- // We are already in ICE mode here, so doing a linear search
116- // should be fine.
117- let ( node_id, _) = self . hir_map
118- . definitions ( )
119- . node_to_hir_id
120- . iter ( )
121- . enumerate ( )
122- . find ( |& ( _, & entry) | hir_id == entry)
123- . expect ( "no node_to_hir_id entry" ) ;
124- let node_id = NodeId :: from_usize ( node_id) ;
125114 missing_items. push ( format ! ( "[local_id: {}, node:{}]" ,
126115 local_id,
127- self . hir_map. node_to_string( node_id ) ) ) ;
116+ self . hir_map. node_to_string( hir_id ) ) ) ;
128117 }
129118 self . error ( || format ! (
130119 "ItemLocalIds not assigned densely in {}. \
@@ -138,7 +127,7 @@ impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> {
138127 owner: owner_def_index,
139128 local_id,
140129 } )
141- . map( |h| format!( "({:?} {})" , h, self . hir_map. hir_to_string ( h) ) )
130+ . map( |h| format!( "({:?} {})" , h, self . hir_map. node_to_string ( h) ) )
142131 . collect:: <Vec <_>>( ) ) ) ;
143132 }
144133 }
@@ -156,14 +145,14 @@ impl<'a, 'hir: 'a> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
156145
157146 if hir_id == hir:: DUMMY_HIR_ID {
158147 self . error ( || format ! ( "HirIdValidator: HirId {:?} is invalid" ,
159- self . hir_map. hir_to_string ( hir_id) ) ) ;
148+ self . hir_map. node_to_string ( hir_id) ) ) ;
160149 return ;
161150 }
162151
163152 if owner != hir_id. owner {
164153 self . error ( || format ! (
165154 "HirIdValidator: The recorded owner of {} is {} instead of {}" ,
166- self . hir_map. hir_to_string ( hir_id) ,
155+ self . hir_map. node_to_string ( hir_id) ,
167156 self . hir_map. def_path( DefId :: local( hir_id. owner) ) . to_string_no_crate( ) ,
168157 self . hir_map. def_path( DefId :: local( owner) ) . to_string_no_crate( ) ) ) ;
169158 }
0 commit comments