diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-09-01 15:41:13 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-09-21 13:15:24 +0000 |
| commit | 4b323e62ba785812fbb5d6b77f2564a59dce2171 (patch) | |
| tree | e36fb85d2d2c2e058808c400751e935230282aa6 /src/test | |
| parent | 36cb01deb3d874650881b0bc22448020751ff19c (diff) | |
| download | rust-4b323e62ba785812fbb5d6b77f2564a59dce2171.tar.gz rust-4b323e62ba785812fbb5d6b77f2564a59dce2171.zip | |
Reproduce sad diagnostic
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/impl-trait/unactionable_diagnostic.rs | 23 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/unactionable_diagnostic.stderr | 12 |
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`. |
