about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/test/ui/impl-trait/unactionable_diagnostic.rs23
-rw-r--r--src/test/ui/impl-trait/unactionable_diagnostic.stderr12
2 files changed, 35 insertions, 0 deletions
diff --git a/src/test/ui/impl-trait/unactionable_diagnostic.rs b/src/test/ui/impl-trait/unactionable_diagnostic.rs
new file mode 100644
index 00000000000..de482e0370c
--- /dev/null
+++ b/src/test/ui/impl-trait/unactionable_diagnostic.rs
@@ -0,0 +1,23 @@
+trait Trait {}
+
+struct Foo;
+
+impl Trait for Foo {}
+
+fn foo<'t, P>(
+    post: P,
+    x: &'t Foo,
+) -> &'t impl Trait {
+    x
+}
+
+fn bar<'t, T>(
+    post: T,
+    x: &'t Foo,
+) -> &'t impl Trait {
+    foo(post, x)
+    //~^ ERROR: the opaque type `foo<T>::{opaque#0}` may not live long enough
+    //~| HELP: consider adding an explicit lifetime bound `foo<T>::{opaque#0}: 't`
+}
+
+fn main() {}
diff --git a/src/test/ui/impl-trait/unactionable_diagnostic.stderr b/src/test/ui/impl-trait/unactionable_diagnostic.stderr
new file mode 100644
index 00000000000..fe6fef5815d
--- /dev/null
+++ b/src/test/ui/impl-trait/unactionable_diagnostic.stderr
@@ -0,0 +1,12 @@
+error[E0309]: the opaque type `foo<T>::{opaque#0}` may not live long enough
+  --> $DIR/unactionable_diagnostic.rs:18:5
+   |
+LL |     foo(post, x)
+   |     ^^^^^^^^^^^^
+   |
+   = help: consider adding an explicit lifetime bound `foo<T>::{opaque#0}: 't`...
+   = note: ...so that the type `impl Trait` will meet its required lifetime bounds
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0309`.