Skip to content

Fix parser error recovery treating 'dyn' as a strict keyword in Rust …#157577

Open
Willi0728 wants to merge 1 commit into
rust-lang:mainfrom
Willi0728:fix-dyn-2015-parser
Open

Fix parser error recovery treating 'dyn' as a strict keyword in Rust …#157577
Willi0728 wants to merge 1 commit into
rust-lang:mainfrom
Willi0728:fix-dyn-2015-parser

Conversation

@Willi0728
Copy link
Copy Markdown

@Willi0728 Willi0728 commented Jun 7, 2026

…2015 when used in dyn + dyn

Fixes: #157565

Description

A diagnostics improvement #84896 in 2015 edition caused errors when dyn + dyn was used, even though dyn is a contextual keyword in the 2015 edition.

Solution

A check was added in rustc_parse/src/parser/ty.rs:1095:

            if self.token.is_keyword(kw::Dyn) && self.token.span.edition().at_least_rust_2018() {

This checks that the version is not 2015 before throwing an error.
A regression test was also added, in tests/ui/parser/dyn-2015-identifier.rs

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jun 7, 2026

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 Jun 7, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jun 7, 2026

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nnethercote (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 20 candidates

@Willi0728
Copy link
Copy Markdown
Author

@rustbot label +relnotes

@rustbot rustbot added the relnotes Marks issues that should be documented in the release notes of the next release. label Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

relnotes Marks issues that should be documented in the release notes of the next release. 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.

Rust 2015 type dyn + dyn wrongly rejected by the parser due to "helpful" diagnostic

3 participants