rust-lang / rust-lang/rust

Detect missing turbofish in paths in expression context when written with lifetimes `Struct<'a> {}`

Open
#162,656 1 comment 0 reactions 1 assignee View on GitHub

@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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.