Skip to content

Suggest : when ; is used before a macro_rules! fragment specifier#153843

Open
ozankenangungor wants to merge 3 commits intorust-lang:mainfrom
ozankenangungor:fix-macro-rules-colon-semicolon
Open

Suggest : when ; is used before a macro_rules! fragment specifier#153843
ozankenangungor wants to merge 3 commits intorust-lang:mainfrom
ozankenangungor:fix-macro-rules-colon-semicolon

Conversation

@ozankenangungor
Copy link
Copy Markdown
Contributor

@ozankenangungor ozankenangungor commented Mar 14, 2026

Closes #153320

Add a suggestion for the case where ; is written instead of : before a valid macro_rules! fragment specifier.

For that semicolon typo case, this also removes the generic “try adding a specifier here” help and keeps the parsed fragment kind during recovery, so $x;ty recovers as $x:ty.

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

rustbot commented Mar 14, 2026

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
  • compiler expanded to 69 candidates
  • Random selection from 15 candidates

@rust-log-analyzer

This comment has been minimized.

@adwinwhite
Copy link
Copy Markdown
Contributor

adwinwhite commented Mar 17, 2026

Could you update the PR description to reflect the latest changes?

@ozankenangungor
Copy link
Copy Markdown
Contributor Author

Updated the PR description to reflect the latest changes.

@adwinwhite adwinwhite 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 Mar 19, 2026
Copy link
Copy Markdown
Contributor

@adwinwhite adwinwhite left a comment

Choose a reason for hiding this comment

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

Sorry, I forgot to submit the inline reviews.

View changes since this review

&& let Some((fragment, _)) = frag_token.ident()
{
let span = frag_token.span.with_lo(start_sp.lo());
let edition = || {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you move this closure upwards and reuse it for both branches?

LL | ($x;ty) => {};
| ^^
|
= note: fragment specifiers must be provided
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Give that we already check that a valid fragment specifier is provided, do you think it's better to use a separate independent diagnostics than MissingFragmentSpecifier?
We probably only need the typo help here.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 8, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

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.

macro_rules matcher colon instead semicolon

6 participants