@@ -27,8 +27,6 @@ pub(super) struct NodeCollector<'a, 'hir> {
2727 /// The node map
2828 map : Vec < Option < Entry < ' hir > > > ,
2929 /// The parent of this node
30- parent_node : NodeId ,
31-
3230 parent_hir : hir:: HirId ,
3331
3432 // These fields keep track of the currently relevant DepNodes during
@@ -149,7 +147,6 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
149147 krate,
150148 source_map : sess. source_map ( ) ,
151149 map : repeat ( None ) . take ( sess. current_node_id_count ( ) ) . collect ( ) ,
152- parent_node : CRATE_NODE_ID ,
153150 parent_hir : hir:: CRATE_HIR_ID ,
154151 current_signature_dep_index : root_mod_sig_dep_index,
155152 current_full_dep_index : root_mod_full_dep_index,
@@ -233,7 +230,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
233230
234231 fn insert ( & mut self , span : Span , hir_id : HirId , node : Node < ' hir > ) {
235232 let entry = Entry {
236- parent : self . parent_node ,
233+ parent : self . hir_to_node_id [ & self . parent_hir ] ,
237234 parent_hir : self . parent_hir ,
238235 dep_node : if self . currently_in_body {
239236 self . current_full_dep_index
@@ -286,17 +283,13 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
286283
287284 fn with_parent < F : FnOnce ( & mut Self ) > (
288285 & mut self ,
289- parent_node_id : NodeId ,
290286 parent_hir_id : HirId ,
291287 f : F ,
292288 ) {
293- let parent_node = self . parent_node ;
294- self . parent_node = parent_node_id;
295289 let parent_hir = self . parent_hir ;
296290 self . parent_hir = parent_hir_id;
297291 f ( self ) ;
298292 self . parent_hir = parent_hir;
299- self . parent_node = parent_node;
300293 }
301294
302295 fn with_dep_node_owner < T : for < ' b > HashStable < StableHashingContext < ' b > > ,
@@ -366,7 +359,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
366359 self . definitions. opt_def_index( i. id) . unwrap( ) ) ;
367360 self . with_dep_node_owner ( i. hir_id . owner , i, |this| {
368361 this. insert ( i. span , i. hir_id , Node :: Item ( i) ) ;
369- this. with_parent ( i. id , i . hir_id , |this| {
362+ this. with_parent ( i. hir_id , |this| {
370363 if let ItemKind :: Struct ( ref struct_def, _) = i. node {
371364 // If this is a tuple-like struct, register the constructor.
372365 if !struct_def. is_struct ( ) {
@@ -381,7 +374,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
381374 fn visit_foreign_item ( & mut self , foreign_item : & ' hir ForeignItem ) {
382375 self . insert ( foreign_item. span , foreign_item. hir_id , Node :: ForeignItem ( foreign_item) ) ;
383376
384- self . with_parent ( foreign_item. id , foreign_item . hir_id , |this| {
377+ self . with_parent ( foreign_item. hir_id , |this| {
385378 intravisit:: walk_foreign_item ( this, foreign_item) ;
386379 } ) ;
387380 }
@@ -397,7 +390,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
397390 self . with_dep_node_owner ( ti. hir_id . owner , ti, |this| {
398391 this. insert ( ti. span , ti. hir_id , Node :: TraitItem ( ti) ) ;
399392
400- this. with_parent ( ti. id , ti . hir_id , |this| {
393+ this. with_parent ( ti. hir_id , |this| {
401394 intravisit:: walk_trait_item ( this, ti) ;
402395 } ) ;
403396 } ) ;
@@ -409,7 +402,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
409402 self . with_dep_node_owner ( ii. hir_id . owner , ii, |this| {
410403 this. insert ( ii. span , ii. hir_id , Node :: ImplItem ( ii) ) ;
411404
412- this. with_parent ( ii. id , ii . hir_id , |this| {
405+ this. with_parent ( ii. hir_id , |this| {
413406 intravisit:: walk_impl_item ( this, ii) ;
414407 } ) ;
415408 } ) ;
@@ -423,31 +416,31 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
423416 } ;
424417 self . insert ( pat. span , pat. hir_id , node) ;
425418
426- self . with_parent ( pat. id , pat . hir_id , |this| {
419+ self . with_parent ( pat. hir_id , |this| {
427420 intravisit:: walk_pat ( this, pat) ;
428421 } ) ;
429422 }
430423
431424 fn visit_anon_const ( & mut self , constant : & ' hir AnonConst ) {
432425 self . insert ( DUMMY_SP , constant. hir_id , Node :: AnonConst ( constant) ) ;
433426
434- self . with_parent ( constant. id , constant . hir_id , |this| {
427+ self . with_parent ( constant. hir_id , |this| {
435428 intravisit:: walk_anon_const ( this, constant) ;
436429 } ) ;
437430 }
438431
439432 fn visit_expr ( & mut self , expr : & ' hir Expr ) {
440433 self . insert ( expr. span , expr. hir_id , Node :: Expr ( expr) ) ;
441434
442- self . with_parent ( expr. id , expr . hir_id , |this| {
435+ self . with_parent ( expr. hir_id , |this| {
443436 intravisit:: walk_expr ( this, expr) ;
444437 } ) ;
445438 }
446439
447440 fn visit_stmt ( & mut self , stmt : & ' hir Stmt ) {
448441 self . insert ( stmt. span , stmt. hir_id , Node :: Stmt ( stmt) ) ;
449442
450- self . with_parent ( stmt. id , stmt . hir_id , |this| {
443+ self . with_parent ( stmt. hir_id , |this| {
451444 intravisit:: walk_stmt ( this, stmt) ;
452445 } ) ;
453446 }
@@ -463,15 +456,15 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
463456 fn visit_ty ( & mut self , ty : & ' hir Ty ) {
464457 self . insert ( ty. span , ty. hir_id , Node :: Ty ( ty) ) ;
465458
466- self . with_parent ( ty. id , ty . hir_id , |this| {
459+ self . with_parent ( ty. hir_id , |this| {
467460 intravisit:: walk_ty ( this, ty) ;
468461 } ) ;
469462 }
470463
471464 fn visit_trait_ref ( & mut self , tr : & ' hir TraitRef ) {
472465 self . insert ( tr. path . span , tr. hir_ref_id , Node :: TraitRef ( tr) ) ;
473466
474- self . with_parent ( tr. ref_id , tr . hir_ref_id , |this| {
467+ self . with_parent ( tr. hir_ref_id , |this| {
475468 intravisit:: walk_trait_ref ( this, tr) ;
476469 } ) ;
477470 }
@@ -484,14 +477,14 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
484477
485478 fn visit_block ( & mut self , block : & ' hir Block ) {
486479 self . insert ( block. span , block. hir_id , Node :: Block ( block) ) ;
487- self . with_parent ( block. id , block . hir_id , |this| {
480+ self . with_parent ( block. hir_id , |this| {
488481 intravisit:: walk_block ( this, block) ;
489482 } ) ;
490483 }
491484
492485 fn visit_local ( & mut self , l : & ' hir Local ) {
493486 self . insert ( l. span , l. hir_id , Node :: Local ( l) ) ;
494- self . with_parent ( l. id , l . hir_id , |this| {
487+ self . with_parent ( l. hir_id , |this| {
495488 intravisit:: walk_local ( this, l)
496489 } )
497490 }
@@ -505,9 +498,9 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
505498 VisibilityKind :: Public |
506499 VisibilityKind :: Crate ( _) |
507500 VisibilityKind :: Inherited => { }
508- VisibilityKind :: Restricted { id , hir_id, .. } => {
501+ VisibilityKind :: Restricted { hir_id, .. } => {
509502 self . insert ( visibility. span , hir_id, Node :: Visibility ( visibility) ) ;
510- self . with_parent ( id , hir_id, |this| {
503+ self . with_parent ( hir_id, |this| {
511504 intravisit:: walk_vis ( this, visibility) ;
512505 } ) ;
513506 }
@@ -524,14 +517,14 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
524517
525518 fn visit_variant ( & mut self , v : & ' hir Variant , g : & ' hir Generics , item_id : HirId ) {
526519 self . insert ( v. span , v. node . data . hir_id ( ) , Node :: Variant ( v) ) ;
527- self . with_parent ( v. node . data . id ( ) , v . node . data . hir_id ( ) , |this| {
520+ self . with_parent ( v. node . data . hir_id ( ) , |this| {
528521 intravisit:: walk_variant ( this, v, g, item_id) ;
529522 } ) ;
530523 }
531524
532525 fn visit_struct_field ( & mut self , field : & ' hir StructField ) {
533526 self . insert ( field. span , field. hir_id , Node :: Field ( field) ) ;
534- self . with_parent ( field. id , field . hir_id , |this| {
527+ self . with_parent ( field. hir_id , |this| {
535528 intravisit:: walk_struct_field ( this, field) ;
536529 } ) ;
537530 }
0 commit comments