@@ -23,7 +23,7 @@ use rustc_hir::def::{CtorOf, DefKind, Namespace, Res};
2323use rustc_hir:: def_id:: { DefId , LocalDefId } ;
2424use rustc_hir:: intravisit:: { walk_generics, Visitor as _} ;
2525use rustc_hir:: lang_items:: LangItem ;
26- use rustc_hir:: { GenericArg , GenericArgs } ;
26+ use rustc_hir:: { GenericArg , GenericArgs , OpaqueTyOrigin } ;
2727use rustc_middle:: middle:: stability:: AllowUnstable ;
2828use rustc_middle:: ty:: subst:: { self , GenericArgKind , InternalSubsts , Subst , SubstsRef } ;
2929use rustc_middle:: ty:: GenericParamDefKind ;
@@ -2628,16 +2628,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
26282628 let def_id = item_id. def_id . to_def_id ( ) ;
26292629
26302630 match opaque_ty. kind {
2631- hir:: ItemKind :: OpaqueTy ( hir:: OpaqueTy { origin, .. } ) => self
2632- . impl_trait_ty_to_ty (
2633- def_id,
2634- lifetimes,
2635- matches ! (
2636- origin,
2637- hir:: OpaqueTyOrigin :: FnReturn ( ..)
2638- | hir:: OpaqueTyOrigin :: AsyncFn ( ..)
2639- ) ,
2640- ) ,
2631+ hir:: ItemKind :: OpaqueTy ( hir:: OpaqueTy { origin, .. } ) => {
2632+ self . impl_trait_ty_to_ty ( def_id, lifetimes, origin)
2633+ }
26412634 ref i => bug ! ( "`impl Trait` pointed to non-opaque type?? {:#?}" , i) ,
26422635 }
26432636 }
@@ -2706,7 +2699,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
27062699 & self ,
27072700 def_id : DefId ,
27082701 lifetimes : & [ hir:: GenericArg < ' _ > ] ,
2709- replace_parent_lifetimes : bool ,
2702+ origin : OpaqueTyOrigin ,
27102703 ) -> Ty < ' tcx > {
27112704 debug ! ( "impl_trait_ty_to_ty(def_id={:?}, lifetimes={:?})" , def_id, lifetimes) ;
27122705 let tcx = self . tcx ( ) ;
@@ -2736,7 +2729,12 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
27362729 // For `impl Trait` in the types of statics, constants,
27372730 // locals and type aliases. These capture all parent
27382731 // lifetimes, so they can use their identity subst.
2739- GenericParamDefKind :: Lifetime if replace_parent_lifetimes => {
2732+ GenericParamDefKind :: Lifetime
2733+ if matches ! (
2734+ origin,
2735+ hir:: OpaqueTyOrigin :: FnReturn ( ..) | hir:: OpaqueTyOrigin :: AsyncFn ( ..)
2736+ ) =>
2737+ {
27402738 tcx. lifetimes . re_static . into ( )
27412739 }
27422740 _ => tcx. mk_param_from_def ( param) ,
0 commit comments