Skip to content

Recover missing turbofish for lifetime arguments in expression position - #162749

Open
raushan728 wants to merge 2 commits into
rust-lang:mainfrom
raushan728:issues/162656
Open

raushan728 wants to merge 2 commits into
rust-lang:mainfrom
raushan728:issues/162656

Conversation

@raushan728

@raushan728 raushan728 commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #162656.

rustc already suggests ::<> when a type/const generic argument is missing its turbofish (foo<Bar>()), but not for lifetime arguments - Struct<'a> { .. } previously misfired through label/char-literal recovery, producing a confusing cascade of unrelated errors instead of one actionable turbofish suggestion.

cc @estebank

@rustbot

rustbot commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

The parser was modified, potentially altering the grammar of (stable) Rust
which would be a breaking change.

cc @fmease

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 14, 2026
@rustbot

rustbot commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

r? @chenyukang

rustbot has assigned @chenyukang.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler, parser
  • compiler, parser expanded to 76 candidates
  • Random selection from 18 candidates

@estebank estebank left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to do a more in-depth review, as I have some mild concerns about increasing the size of the parser, but the results look reasonable so far. I'll look at this again later this week if the assigned reviewer doesn't manage to get the time before then.

View changes since this review

Comment thread compiler/rustc_parse/src/parser/expr.rs Outdated
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 14, 2026
@rustbot

rustbot commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot

This comment has been minimized.

Comment thread compiler/rustc_parse/src/parser/expr.rs Outdated
@raushan728
raushan728 requested a review from estebank September 15, 2026 14:36
@raushan728

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 15, 2026
@rust-bors

This comment has been minimized.

@rustbot

This comment has been minimized.

@rust-bors

This comment has been minimized.

@chenyukang

Copy link
Copy Markdown
Member

r? @estebank since you already take review :)

@rustbot rustbot assigned estebank and unassigned chenyukang Sep 19, 2026
@raushan728 raushan728 changed the title Recover missing turbofish for lifetime arguments in expression position Recover missing turbofish for lifetime arguments in expression position Sep 20, 2026
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@raushan728
raushan728 marked this pull request as draft October 2, 2026 16:01
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 2, 2026

@raushan728 raushan728 left a comment •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funny story this idea actually came to me while I was half asleep last night 😄. Your comment about parser size kept nagging at me and it hit me that we didn't need to touch eat_label/parse_expr_labeled or add any new parser fields at all we could intercept the missing turbofish with a simple lookahead right where < is already being parsed as a binary operator before it ever falls into label parsing.

@estebank should be a much smaller ask for review now

@raushan728
raushan728 marked this pull request as ready for review October 3, 2026 05:00
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 3, 2026
@rustbot

rustbot commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

4 participants