1
1
use crate :: hir:: def_id:: { DefId , DefIndex , CRATE_DEF_INDEX } ;
2
2
use crate :: hir:: { self , intravisit, HirId , ItemLocalId } ;
3
- use syntax:: ast:: NodeId ;
4
3
use crate :: hir:: itemlikevisit:: ItemLikeVisitor ;
5
4
use rustc_data_structures:: fx:: FxHashSet ;
6
5
use rustc_data_structures:: sync:: { Lock , ParallelIterator , par_iter} ;
@@ -112,19 +111,9 @@ impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> {
112
111
113
112
trace ! ( "missing hir id {:#?}" , hir_id) ;
114
113
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) ;
125
114
missing_items. push ( format ! ( "[local_id: {}, node:{}]" ,
126
115
local_id,
127
- self . hir_map. node_to_string( node_id ) ) ) ;
116
+ self . hir_map. node_to_string( hir_id ) ) ) ;
128
117
}
129
118
self . error ( || format ! (
130
119
"ItemLocalIds not assigned densely in {}. \
@@ -138,7 +127,7 @@ impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> {
138
127
owner: owner_def_index,
139
128
local_id,
140
129
} )
141
- . map( |h| format!( "({:?} {})" , h, self . hir_map. hir_to_string ( h) ) )
130
+ . map( |h| format!( "({:?} {})" , h, self . hir_map. node_to_string ( h) ) )
142
131
. collect:: <Vec <_>>( ) ) ) ;
143
132
}
144
133
}
@@ -156,14 +145,14 @@ impl<'a, 'hir: 'a> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
156
145
157
146
if hir_id == hir:: DUMMY_HIR_ID {
158
147
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) ) ) ;
160
149
return ;
161
150
}
162
151
163
152
if owner != hir_id. owner {
164
153
self . error ( || format ! (
165
154
"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) ,
167
156
self . hir_map. def_path( DefId :: local( hir_id. owner) ) . to_string_no_crate( ) ,
168
157
self . hir_map. def_path( DefId :: local( owner) ) . to_string_no_crate( ) ) ) ;
169
158
}
0 commit comments