Skip to content

macro_rules matcher colon instead semicolon #153320

@A4-Tacks

Description

@A4-Tacks

Code

macro_rules! foo {
    ($x;tt) => {};
}

Current output

error: missing fragment specifier
 --> src/bin/main.rs:2:6
  |
2 |     ($x;tt) => {};
  |      ^^
  |
  = note: fragment specifiers must be provided
  = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`, along with `expr_2021` and `pat_param` for edition compatibility
help: try adding a specifier here
  |
2 |     ($x:spec;tt) => {};
  |        +++++

Desired output

error: missing fragment specifier
 --> src/bin/main.rs:2:6
  |
2 |     ($x;tt) => {};
  |      ^^
  |
  = note: fragment specifiers must be provided
  = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`, along with `expr_2021` and `pat_param` for edition compatibility
help: try adding a specifier here
  |
2 |     ($x:spec;tt) => {};
  |        +++++
help: use a semicolon instead
  |
2 -     ($x;tt) => {};
2 +     ($x:tt) => {};

Rationale and extra context

No response

Other cases

Rust Version

rustc 1.95.0-nightly (a293cc4af 2026-01-30)
binary: rustc
commit-hash: a293cc4af8b26701c42738381c0c6f9d2ba881e0
commit-date: 2026-01-30
host: aarch64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 22.1.0

Anything else?

No response

Metadata

Metadata

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions