Skip to content

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

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
raushan728:issues/162656
Oct 14, 2026
Merged

rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
raushan728:issues/162656

Conversation

@raushan728

@raushan728 raushan728 commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

View all comments

Fixes #162656.

Struct<'a> { .. } and f<'_>() were parsed as a < comparison whose RHS is a label, producing a cascade of unrelated errors. parse_path_segment now accepts < followed by a lifetime and >/, in expression paths, emits one "use ::<...>" suggestion, and parses the args normally.Since the recovery is inside the path parser, path.span and chained forms (::new(), .method(), ?) work without AST fix-ups or new Parser state; it is guarded by may_recover().

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.

@rust-log-analyzer

This comment has been minimized.

@raushan728 raushan728 closed this Oct 9, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 9, 2026
@raushan728 raushan728 reopened this Oct 9, 2026
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 9, 2026

@nnethercote nnethercote 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.

This is looking much better! A couple of remaining nits.

View changes since this review

Comment thread compiler/rustc_parse/src/diagnostics.rs Outdated
Comment thread compiler/rustc_parse/src/parser/diagnostics.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 Oct 12, 2026
@rustbot

rustbot commented Oct 13, 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.

@nnethercote

Copy link
Copy Markdown
Contributor

Thanks for your patience on this one. I think the final version ended up much better than the first version :)

@bors r+

@rust-bors

rust-bors Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

📌 Commit ebca075 has been approved by nnethercote

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 13, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Oct 14, 2026
…rcote

Recover missing `turbofish` for `lifetime` arguments in expression position

Fixes rust-lang#162656.

`Struct<'a> { .. }` and `f<'_>()` were parsed as a `<` comparison whose RHS is a label, producing a cascade of unrelated errors. `parse_path_segment` now accepts `<` followed by a lifetime and `>`/`,` in expression paths, emits one "use `::<...>`" suggestion, and parses the args normally.Since the recovery is inside the path parser, `path.span` and chained forms (`::new()`, `.method()`, `?`) work without AST fix-ups or new `Parser` state; it is guarded by `may_recover()`.

cc @estebank
rust-bors Bot pushed a commit that referenced this pull request Oct 14, 2026
Rollup of 9 pull requests

Successful merges:

 - #162749 (Recover missing `turbofish` for `lifetime` arguments in expression position)
 - #164170 (Prefer WriteConsoleW for stdout on Windows)
 - #164255 (test DSL eagerly handle false constraints)
 - #163230 (Document zero-sized allocations properly for `Box` and `Vec`)
 - #163940 (Parse move exprs as a bottom expr instead of a prefix expr)
 - #164219 (Windows FileExt trait doesn't need to handle ErrorKind::Interrupted; test improvements for same)
 - #164220 (Test the interaction between `--remap-path-prefix` and doctests)
 - #164266 (rustdoc: Improvements for `rustc_must_implement_one_of`)
 - #164278 (Output remapped paths in rustdoc JSON with the `documentation` scope)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 14, 2026
…rcote

Recover missing `turbofish` for `lifetime` arguments in expression position

Fixes rust-lang#162656.

`Struct<'a> { .. }` and `f<'_>()` were parsed as a `<` comparison whose RHS is a label, producing a cascade of unrelated errors. `parse_path_segment` now accepts `<` followed by a lifetime and `>`/`,` in expression paths, emits one "use `::<...>`" suggestion, and parses the args normally.Since the recovery is inside the path parser, `path.span` and chained forms (`::new()`, `.method()`, `?`) work without AST fix-ups or new `Parser` state; it is guarded by `may_recover()`.

cc @estebank
rust-bors Bot pushed a commit that referenced this pull request Oct 14, 2026
…uwer

Rollup of 11 pull requests

Successful merges:

 - #162749 (Recover missing `turbofish` for `lifetime` arguments in expression position)
 - #164170 (Prefer WriteConsoleW for stdout on Windows)
 - #164255 (test DSL eagerly handle false constraints)
 - #163230 (Document zero-sized allocations properly for `Box` and `Vec`)
 - #163940 (Parse move exprs as a bottom expr instead of a prefix expr)
 - #164219 (Windows FileExt trait doesn't need to handle ErrorKind::Interrupted; test improvements for same)
 - #164220 (Test the interaction between `--remap-path-prefix` and doctests)
 - #164266 (rustdoc: Improvements for `rustc_must_implement_one_of`)
 - #164272 (Add regression test for #155977)
 - #164287 (Add regression test for hang in overlap check with GAT alias)
 - #164301 (fix issue number for feature(unsized_const_params))
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 14, 2026
…rcote

Recover missing `turbofish` for `lifetime` arguments in expression position

Fixes rust-lang#162656.

`Struct<'a> { .. }` and `f<'_>()` were parsed as a `<` comparison whose RHS is a label, producing a cascade of unrelated errors. `parse_path_segment` now accepts `<` followed by a lifetime and `>`/`,` in expression paths, emits one "use `::<...>`" suggestion, and parses the args normally.Since the recovery is inside the path parser, `path.span` and chained forms (`::new()`, `.method()`, `?`) work without AST fix-ups or new `Parser` state; it is guarded by `may_recover()`.

cc @estebank
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 14, 2026
…rcote

Recover missing `turbofish` for `lifetime` arguments in expression position

Fixes rust-lang#162656.

`Struct<'a> { .. }` and `f<'_>()` were parsed as a `<` comparison whose RHS is a label, producing a cascade of unrelated errors. `parse_path_segment` now accepts `<` followed by a lifetime and `>`/`,` in expression paths, emits one "use `::<...>`" suggestion, and parses the args normally.Since the recovery is inside the path parser, `path.span` and chained forms (`::new()`, `.method()`, `?`) work without AST fix-ups or new `Parser` state; it is guarded by `may_recover()`.

cc @estebank
rust-bors Bot pushed a commit that referenced this pull request Oct 14, 2026
…uwer

Rollup of 17 pull requests

Successful merges:

 - #162749 (Recover missing `turbofish` for `lifetime` arguments in expression position)
 - #164165 (Add a new `rustc_show_spans` internal attribute)
 - #164170 (Prefer WriteConsoleW for stdout on Windows)
 - #164208 (Implement better resolution for delegation `Self` mapping field)
 - #164255 (test DSL eagerly handle false constraints)
 - #163230 (Document zero-sized allocations properly for `Box` and `Vec`)
 - #163442 (Fix fudging)
 - #163940 (Parse move exprs as a bottom expr instead of a prefix expr)
 - #164079 (document some quirks around directory symlinks on Windows)
 - #164178 (Fix `diagnostic::on_unknown` format placeholder for paths in expressions and type paths)
 - #164219 (Windows FileExt trait doesn't need to handle ErrorKind::Interrupted; test improvements for same)
 - #164266 (rustdoc: Improvements for `rustc_must_implement_one_of`)
 - #164272 (Add regression test for #155977)
 - #164287 (Add regression test for hang in overlap check with GAT alias)
 - #164292 (Remove the `span_use_eq_ctxt` lint)
 - #164301 (fix issue number for feature(unsized_const_params))
 - #164309 (point at the opaque when its hidden type cannot be inferred)
rust-bors Bot pushed a commit that referenced this pull request Oct 14, 2026
Rollup merge of #162749 - raushan728:issues/162656, r=nnethercote

Recover missing `turbofish` for `lifetime` arguments in expression position

Fixes #162656.

`Struct<'a> { .. }` and `f<'_>()` were parsed as a `<` comparison whose RHS is a label, producing a cascade of unrelated errors. `parse_path_segment` now accepts `<` followed by a lifetime and `>`/`,` in expression paths, emits one "use `::<...>`" suggestion, and parses the args normally.Since the recovery is inside the path parser, `path.span` and chained forms (`::new()`, `.method()`, `?`) work without AST fix-ups or new `Parser` state; it is guarded by `may_recover()`.

cc @estebank
@rust-bors
rust-bors Bot merged commit 0c16e6d into rust-lang:main Oct 14, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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> {}

8 participants