about summary refs log tree commit diff
path: root/tests/ui/impl-trait
diff options
context:
space:
mode:
authorbohan <bohan-zhang@foxmail.com>2023-11-04 17:00:33 +0800
committerbohan <bohan-zhang@foxmail.com>2023-11-04 22:15:22 +0800
commita4768fea3545a799b9c19e65777f6fee7b50a561 (patch)
treef41dcba0abcb8cd6704a9d11854e6701238348cd /tests/ui/impl-trait
parent2db26d3d55387930f1b1dfb84810bcde5a787a09 (diff)
downloadrust-a4768fea3545a799b9c19e65777f6fee7b50a561.tar.gz
rust-a4768fea3545a799b9c19e65777f6fee7b50a561.zip
fallback for `construct_generic_bound_failure`
Diffstat (limited to 'tests/ui/impl-trait')
-rw-r--r--tests/ui/impl-trait/in-trait/async-and-ret-ref.rs11
-rw-r--r--tests/ui/impl-trait/in-trait/async-and-ret-ref.stderr14
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/ui/impl-trait/in-trait/async-and-ret-ref.rs b/tests/ui/impl-trait/in-trait/async-and-ret-ref.rs
new file mode 100644
index 00000000000..af6ffe83394
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/async-and-ret-ref.rs
@@ -0,0 +1,11 @@
+// edition:2021
+// https://github.com/rust-lang/rust/issues/117547
+
+trait T {}
+
+trait MyTrait {
+    async fn foo() -> &'static impl T;
+    //~^ ERROR the associated type `<Self as MyTrait>::{opaque#0}` may not live long enough
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/async-and-ret-ref.stderr b/tests/ui/impl-trait/in-trait/async-and-ret-ref.stderr
new file mode 100644
index 00000000000..7c9028a8cd5
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/async-and-ret-ref.stderr
@@ -0,0 +1,14 @@
+error[E0310]: the associated type `<Self as MyTrait>::{opaque#0}` may not live long enough
+  --> $DIR/async-and-ret-ref.rs:7:5
+   |
+LL |     async fn foo() -> &'static impl T;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |     |
+   |     the associated type `<Self as MyTrait>::{opaque#0}` must be valid for the static lifetime...
+   |     ...so that the reference type `&'static impl T` does not outlive the data it points at
+   |
+   = help: consider adding an explicit lifetime bound `<Self as MyTrait>::{opaque#0}: 'static`...
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0310`.