Skip to content

Macro hygiene bug #32922

@jseyfried

Description

@jseyfried

The following should print 1, but it currently prints 0:

fn main() {
    let x = 0;
    macro_rules! foo { () => {
        let x = 1;
        macro_rules! bar { () => {x} }
        println!("{}", bar!());
    }}

    foo! {};
}

For comparison, the following correctly prints 1:

fn main() {
    let x = 0;
    macro_rules! foo { () => {{ //< note the added brace here
        let x = 1;
        macro_rules! bar { () => {x} }
        println!("{}", bar!());
    }}}

    foo! {};
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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