Skip to content

Render the box pattern removal diagnostic more actionable & fully remove box expression recovery - #162008

Open
fmease wants to merge 2 commits into
rust-lang:mainfrom
fmease:actionable-box-pat-diag
Open

Render the box pattern removal diagnostic more actionable & fully remove box expression recovery#162008
fmease wants to merge 2 commits into
rust-lang:mainfrom
fmease:actionable-box-pat-diag

Conversation

@fmease

@fmease fmease commented Aug 30, 2026

Copy link
Copy Markdown
Member

Follow-up to #156749. This way, users don't have to comb through (probably outdated) tracking issues trying to piece together how to fix their code (in the most idiomatic way). Lemme know if you think this is unnecessary.

Re. box expression removal, see #162008 (comment) (TL;DR: it's been 3 years).

cc @cyrgani

(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 Aug 30, 2026
@rustbot

rustbot commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

r? @fee1-dead

rustbot has assigned @fee1-dead.
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

@cyrgani

cyrgani commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Maybe it's also time to just remove the suggestion for box_syntax? The removal PR (#108471) was merged in 1.70, three years ago, so everyone should have had plenty of time to move away from it.

@fmease fmease changed the title Render the box pattern removal diagnostic more actionable Render the box pattern removal diagnostic more actionable & fully remove box expression recovery Aug 30, 2026
|| [
kw::Async,
kw::Do,
kw::Box,

@fmease fmease Aug 30, 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.

Modifying can_begin* usually affects stable(!) macro rules matching behavior. In this case, it leads to code like the following to go from fail to pass:

macro_rules! mk {
    ($e:expr) => { compile_error!("expr"); };
    (box $e:expr) => {};
}

mk!(box 0);

Strictly speaking that's a new guarantee (in the sense that re-adding box exprs would be breaking). It's unclear if lang FCP #108471 (comment) covers this. If you don't want to involve T-lang at this time, we could also keep kw::Box in can_begin_expr for now and add a FIXME to revisit it in the future.

View changes since the review

@fee1-dead fee1-dead Aug 30, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would prefer us to split this out of the suggestion / expression recovery remove, and nominate lang for it, this PR should just add a FIXME.

However, let's document that changing this function can change stable macro rules behavior too.

@rust-log-analyzer

This comment has been minimized.

@fmease
fmease force-pushed the actionable-box-pat-diag branch from 6933264 to e292f3c Compare August 30, 2026 13:29

@fee1-dead fee1-dead left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

|| [
kw::Async,
kw::Do,
kw::Box,

@fee1-dead fee1-dead Aug 30, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would prefer us to split this out of the suggestion / expression recovery remove, and nominate lang for it, this PR should just add a FIXME.

However, let's document that changing this function can change stable macro rules behavior too.

@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 Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants