Skip to content

When trying to recover from for<…> dyn … don't unconditionally treat dyn as a keyword - #162340

Open
fmease wants to merge 1 commit into
rust-lang:mainfrom
fmease:fix-for-dyn-recovery
Open

When trying to recover from for<…> dyn … don't unconditionally treat dyn as a keyword#162340
fmease wants to merge 1 commit into
rust-lang:mainfrom
fmease:fix-for-dyn-recovery

Conversation

@fmease

@fmease fmease commented Sep 5, 2026

Copy link
Copy Markdown
Member

dyn is only a keyword in Rust 2015 if it's followed by a token in the following set: {PathIdentSegment, LIFETIME_TOKEN, for, (, ?}. However, the for<…> dyn …dyn for<…> … recovery code treated it as a keyword unconditionally meaning we were incorrectly rejecting Rust 2015 code like trait dyn {} type X = for<> dyn;

This is very similar to issue #157565.

(No LLM was or will be used by me during the entire creation process of this PR)

@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 5, 2026
@rustbot

rustbot commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator

r? @davidtwco

rustbot has assigned @davidtwco.
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 75 candidates
  • Random selection from 20 candidates

@fmease
fmease force-pushed the fix-for-dyn-recovery branch from 27ed5e7 to b6361ec Compare September 5, 2026 17:21
@rust-log-analyzer

This comment has been minimized.

@fmease
fmease force-pushed the fix-for-dyn-recovery branch from b6361ec to a210e58 Compare September 5, 2026 18:33
//~^ ERROR `for<...>` expected after `impl`, not before

// Issue #118564
type A2 = dyn<for<> dyn>;

@fmease fmease Sep 5, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

nightly-2023-12-03 also ICEs for the much smaller type X = for<> dyn; which incidentally is the code I added to dyn-2015-identifier.rs. Hence the other test now kills two birds with one stone allowing me to remove this regression test case.

View changes since the review

@fmease
fmease force-pushed the fix-for-dyn-recovery branch from a210e58 to 0d1e323 Compare September 6, 2026 09:23
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.

4 participants