@@ -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 } ;
@@ -572,23 +573,25 @@ impl<'hir> LoweringContext<'_, 'hir> {
572573 // This is used to track which lifetimes have already been defined,
573574 // and which need to be replicated when lowering an async fn.
574575
575- match parent_hir. node ( ) . expect_item ( ) . kind {
576+ let generics = match parent_hir. node ( ) . expect_item ( ) . kind {
576577 hir:: ItemKind :: Impl ( impl_) => {
577578 self . is_in_trait_impl = impl_. of_trait . is_some ( ) ;
579+ & impl_. generics
578580 }
579- hir:: ItemKind :: Trait ( _, _, generics, _, _) if self . tcx . features ( ) . effects => {
580- self . host_param_id = generics
581- . params
582- . iter ( )
583- . find ( |param| {
584- matches ! (
585- param. kind,
586- hir:: GenericParamKind :: Const { is_host_effect: true , .. }
587- )
588- } )
589- . map ( |param| param. def_id ) ;
581+ hir:: ItemKind :: Trait ( _, _, generics, _, _) => generics,
582+ kind => {
583+ span_bug ! ( item. span, "assoc item has unexpected kind of parent: {}" , kind. descr( ) )
590584 }
591- _ => { }
585+ } ;
586+
587+ if self . tcx . features ( ) . effects {
588+ self . host_param_id = generics
589+ . params
590+ . iter ( )
591+ . find ( |param| {
592+ matches ! ( param. kind, hir:: GenericParamKind :: Const { is_host_effect: true , .. } )
593+ } )
594+ . map ( |param| param. def_id ) ;
592595 }
593596
594597 match ctxt {
0 commit comments