@@ -27,8 +27,6 @@ pub(super) struct NodeCollector<'a, 'hir> {
27
27
/// The node map
28
28
map : Vec < Option < Entry < ' hir > > > ,
29
29
/// The parent of this node
30
- parent_node : NodeId ,
31
-
32
30
parent_hir : hir:: HirId ,
33
31
34
32
// These fields keep track of the currently relevant DepNodes during
@@ -149,7 +147,6 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
149
147
krate,
150
148
source_map : sess. source_map ( ) ,
151
149
map : repeat ( None ) . take ( sess. current_node_id_count ( ) ) . collect ( ) ,
152
- parent_node : CRATE_NODE_ID ,
153
150
parent_hir : hir:: CRATE_HIR_ID ,
154
151
current_signature_dep_index : root_mod_sig_dep_index,
155
152
current_full_dep_index : root_mod_full_dep_index,
@@ -233,7 +230,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
233
230
234
231
fn insert ( & mut self , span : Span , hir_id : HirId , node : Node < ' hir > ) {
235
232
let entry = Entry {
236
- parent : self . parent_node ,
233
+ parent : self . hir_to_node_id [ & self . parent_hir ] ,
237
234
parent_hir : self . parent_hir ,
238
235
dep_node : if self . currently_in_body {
239
236
self . current_full_dep_index
@@ -286,17 +283,13 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
286
283
287
284
fn with_parent < F : FnOnce ( & mut Self ) > (
288
285
& mut self ,
289
- parent_node_id : NodeId ,
290
286
parent_hir_id : HirId ,
291
287
f : F ,
292
288
) {
293
- let parent_node = self . parent_node ;
294
- self . parent_node = parent_node_id;
295
289
let parent_hir = self . parent_hir ;
296
290
self . parent_hir = parent_hir_id;
297
291
f ( self ) ;
298
292
self . parent_hir = parent_hir;
299
- self . parent_node = parent_node;
300
293
}
301
294
302
295
fn with_dep_node_owner < T : for < ' b > HashStable < StableHashingContext < ' b > > ,
@@ -366,7 +359,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
366
359
self . definitions. opt_def_index( i. id) . unwrap( ) ) ;
367
360
self . with_dep_node_owner ( i. hir_id . owner , i, |this| {
368
361
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| {
370
363
if let ItemKind :: Struct ( ref struct_def, _) = i. node {
371
364
// If this is a tuple-like struct, register the constructor.
372
365
if !struct_def. is_struct ( ) {
@@ -381,7 +374,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
381
374
fn visit_foreign_item ( & mut self , foreign_item : & ' hir ForeignItem ) {
382
375
self . insert ( foreign_item. span , foreign_item. hir_id , Node :: ForeignItem ( foreign_item) ) ;
383
376
384
- self . with_parent ( foreign_item. id , foreign_item . hir_id , |this| {
377
+ self . with_parent ( foreign_item. hir_id , |this| {
385
378
intravisit:: walk_foreign_item ( this, foreign_item) ;
386
379
} ) ;
387
380
}
@@ -397,7 +390,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
397
390
self . with_dep_node_owner ( ti. hir_id . owner , ti, |this| {
398
391
this. insert ( ti. span , ti. hir_id , Node :: TraitItem ( ti) ) ;
399
392
400
- this. with_parent ( ti. id , ti . hir_id , |this| {
393
+ this. with_parent ( ti. hir_id , |this| {
401
394
intravisit:: walk_trait_item ( this, ti) ;
402
395
} ) ;
403
396
} ) ;
@@ -409,7 +402,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
409
402
self . with_dep_node_owner ( ii. hir_id . owner , ii, |this| {
410
403
this. insert ( ii. span , ii. hir_id , Node :: ImplItem ( ii) ) ;
411
404
412
- this. with_parent ( ii. id , ii . hir_id , |this| {
405
+ this. with_parent ( ii. hir_id , |this| {
413
406
intravisit:: walk_impl_item ( this, ii) ;
414
407
} ) ;
415
408
} ) ;
@@ -423,31 +416,31 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
423
416
} ;
424
417
self . insert ( pat. span , pat. hir_id , node) ;
425
418
426
- self . with_parent ( pat. id , pat . hir_id , |this| {
419
+ self . with_parent ( pat. hir_id , |this| {
427
420
intravisit:: walk_pat ( this, pat) ;
428
421
} ) ;
429
422
}
430
423
431
424
fn visit_anon_const ( & mut self , constant : & ' hir AnonConst ) {
432
425
self . insert ( DUMMY_SP , constant. hir_id , Node :: AnonConst ( constant) ) ;
433
426
434
- self . with_parent ( constant. id , constant . hir_id , |this| {
427
+ self . with_parent ( constant. hir_id , |this| {
435
428
intravisit:: walk_anon_const ( this, constant) ;
436
429
} ) ;
437
430
}
438
431
439
432
fn visit_expr ( & mut self , expr : & ' hir Expr ) {
440
433
self . insert ( expr. span , expr. hir_id , Node :: Expr ( expr) ) ;
441
434
442
- self . with_parent ( expr. id , expr . hir_id , |this| {
435
+ self . with_parent ( expr. hir_id , |this| {
443
436
intravisit:: walk_expr ( this, expr) ;
444
437
} ) ;
445
438
}
446
439
447
440
fn visit_stmt ( & mut self , stmt : & ' hir Stmt ) {
448
441
self . insert ( stmt. span , stmt. hir_id , Node :: Stmt ( stmt) ) ;
449
442
450
- self . with_parent ( stmt. id , stmt . hir_id , |this| {
443
+ self . with_parent ( stmt. hir_id , |this| {
451
444
intravisit:: walk_stmt ( this, stmt) ;
452
445
} ) ;
453
446
}
@@ -463,15 +456,15 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
463
456
fn visit_ty ( & mut self , ty : & ' hir Ty ) {
464
457
self . insert ( ty. span , ty. hir_id , Node :: Ty ( ty) ) ;
465
458
466
- self . with_parent ( ty. id , ty . hir_id , |this| {
459
+ self . with_parent ( ty. hir_id , |this| {
467
460
intravisit:: walk_ty ( this, ty) ;
468
461
} ) ;
469
462
}
470
463
471
464
fn visit_trait_ref ( & mut self , tr : & ' hir TraitRef ) {
472
465
self . insert ( tr. path . span , tr. hir_ref_id , Node :: TraitRef ( tr) ) ;
473
466
474
- self . with_parent ( tr. ref_id , tr . hir_ref_id , |this| {
467
+ self . with_parent ( tr. hir_ref_id , |this| {
475
468
intravisit:: walk_trait_ref ( this, tr) ;
476
469
} ) ;
477
470
}
@@ -484,14 +477,14 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
484
477
485
478
fn visit_block ( & mut self , block : & ' hir Block ) {
486
479
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| {
488
481
intravisit:: walk_block ( this, block) ;
489
482
} ) ;
490
483
}
491
484
492
485
fn visit_local ( & mut self , l : & ' hir Local ) {
493
486
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| {
495
488
intravisit:: walk_local ( this, l)
496
489
} )
497
490
}
@@ -505,9 +498,9 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
505
498
VisibilityKind :: Public |
506
499
VisibilityKind :: Crate ( _) |
507
500
VisibilityKind :: Inherited => { }
508
- VisibilityKind :: Restricted { id , hir_id, .. } => {
501
+ VisibilityKind :: Restricted { hir_id, .. } => {
509
502
self . insert ( visibility. span , hir_id, Node :: Visibility ( visibility) ) ;
510
- self . with_parent ( id , hir_id, |this| {
503
+ self . with_parent ( hir_id, |this| {
511
504
intravisit:: walk_vis ( this, visibility) ;
512
505
} ) ;
513
506
}
@@ -524,14 +517,14 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
524
517
525
518
fn visit_variant ( & mut self , v : & ' hir Variant , g : & ' hir Generics , item_id : HirId ) {
526
519
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| {
528
521
intravisit:: walk_variant ( this, v, g, item_id) ;
529
522
} ) ;
530
523
}
531
524
532
525
fn visit_struct_field ( & mut self , field : & ' hir StructField ) {
533
526
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| {
535
528
intravisit:: walk_struct_field ( this, field) ;
536
529
} ) ;
537
530
}
0 commit comments