Skip to content

Don't recover &raw EXPR as a missing comma#157079

Open
qaijuang wants to merge 2 commits into
rust-lang:mainfrom
qaijuang:raw-expr-list-recovery
Open

Don't recover &raw EXPR as a missing comma#157079
qaijuang wants to merge 2 commits into
rust-lang:mainfrom
qaijuang:raw-expr-list-recovery

Conversation

@qaijuang
Copy link
Copy Markdown
Contributor

@qaijuang qaijuang commented May 28, 2026

The parser already has a targeted suggestion for &raw EXPR, added in #139392, telling the user that &raw must be followed by const or mut.

In comma-separated expression lists, the generic missing-comma recovery would then treat the expression after raw as the next list element. That produced follow-up diagnostics like:

  • help: missing ','
  • cannot find value raw in this scope
  • an arity error for calls such as takes_raw_ptr(&raw x)

This PR avoids that comma recovery when we are already in the &raw missing-const/mut diagnostic path. For function calls, it preserves the call expression with a single error argument, so useful later diagnostics such as cannot find function f are still emitted.

Fixes #157015.

@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 May 28, 2026
@qaijuang qaijuang marked this pull request as ready for review May 28, 2026 22:37
@rustbot
Copy link
Copy Markdown
Collaborator

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

rustbot commented May 28, 2026

r? @jieyouxu

rustbot has assigned @jieyouxu.
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
  • compiler expanded to 73 candidates
  • Random selection from 19 candidates

@jieyouxu
Copy link
Copy Markdown
Member

(Focusing on debuginfo/compiletest/rustfmt reviews this weekend)
@rustbot reroll

@rustbot rustbot assigned Kivooeo and unassigned jieyouxu May 29, 2026
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.

&raw $expr in a list should not recover to &raw, $expr

4 participants