Auto merge of #94088 - oli-obk:revert, r=jackh726
Revert #91403 fixes #94004 r? `@pnkfelix` `@cjgillot`
This commit is contained in:
commit
feac2ecf1c
34 changed files with 281 additions and 227 deletions
|
@ -2409,11 +2409,16 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
let def_id = item_id.def_id.to_def_id();
|
||||
|
||||
match opaque_ty.kind {
|
||||
hir::ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) => {
|
||||
let replace_parent_lifetimes =
|
||||
matches!(origin, hir::OpaqueTyOrigin::FnReturn(..));
|
||||
self.impl_trait_ty_to_ty(def_id, lifetimes, replace_parent_lifetimes)
|
||||
}
|
||||
hir::ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) => self
|
||||
.impl_trait_ty_to_ty(
|
||||
def_id,
|
||||
lifetimes,
|
||||
matches!(
|
||||
origin,
|
||||
hir::OpaqueTyOrigin::FnReturn(..)
|
||||
| hir::OpaqueTyOrigin::AsyncFn(..)
|
||||
),
|
||||
),
|
||||
ref i => bug!("`impl Trait` pointed to non-opaque type?? {:#?}", i),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -545,8 +545,10 @@ pub(super) fn check_opaque_for_inheriting_lifetimes<'tcx>(
|
|||
}
|
||||
}
|
||||
|
||||
if let ItemKind::OpaqueTy(hir::OpaqueTy { origin: hir::OpaqueTyOrigin::FnReturn(..), .. }) =
|
||||
item.kind
|
||||
if let ItemKind::OpaqueTy(hir::OpaqueTy {
|
||||
origin: hir::OpaqueTyOrigin::AsyncFn(..) | hir::OpaqueTyOrigin::FnReturn(..),
|
||||
..
|
||||
}) = item.kind
|
||||
{
|
||||
let mut visitor = ProhibitOpaqueVisitor {
|
||||
opaque_identity_ty: tcx.mk_opaque(
|
||||
|
@ -568,13 +570,20 @@ pub(super) fn check_opaque_for_inheriting_lifetimes<'tcx>(
|
|||
|
||||
if let Some(ty) = prohibit_opaque.break_value() {
|
||||
visitor.visit_item(&item);
|
||||
let is_async = match item.kind {
|
||||
ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) => {
|
||||
matches!(origin, hir::OpaqueTyOrigin::AsyncFn(..))
|
||||
}
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
span,
|
||||
E0760,
|
||||
"`impl Trait` return type cannot contain a projection or `Self` that references lifetimes from \
|
||||
"`{}` return type cannot contain a projection or `Self` that references lifetimes from \
|
||||
a parent scope",
|
||||
if is_async { "async fn" } else { "impl Trait" },
|
||||
);
|
||||
|
||||
for (span, name) in visitor.selftys {
|
||||
|
|
|
@ -2157,7 +2157,8 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
|
|||
generics
|
||||
}
|
||||
ItemKind::OpaqueTy(OpaqueTy {
|
||||
origin: hir::OpaqueTyOrigin::FnReturn(..), ..
|
||||
origin: hir::OpaqueTyOrigin::AsyncFn(..) | hir::OpaqueTyOrigin::FnReturn(..),
|
||||
..
|
||||
}) => {
|
||||
// return-position impl trait
|
||||
//
|
||||
|
@ -2177,7 +2178,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
|
|||
}
|
||||
ItemKind::OpaqueTy(OpaqueTy {
|
||||
ref generics,
|
||||
origin: hir::OpaqueTyOrigin::AsyncFn(..) | hir::OpaqueTyOrigin::TyAlias,
|
||||
origin: hir::OpaqueTyOrigin::TyAlias,
|
||||
..
|
||||
}) => {
|
||||
// type-alias impl trait
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue