Reproduce sad diagnostic

This commit is contained in:
Oli Scherer 2022-09-01 15:41:13 +00:00
parent 36cb01deb3
commit 4b323e62ba
2 changed files with 35 additions and 0 deletions

View file

@ -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() {}

View file

@ -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`.