Skip to content

Commit 29a41f0

Browse files
committed
add ui test for issue-69276
1 parent aeb4738 commit 29a41f0

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

src/librustc_typeck/check/mod.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1659,6 +1659,7 @@ fn check_opaque_for_inheriting_lifetimes(tcx: TyCtxt<'tcx>, def_id: LocalDefId,
16591659

16601660
let prohibit_opaque = match item.kind {
16611661
ItemKind::OpaqueTy(hir::OpaqueTy {
1662+
bounds,
16621663
origin: hir::OpaqueTyOrigin::AsyncFn | hir::OpaqueTyOrigin::FnReturn,
16631664
..
16641665
}) => {
@@ -1671,6 +1672,9 @@ fn check_opaque_for_inheriting_lifetimes(tcx: TyCtxt<'tcx>, def_id: LocalDefId,
16711672
};
16721673
debug!("check_opaque_for_inheriting_lifetimes: visitor={:?}", visitor);
16731674

1675+
for bound in bounds {
1676+
debug!("check_opaque_for_inheriting_lifetimes: {:?}", bound.trait_ref());
1677+
}
16741678
tcx.predicates_of(def_id)
16751679
.predicates
16761680
.iter()
@@ -1695,7 +1699,7 @@ fn check_opaque_for_inheriting_lifetimes(tcx: TyCtxt<'tcx>, def_id: LocalDefId,
16951699
"`{}` return type cannot contain a projection or `Self` that references lifetimes from \
16961700
a parent scope",
16971701
if is_async { "async fn" } else { "impl Trait" },
1698-
),
1702+
)
16991703
);
17001704
}
17011705
}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// edition:2018
2+
3+
struct S<'a>(&'a i32);
4+
5+
impl<'a> S<'a> {
6+
async fn new(i: &'a i32) -> Self {
7+
//~^ ERROR `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope
8+
S(&22)
9+
}
10+
}
11+
12+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope
2+
--> $DIR/issue-69276.rs:6:33
3+
|
4+
LL | async fn new(i: &'a i32) -> Self {
5+
| ^^^^
6+
7+
error: aborting due to previous error
8+

0 commit comments

Comments
 (0)