@@ -8,8 +8,8 @@ use crate::ich::Fingerprint;
8
8
use crate :: middle:: cstore:: CrateStore ;
9
9
use crate :: session:: CrateDisambiguator ;
10
10
use crate :: session:: Session ;
11
- use std :: iter :: repeat ;
12
- use syntax:: ast:: { NodeId , CRATE_NODE_ID } ;
11
+ use crate :: util :: nodemap :: FxHashMap ;
12
+ use syntax:: ast:: NodeId ;
13
13
use syntax:: source_map:: SourceMap ;
14
14
use syntax_pos:: Span ;
15
15
@@ -25,7 +25,7 @@ pub(super) struct NodeCollector<'a, 'hir> {
25
25
source_map : & ' a SourceMap ,
26
26
27
27
/// The node map
28
- map : Vec < Option < Entry < ' hir > > > ,
28
+ map : FxHashMap < HirId , Entry < ' hir > > ,
29
29
/// The parent of this node
30
30
parent_node : hir:: HirId ,
31
31
@@ -146,7 +146,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
146
146
let mut collector = NodeCollector {
147
147
krate,
148
148
source_map : sess. source_map ( ) ,
149
- map : repeat ( None ) . take ( sess . current_node_id_count ( ) ) . collect ( ) ,
149
+ map : Default :: default ( ) ,
150
150
parent_node : hir:: CRATE_HIR_ID ,
151
151
current_signature_dep_index : root_mod_sig_dep_index,
152
152
current_full_dep_index : root_mod_full_dep_index,
@@ -158,9 +158,8 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
158
158
hcx,
159
159
hir_body_nodes,
160
160
} ;
161
- collector. insert_entry ( CRATE_NODE_ID , Entry {
162
- parent : CRATE_NODE_ID ,
163
- parent_hir : hir:: CRATE_HIR_ID ,
161
+ collector. insert_entry ( hir:: CRATE_HIR_ID , Entry {
162
+ parent : hir:: CRATE_HIR_ID ,
164
163
dep_node : root_mod_sig_dep_index,
165
164
node : Node :: Crate ,
166
165
} ) ;
@@ -172,7 +171,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
172
171
crate_disambiguator : CrateDisambiguator ,
173
172
cstore : & dyn CrateStore ,
174
173
commandline_args_hash : u64 )
175
- -> ( Vec < Option < Entry < ' hir > > > , Svh )
174
+ -> ( FxHashMap < HirId , Entry < ' hir > > , Svh )
176
175
{
177
176
self . hir_body_nodes . sort_unstable_by_key ( |bn| bn. 0 ) ;
178
177
@@ -223,15 +222,14 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
223
222
( self . map , svh)
224
223
}
225
224
226
- fn insert_entry ( & mut self , id : NodeId , entry : Entry < ' hir > ) {
225
+ fn insert_entry ( & mut self , id : HirId , entry : Entry < ' hir > ) {
227
226
debug ! ( "hir_map: {:?} => {:?}" , id, entry) ;
228
- self . map [ id . as_usize ( ) ] = Some ( entry) ;
227
+ self . map . insert ( id , entry) ;
229
228
}
230
229
231
230
fn insert ( & mut self , span : Span , hir_id : HirId , node : Node < ' hir > ) {
232
231
let entry = Entry {
233
- parent : self . hir_to_node_id [ & self . parent_node ] ,
234
- parent_hir : self . parent_node ,
232
+ parent : self . parent_node ,
235
233
dep_node : if self . currently_in_body {
236
234
self . current_full_dep_index
237
235
} else {
@@ -240,12 +238,11 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
240
238
node,
241
239
} ;
242
240
243
- let node_id = self . hir_to_node_id [ & hir_id] ;
244
-
245
241
// Make sure that the DepNode of some node coincides with the HirId
246
242
// owner of that node.
247
243
if cfg ! ( debug_assertions) {
248
- assert_eq ! ( self . definitions. node_to_hir_id( node_id) , hir_id) ;
244
+ let node_id = self . hir_to_node_id [ & hir_id] ;
245
+ assert_eq ! ( self . definitions. node_to_hir_id( node_id) , hir_id) ;
249
246
250
247
if hir_id. owner != self . current_dep_node_owner {
251
248
let node_str = match self . definitions . opt_def_index ( node_id) {
@@ -278,7 +275,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
278
275
}
279
276
}
280
277
281
- self . insert_entry ( node_id , entry) ;
278
+ self . insert_entry ( hir_id , entry) ;
282
279
}
283
280
284
281
fn with_parent < F : FnOnce ( & mut Self ) > (
0 commit comments