@@ -247,7 +247,7 @@ enum ImplTraitContext {
247247 in_trait : bool ,
248248 } ,
249249 /// Impl trait in type aliases.
250- TypeAliasesOpaqueTy ,
250+ TypeAliasesOpaqueTy { in_assoc_ty : bool } ,
251251 /// `impl Trait` is unstably accepted in this position.
252252 FeatureGated ( ImplTraitPosition , Symbol ) ,
253253 /// `impl Trait` is not accepted in this position.
@@ -1407,14 +1407,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
14071407 * in_trait,
14081408 itctx,
14091409 ) ,
1410- ImplTraitContext :: TypeAliasesOpaqueTy => self . lower_opaque_impl_trait (
1411- span,
1412- hir:: OpaqueTyOrigin :: TyAlias ,
1413- * def_node_id,
1414- bounds,
1415- false ,
1416- itctx,
1417- ) ,
1410+ & ImplTraitContext :: TypeAliasesOpaqueTy { in_assoc_ty } => self
1411+ . lower_opaque_impl_trait (
1412+ span,
1413+ hir:: OpaqueTyOrigin :: TyAlias { in_assoc_ty } ,
1414+ * def_node_id,
1415+ bounds,
1416+ false ,
1417+ itctx,
1418+ ) ,
14181419 ImplTraitContext :: Universal => {
14191420 let span = t. span ;
14201421 self . create_def (
@@ -1534,13 +1535,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
15341535 // If this came from a TAIT (as opposed to a function that returns an RPIT), we only want
15351536 // to capture the lifetimes that appear in the bounds. So visit the bounds to find out
15361537 // exactly which ones those are.
1537- let lifetimes_to_remap = if origin == hir:: OpaqueTyOrigin :: TyAlias {
1538- // in a TAIT like `type Foo<'a> = impl Foo<'a>`, we don't keep all the lifetime parameters
1539- Vec :: new ( )
1540- } else {
1541- // in fn return position, like the `fn test<'a>() -> impl Debug + 'a` example,
1542- // we only keep the lifetimes that appear in the `impl Debug` itself:
1543- lifetime_collector:: lifetimes_in_bounds ( & self . resolver , bounds)
1538+ let lifetimes_to_remap = match origin {
1539+ hir:: OpaqueTyOrigin :: TyAlias { .. } => {
1540+ // in a TAIT like `type Foo<'a> = impl Foo<'a>`, we don't keep all the lifetime parameters
1541+ Vec :: new ( )
1542+ }
1543+ hir:: OpaqueTyOrigin :: AsyncFn ( ..) | hir:: OpaqueTyOrigin :: FnReturn ( ..) => {
1544+ // in fn return position, like the `fn test<'a>() -> impl Debug + 'a` example,
1545+ // we only keep the lifetimes that appear in the `impl Debug` itself:
1546+ lifetime_collector:: lifetimes_in_bounds ( & self . resolver , bounds)
1547+ }
15441548 } ;
15451549 debug ! ( ?lifetimes_to_remap) ;
15461550
0 commit comments