@@ -425,7 +425,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
425
425
/// declared for every type and trait definition.
426
426
struct MiscCollector < ' tcx , ' lowering , ' hir > {
427
427
lctx : & ' tcx mut LoweringContext < ' lowering , ' hir > ,
428
- hir_id_owner : Option < NodeId > ,
429
428
}
430
429
431
430
impl MiscCollector < ' _ , ' _ , ' _ > {
@@ -452,30 +451,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
452
451
}
453
452
}
454
453
}
455
-
456
- fn with_hir_id_owner < T > (
457
- & mut self ,
458
- owner : Option < NodeId > ,
459
- f : impl FnOnce ( & mut Self ) -> T ,
460
- ) -> T {
461
- let old = mem:: replace ( & mut self . hir_id_owner , owner) ;
462
- let r = f ( self ) ;
463
- self . hir_id_owner = old;
464
- r
465
- }
466
454
}
467
455
468
456
impl < ' tcx > Visitor < ' tcx > for MiscCollector < ' tcx , ' _ , ' _ > {
469
- fn visit_pat ( & mut self , p : & ' tcx Pat ) {
470
- if let PatKind :: Paren ( ..) | PatKind :: Rest = p. kind {
471
- // Doesn't generate a HIR node
472
- } else if let Some ( owner) = self . hir_id_owner {
473
- self . lctx . lower_node_id_with_owner ( p. id , owner) ;
474
- }
475
-
476
- visit:: walk_pat ( self , p)
477
- }
478
-
479
457
fn visit_item ( & mut self , item : & ' tcx Item ) {
480
458
let hir_id = self . lctx . allocate_hir_id_counter ( item. id ) ;
481
459
@@ -499,24 +477,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
499
477
_ => { }
500
478
}
501
479
502
- self . with_hir_id_owner ( Some ( item. id ) , |this| {
503
- visit:: walk_item ( this, item) ;
504
- } ) ;
480
+ visit:: walk_item ( self , item) ;
505
481
}
506
482
507
483
fn visit_assoc_item ( & mut self , item : & ' tcx AssocItem , ctxt : AssocCtxt ) {
508
484
self . lctx . allocate_hir_id_counter ( item. id ) ;
509
- let owner = match ( & item. kind , ctxt) {
510
- // Ignore patterns in trait methods without bodies.
511
- ( AssocItemKind :: Fn ( _, _, _, None ) , AssocCtxt :: Trait ) => None ,
512
- _ => Some ( item. id ) ,
513
- } ;
514
- self . with_hir_id_owner ( owner, |this| visit:: walk_assoc_item ( this, item, ctxt) ) ;
515
- }
516
-
517
- fn visit_foreign_item ( & mut self , i : & ' tcx ForeignItem ) {
518
- // Ignore patterns in foreign items
519
- self . with_hir_id_owner ( None , |this| visit:: walk_foreign_item ( this, i) ) ;
485
+ visit:: walk_assoc_item ( self , item, ctxt) ;
520
486
}
521
487
522
488
fn visit_ty ( & mut self , t : & ' tcx Ty ) {
@@ -527,18 +493,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
527
493
// Mirrors visit::walk_fn_decl
528
494
for parameter in & f. decl . inputs {
529
495
// We don't lower the ids of argument patterns
530
- self . with_hir_id_owner ( None , |this| {
531
- this. visit_pat ( & parameter. pat ) ;
532
- } ) ;
496
+ self . visit_pat ( & parameter. pat ) ;
533
497
self . visit_ty ( & parameter. ty )
534
498
}
535
499
self . visit_fn_ret_ty ( & f. decl . output )
536
500
}
537
501
TyKind :: ImplTrait ( def_node_id, _) => {
538
502
self . lctx . allocate_hir_id_counter ( def_node_id) ;
539
- self . with_hir_id_owner ( Some ( def_node_id) , |this| {
540
- visit:: walk_ty ( this, t) ;
541
- } ) ;
503
+ visit:: walk_ty ( self , t) ;
542
504
}
543
505
_ => visit:: walk_ty ( self , t) ,
544
506
}
@@ -548,7 +510,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
548
510
self . lower_node_id ( CRATE_NODE_ID ) ;
549
511
debug_assert ! ( self . node_id_to_hir_id[ CRATE_NODE_ID ] == Some ( hir:: CRATE_HIR_ID ) ) ;
550
512
551
- visit:: walk_crate ( & mut MiscCollector { lctx : & mut self , hir_id_owner : None } , c) ;
513
+ visit:: walk_crate ( & mut MiscCollector { lctx : & mut self } , c) ;
552
514
visit:: walk_crate ( & mut item:: ItemLowerer { lctx : & mut self } , c) ;
553
515
554
516
let module = self . lower_mod ( & c. module ) ;
0 commit comments