Detect missing turbofish in paths in expression context when written with lifetimes `Struct<'a> {}`
Open
@raushan728 is already working on this.
Since Sep 12, 2026.
A-diagnostics
A-parser
D-verbose
P-low
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=0567b7dfb68532fc6d58e39411dd491d
Struct<'_> {
string: "",
};
Current output
error: labels cannot use keyword names
--> src/main.rs:6:20
|
6 | let _ = Struct<'_> {
| ^^
error: expected `while`, `for`, `loop` or `{` after a label
--> src/main.rs:6:22
|
6 | let _ = Struct<'_> {
| ^ expected `while`, `for`, `loop` or `{` after a label
|
help: add `'` to close the char literal
|
6 | let _ = Struct<'_'> {
| +
error: comparison operators cannot be chained
--> src/main.rs:6:19
|
6 | let _ = Struct<'_> {
| ^ ^
Desired output
error: labels cannot use keyword names
--> src/main.rs:6:20
|
6 | let _ = Struct<'_> {
| ^^
help: if you meant to specify lifetime parameters for `Struct`, use the `::<>` turbofish
|
6 | let _ = Struct::<'_> {
| ++
Rationale and extra context
We already account for other missing turbofish cases, but we don't account for lifetimes
Other cases
Struct<'a> { ... }
Rust Version
1.98.1
Anything else?
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.