@@ -2158,7 +2158,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
2158
2158
}
2159
2159
ItemKind :: OpaqueTy ( OpaqueTy {
2160
2160
ref generics,
2161
- origin : hir:: OpaqueTyOrigin :: AsyncFn ( .. ) | hir :: OpaqueTyOrigin :: FnReturn ( ..) ,
2161
+ origin : hir:: OpaqueTyOrigin :: FnReturn ( ..) ,
2162
2162
..
2163
2163
} ) => {
2164
2164
// return-position impl trait
@@ -2181,6 +2181,25 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
2181
2181
2182
2182
generics
2183
2183
}
2184
+ ItemKind :: OpaqueTy ( OpaqueTy {
2185
+ origin : hir:: OpaqueTyOrigin :: AsyncFn ( ..) , ..
2186
+ } ) => {
2187
+ // return-position impl trait
2188
+ //
2189
+ // We don't inherit predicates from the parent here:
2190
+ // If we have, say `fn f<'a, T: 'a>() -> impl Sized {}`
2191
+ // then the return type is `f::<'static, T>::{{opaque}}`.
2192
+ //
2193
+ // If we inherited the predicates of `f` then we would
2194
+ // require that `T: 'static` to show that the return
2195
+ // type is well-formed.
2196
+ //
2197
+ // The only way to have something with this opaque type
2198
+ // is from the return type of the containing function,
2199
+ // which will ensure that the function's predicates
2200
+ // hold.
2201
+ return ty:: GenericPredicates { parent : None , predicates : & [ ] } ;
2202
+ }
2184
2203
ItemKind :: OpaqueTy ( OpaqueTy {
2185
2204
ref generics,
2186
2205
origin : hir:: OpaqueTyOrigin :: TyAlias ,
0 commit comments