Skip to content

Better error message when bare type in impl parameter list#157466

Open
bb1yd wants to merge 1 commit into
rust-lang:mainfrom
bb1yd:issue-147889
Open

Better error message when bare type in impl parameter list#157466
bb1yd wants to merge 1 commit into
rust-lang:mainfrom
bb1yd:issue-147889

Conversation

@bb1yd

@bb1yd bb1yd commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #147889

Marking this PR ready for feedback on this problem.

The approach I'm trying is to create a snapshot parser and attempt to re-parse the input in another way. If it succeeds, we successfully predicted the user's intention and emit the related help message. If it fails, we cancel the errors produced during the attempt and report the original error.

The problem is that parse functions may internally recover from parse failures and emit errors directly, which means we can't cancel them later. I saw that we have a recovery field to control the recovery mechanism, but it seems there are (maybe) a lot of places in the parser that don't check the recovery field before doing their recovery logic.

Should we always use look_ahead instead of using a snapshot parser and calling another parse function?

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 5, 2026
@bb1yd bb1yd marked this pull request as ready for review June 8, 2026 12:54
@rustbot

rustbot commented Jun 8, 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. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 8, 2026
@rustbot

rustbot commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

r? @adwinwhite

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

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.

Bare type in impl parameter list causes non-intuitive parse error

3 participants