Skip to content

Standalone $ is accepted as a token in declarative macros. #153142

@cafce25

Description

@cafce25

I tried this code:

macro_rules! foo {
    ($) => {}
}

I expected to see this happen: an error because a standalone $ doesn't match any of the grammar rules from the reference

Instead, this happened: the code compiles, you can successfully invoke the macro like this foo!($);

Playground

Meta

Latest stable on the playground (1.93.1)
Also on the nightly verson:

Nightly version: 1.95.0-nightly
(2026-02-24 859951e3c7c9d0322c39)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamneeds-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions