Skip to content

macro_rules! thinks use is an ident. It isn't. #40569

Closed
@sgrif

Description

@sgrif

This code should fail to compile, giving the same error message as fn use() would give, but it compiles successfully.

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

fn main() {
    foo!(use);
}

This code should compile successfully. However, it fails complaining that it can't decide whether use is an ident or not (hint: it isn't). It also shouldn't be trying to match use as an ident because of the semicolon, but that's a broader/deeper issue with macro_rules!

macro_rules! foo {
    ($(use ;)* $foo:ident) => {}
}

fn main() {
    foo!(use ; use ; bar);
}

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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions