@@ -425,7 +425,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
425425 /// declared for every type and trait definition.
426426 struct MiscCollector < ' tcx , ' lowering , ' hir > {
427427 lctx : & ' tcx mut LoweringContext < ' lowering , ' hir > ,
428- hir_id_owner : Option < NodeId > ,
429428 }
430429
431430 impl MiscCollector < ' _ , ' _ , ' _ > {
@@ -452,30 +451,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
452451 }
453452 }
454453 }
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- }
466454 }
467455
468456 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-
479457 fn visit_item ( & mut self , item : & ' tcx Item ) {
480458 let hir_id = self . lctx . allocate_hir_id_counter ( item. id ) ;
481459
@@ -499,24 +477,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
499477 _ => { }
500478 }
501479
502- self . with_hir_id_owner ( Some ( item. id ) , |this| {
503- visit:: walk_item ( this, item) ;
504- } ) ;
480+ visit:: walk_item ( self , item) ;
505481 }
506482
507483 fn visit_assoc_item ( & mut self , item : & ' tcx AssocItem , ctxt : AssocCtxt ) {
508484 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) ;
520486 }
521487
522488 fn visit_ty ( & mut self , t : & ' tcx Ty ) {
@@ -527,18 +493,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
527493 // Mirrors visit::walk_fn_decl
528494 for parameter in & f. decl . inputs {
529495 // 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 ) ;
533497 self . visit_ty ( & parameter. ty )
534498 }
535499 self . visit_fn_ret_ty ( & f. decl . output )
536500 }
537501 TyKind :: ImplTrait ( def_node_id, _) => {
538502 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) ;
542504 }
543505 _ => visit:: walk_ty ( self , t) ,
544506 }
@@ -548,7 +510,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
548510 self . lower_node_id ( CRATE_NODE_ID ) ;
549511 debug_assert ! ( self . node_id_to_hir_id[ CRATE_NODE_ID ] == Some ( hir:: CRATE_HIR_ID ) ) ;
550512
551- visit:: walk_crate ( & mut MiscCollector { lctx : & mut self , hir_id_owner : None } , c) ;
513+ visit:: walk_crate ( & mut MiscCollector { lctx : & mut self } , c) ;
552514 visit:: walk_crate ( & mut item:: ItemLowerer { lctx : & mut self } , c) ;
553515
554516 let module = self . lower_mod ( & c. module ) ;
0 commit comments