about summary refs log tree commit diff
diff options
context:
space:
mode:
authorcsmoe <csmoe@msn.com>2020-05-11 14:24:57 +0800
committercsmoe <csmoe@msn.com>2020-05-12 20:57:44 +0800
commit29a41f0d86b82c2731cc2ab8c8a26272e773e4c3 (patch)
treef8d806034d13ceadebc91c414455db56b4c8cd04
parentaeb473803d1ead96fab51224ba3e366f44883423 (diff)
downloadrust-29a41f0d86b82c2731cc2ab8c8a26272e773e4c3.tar.gz
rust-29a41f0d86b82c2731cc2ab8c8a26272e773e4c3.zip
add ui test for issue-69276
-rw-r--r--src/librustc_typeck/check/mod.rs6
-rw-r--r--src/test/ui/async-await/issue-69276.rs12
-rw-r--r--src/test/ui/async-await/issue-69276.stderr8
3 files changed, 25 insertions, 1 deletions
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index 956e09ec52b..57fdb03250e 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -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" },
-        ),
+        )
         );
     }
 }
diff --git a/src/test/ui/async-await/issue-69276.rs b/src/test/ui/async-await/issue-69276.rs
new file mode 100644
index 00000000000..224b76e2d90
--- /dev/null
+++ b/src/test/ui/async-await/issue-69276.rs
@@ -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() {}
diff --git a/src/test/ui/async-await/issue-69276.stderr b/src/test/ui/async-await/issue-69276.stderr
new file mode 100644
index 00000000000..1ebfdfa8b54
--- /dev/null
+++ b/src/test/ui/async-await/issue-69276.stderr
@@ -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
+