@@ -247,7 +247,7 @@ enum ImplTraitContext {
247
247
in_trait : bool ,
248
248
} ,
249
249
/// Impl trait in type aliases.
250
- TypeAliasesOpaqueTy ,
250
+ TypeAliasesOpaqueTy { in_assoc_ty : bool } ,
251
251
/// `impl Trait` is unstably accepted in this position.
252
252
FeatureGated ( ImplTraitPosition , Symbol ) ,
253
253
/// `impl Trait` is not accepted in this position.
@@ -1407,14 +1407,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1407
1407
* in_trait,
1408
1408
itctx,
1409
1409
) ,
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
+ ) ,
1418
1419
ImplTraitContext :: Universal => {
1419
1420
let span = t. span ;
1420
1421
self . create_def (
@@ -1534,13 +1535,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1534
1535
// If this came from a TAIT (as opposed to a function that returns an RPIT), we only want
1535
1536
// to capture the lifetimes that appear in the bounds. So visit the bounds to find out
1536
1537
// 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
+ }
1544
1548
} ;
1545
1549
debug ! ( ?lifetimes_to_remap) ;
1546
1550
0 commit comments