Closed
Description
Currently (tested on stable and nightly) if you try to compile this code
fn f<'a>() {}
fn main() { let _ = f::<'static>; }
you get this error message:
error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
--> src/main.rs:4:17
|
4 | let _ = f::<'static>;
| ^^^^^^^
|
note: the late bound lifetime parameter is introduced here
--> src/main.rs:1:6
|
1 | fn f<'a>() {}
| ^^
There is no error number (like E0208) to pass to rustc --explain
. There's also no mention that you can fix this error without changing the meaning of the code at all by putting a vacuous where
clause in the signature of f
, like this:
fn f<'a>() where 'a: 'a {}
See #42868 for background. (I'm not sure when that compatibility lint became a hard error; it seems to have happened without that tracking issue being updated. Maybe that has something to do with why the error has no number or help
.)
I think:
- this error should have a number and accompanying
rustc --explain
text that discusses the early- vs. late-bound lifetime distinction and why specifying late-bound lifetime parameters explicitly is not allowed - it should also have a
help
line that suggests addingwhere 'a: 'a
Here is the URLO thread that prompted this issue:
https://users.rust-lang.org/t/what-is-the-meaning-of-a-a-in-rust-lifetime-parameters/53570
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Explanation of an error code (--explain)Area: Lifetimes / regionsCategory: An issue proposing an enhancement or a PR with one.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Relevant to the compiler team, which will review and decide on the PR/issue.