Skip to content

Commit 4b323e6

Browse files
committed
Reproduce sad diagnostic
1 parent 36cb01d commit 4b323e6

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
trait Trait {}
2+
3+
struct Foo;
4+
5+
impl Trait for Foo {}
6+
7+
fn foo<'t, P>(
8+
post: P,
9+
x: &'t Foo,
10+
) -> &'t impl Trait {
11+
x
12+
}
13+
14+
fn bar<'t, T>(
15+
post: T,
16+
x: &'t Foo,
17+
) -> &'t impl Trait {
18+
foo(post, x)
19+
//~^ ERROR: the opaque type `foo<T>::{opaque#0}` may not live long enough
20+
//~| HELP: consider adding an explicit lifetime bound `foo<T>::{opaque#0}: 't`
21+
}
22+
23+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0309]: the opaque type `foo<T>::{opaque#0}` may not live long enough
2+
--> $DIR/unactionable_diagnostic.rs:18:5
3+
|
4+
LL | foo(post, x)
5+
| ^^^^^^^^^^^^
6+
|
7+
= help: consider adding an explicit lifetime bound `foo<T>::{opaque#0}: 't`...
8+
= note: ...so that the type `impl Trait` will meet its required lifetime bounds
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0309`.

0 commit comments

Comments
 (0)