@@ -12,6 +12,7 @@ use rustc_hir::def::{DefKind, Res};
1212use rustc_hir:: def_id:: { LocalDefId , CRATE_DEF_ID } ;
1313use rustc_hir:: PredicateOrigin ;
1414use rustc_index:: { Idx , IndexSlice , IndexVec } ;
15+ use rustc_middle:: span_bug;
1516use rustc_middle:: ty:: { ResolverAstLowering , TyCtxt } ;
1617use rustc_span:: edit_distance:: find_best_match_for_name;
1718use rustc_span:: symbol:: { kw, sym, Ident } ;
@@ -576,23 +577,25 @@ impl<'hir> LoweringContext<'_, 'hir> {
576577 // This is used to track which lifetimes have already been defined,
577578 // and which need to be replicated when lowering an async fn.
578579
579- match parent_hir. node ( ) . expect_item ( ) . kind {
580+ let generics = match parent_hir. node ( ) . expect_item ( ) . kind {
580581 hir:: ItemKind :: Impl ( impl_) => {
581582 self . is_in_trait_impl = impl_. of_trait . is_some ( ) ;
583+ & impl_. generics
582584 }
583- hir:: ItemKind :: Trait ( _, _, generics, _, _) if self . tcx . features ( ) . effects => {
584- self . host_param_id = generics
585- . params
586- . iter ( )
587- . find ( |param| {
588- matches ! (
589- param. kind,
590- hir:: GenericParamKind :: Const { is_host_effect: true , .. }
591- )
592- } )
593- . map ( |param| param. def_id ) ;
585+ hir:: ItemKind :: Trait ( _, _, generics, _, _) => generics,
586+ kind => {
587+ span_bug ! ( item. span, "assoc item has unexpected kind of parent: {}" , kind. descr( ) )
594588 }
595- _ => { }
589+ } ;
590+
591+ if self . tcx . features ( ) . effects {
592+ self . host_param_id = generics
593+ . params
594+ . iter ( )
595+ . find ( |param| {
596+ matches ! ( param. kind, hir:: GenericParamKind :: Const { is_host_effect: true , .. } )
597+ } )
598+ . map ( |param| param. def_id ) ;
596599 }
597600
598601 match ctxt {
0 commit comments