@@ -7,7 +7,6 @@ use rustc_hir::def::{DefKind, Res};
7
7
use rustc_hir:: def_id:: { CRATE_DEF_ID , LocalDefId } ;
8
8
use rustc_hir:: { self as hir, HirId , PredicateOrigin } ;
9
9
use rustc_index:: { IndexSlice , IndexVec } ;
10
- use rustc_middle:: span_bug;
11
10
use rustc_middle:: ty:: { ResolverAstLowering , TyCtxt } ;
12
11
use rustc_span:: edit_distance:: find_best_match_for_name;
13
12
use rustc_span:: { DUMMY_SP , DesugaringKind , Ident , Span , Symbol , kw, sym} ;
@@ -104,10 +103,7 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
104
103
}
105
104
106
105
fn lower_assoc_item ( & mut self , item : & AssocItem , ctxt : AssocCtxt ) {
107
- let def_id = self . resolver . node_id_to_def_id [ & item. id ] ;
108
- let parent_id = self . tcx . local_parent ( def_id) ;
109
- let parent_hir = self . lower_node ( parent_id) . unwrap ( ) ;
110
- self . with_lctx ( item. id , |lctx| lctx. lower_assoc_item ( item, ctxt, parent_hir) )
106
+ self . with_lctx ( item. id , |lctx| lctx. lower_assoc_item ( item, ctxt) )
111
107
}
112
108
113
109
fn lower_foreign_item ( & mut self , item : & ForeignItem ) {
@@ -631,29 +627,18 @@ impl<'hir> LoweringContext<'_, 'hir> {
631
627
}
632
628
}
633
629
634
- fn lower_assoc_item (
635
- & mut self ,
636
- item : & AssocItem ,
637
- ctxt : AssocCtxt ,
638
- parent_hir : & ' hir hir:: OwnerInfo < ' hir > ,
639
- ) -> hir:: OwnerNode < ' hir > {
640
- let parent_item = parent_hir. node ( ) . expect_item ( ) ;
641
- match parent_item. kind {
642
- hir:: ItemKind :: Impl ( impl_) => {
643
- self . is_in_trait_impl = impl_. of_trait . is_some ( ) ;
644
- }
645
- hir:: ItemKind :: Trait ( ..) => { }
646
- kind => {
647
- span_bug ! ( item. span, "assoc item has unexpected kind of parent: {}" , kind. descr( ) )
648
- }
649
- }
650
-
630
+ fn lower_assoc_item ( & mut self , item : & AssocItem , ctxt : AssocCtxt ) -> hir:: OwnerNode < ' hir > {
651
631
// Evaluate with the lifetimes in `params` in-scope.
652
632
// This is used to track which lifetimes have already been defined,
653
633
// and which need to be replicated when lowering an async fn.
654
634
match ctxt {
655
635
AssocCtxt :: Trait => hir:: OwnerNode :: TraitItem ( self . lower_trait_item ( item) ) ,
656
- AssocCtxt :: Impl => hir:: OwnerNode :: ImplItem ( self . lower_impl_item ( item) ) ,
636
+ AssocCtxt :: Impl { of_trait } => {
637
+ if of_trait {
638
+ self . is_in_trait_impl = of_trait;
639
+ }
640
+ hir:: OwnerNode :: ImplItem ( self . lower_impl_item ( item) )
641
+ }
657
642
}
658
643
}
659
644
0 commit comments