Skip to content

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

Open
ozankenangungor wants to merge 2 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 2 commits intorust-lang:mainfrom
ozankenangungor:fix-macro-rules-colon-semicolon

Conversation

@ozankenangungor
Copy link
Contributor

@ozankenangungor ozankenangungor commented Mar 14, 2026

Closes #153320

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

This leaves the existing missing fragment specifier diagnostic as-is and only adds an extra suggestion for the $x;fragment case.

@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
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.

result.push(TokenTree::MetaVarDecl {
span: start_sp,
name: ident,
kind: NonterminalKind::TT,
Copy link
Member

@fmease fmease Mar 14, 2026

Choose a reason for hiding this comment

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

You could use the nonterminal kind here that you've already parsed above but are currently discarding.

That way, you'd recover $x;ty as $x:ty instead of $x:tt.

Comment on lines +9 to +12
help: try adding a specifier here
|
LL | ($x:spec;tt) => {};
| +++++
Copy link
Member

Choose a reason for hiding this comment

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

haven't looked thought, but is that possible to remove this missleading help?

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.

macro_rules matcher colon instead semicolon

6 participants