Skip to content

Expand macro returns wrong text when top level declarative macro call is in scope #1162

@piotmag769

Description

@piotmag769

E.g.

pub macro inc {
    ($x:expr) => { $x + 1 };
}

crate::inc!(2);

#[test]<caret>
fn test() {
    inc!(0);
}

expands the inc!(0) without the context instead of #[test]. However

pub macro inc {
    ($x:expr) => { $x + 1 };
}


#[test]<caret>
fn test() {
    inc!(0);
}

crate::inc!(2);

gives incorrect result - part of the test expanded code is missing.

When crate::inc!(2); is removed - everything works as expected

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions