Skip to content

Macro :meta matcher doesn't match true or false #145060

@tgross35

Description

@tgross35

true and false are now accepted config options. However, they aren't accepted by the meta fragment specifier:

macro_rules! demo {
    ($m:meta) => {
        #[cfg($m)]
        println!("hi {}", stringify!($m));
    }
}

fn main() {
    demo!(any());
    demo!(all());
    demo!(true);
    demo!(false);
}
error: expected identifier, found keyword `true`
  --> src/main.rs:11:11
   |
11 |     demo!(true);
   |           ^^^^ expected identifier, found keyword

error: expected identifier, found keyword `false`
  --> src/main.rs:12:11
   |
12 |     demo!(false);
   |           ^^^^^ expected identifier, found keyword

playground

We should consider whether we want to accept this in the next edition, keeping the current :meta matcher behavior as :meta_2024.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)T-langRelevant to the language teamWG-macrosWorking group: Macros

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions