Verify predicates on RPIT and async opaques.

This commit is contained in:
Camille GILLOT 2022-11-11 18:07:03 +00:00
parent da9dca7040
commit 49a5aa4f0c

View File

@ -106,26 +106,6 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
is_trait = Some(ty::TraitRef::identity(tcx, def_id));
*generics
}
ItemKind::OpaqueTy(OpaqueTy {
origin: hir::OpaqueTyOrigin::AsyncFn(..) | hir::OpaqueTyOrigin::FnReturn(..),
..
}) => {
// return-position impl trait
//
// We don't inherit predicates from the parent here:
// If we have, say `fn f<'a, T: 'a>() -> impl Sized {}`
// then the return type is `f::<'static, T>::{{opaque}}`.
//
// If we inherited the predicates of `f` then we would
// require that `T: 'static` to show that the return
// type is well-formed.
//
// The only way to have something with this opaque type
// is from the return type of the containing function,
// which will ensure that the function's predicates
// hold.
return ty::GenericPredicates { parent: None, predicates: &[] };
}
ItemKind::OpaqueTy(OpaqueTy {
ref generics,
origin: hir::OpaqueTyOrigin::TyAlias,