add ui test for issue-69276

This commit is contained in:
csmoe 2020-05-11 14:24:57 +08:00
parent aeb473803d
commit 29a41f0d86
3 changed files with 25 additions and 1 deletions

View file

@ -1659,6 +1659,7 @@ fn check_opaque_for_inheriting_lifetimes(tcx: TyCtxt<'tcx>, def_id: LocalDefId,
let prohibit_opaque = match item.kind {
ItemKind::OpaqueTy(hir::OpaqueTy {
bounds,
origin: hir::OpaqueTyOrigin::AsyncFn | hir::OpaqueTyOrigin::FnReturn,
..
}) => {
@ -1671,6 +1672,9 @@ fn check_opaque_for_inheriting_lifetimes(tcx: TyCtxt<'tcx>, def_id: LocalDefId,
};
debug!("check_opaque_for_inheriting_lifetimes: visitor={:?}", visitor);
for bound in bounds {
debug!("check_opaque_for_inheriting_lifetimes: {:?}", bound.trait_ref());
}
tcx.predicates_of(def_id)
.predicates
.iter()
@ -1695,7 +1699,7 @@ fn check_opaque_for_inheriting_lifetimes(tcx: TyCtxt<'tcx>, def_id: LocalDefId,
"`{}` return type cannot contain a projection or `Self` that references lifetimes from \
a parent scope",
if is_async { "async fn" } else { "impl Trait" },
),
)
);
}
}

View file

@ -0,0 +1,12 @@
// edition:2018
struct S<'a>(&'a i32);
impl<'a> S<'a> {
async fn new(i: &'a i32) -> Self {
//~^ ERROR `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope
S(&22)
}
}
fn main() {}

View file

@ -0,0 +1,8 @@
error: `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope
--> $DIR/issue-69276.rs:6:33
|
LL | async fn new(i: &'a i32) -> Self {
| ^^^^
error: aborting due to previous error