Closed
Description
Given the following code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=d55c130a01f69dede262830dd4771bdf
fn no_restriction<T>(x: &()) -> &() {
with_restriction::<T>(x)
}
fn with_restriction<'b, T: 'b>(x: &'b ()) -> &'b () {
x
}
The current output is:
error[E0311]: the parameter type `T` may not live long enough
--> src/lib.rs:2:5
|
2 | with_restriction::<T>(x)
| ^^^^^^^^^^^^^^^^^^^^^
|
note: the parameter type `T` must be valid for the anonymous lifetime defined here...
--> src/lib.rs:1:25
|
1 | fn no_restriction<T>(x: &()) -> &() {
| ^^^
note: ...so that the type `T` will meet its required lifetime bounds
--> src/lib.rs:2:5
|
2 | with_restriction::<T>(x)
| ^^^^^^^^^^^^^^^^^^^^^
help: consider adding an explicit lifetime bound...
|
1 | fn no_restriction<T: 'a>(x: &()) -> &() {
| ++++
'a
does not exist, maybe it should get introduced by the diagnostic