Skip to content

NOT token (!) inside a macro call inside macro_rules! erroneously de-indented (non-idempotency) #5644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jinohkang-theori opened this issue Dec 29, 2022 · 2 comments
Labels
a-macros bug Panic, non-idempotency, invalid code, etc.

Comments

@jinohkang-theori
Copy link

Minimal reproducer:

mod ok {
    mod ok {
        const _: &'static str = stringify!(Foo: !Bar);
    }
}

macro_rules! ok_2 {
    () => {
        const _: i32 = !1;
    };
}
ok_2!();

macro_rules! fail_dedented {
    () => {
        const _: &'static str = stringify!(Foo: !Bar);
    };
}
fail_dedented!();

macro_rules! fail_dedented_nonidempotent {
    () => {
        const _: () = assert!(stringify!(Foo: !Bar).len() > 0, concat!(stringify!(Foo: !Bar), "Lorem ipsum dolor sit amet, consectetur adipiscing elit"));
    };
}
fail_dedented_nonidempotent!();

macro_rules! fail_dedented_nonidempotent_2 {
    () => {
        const _: () = assert!(stringify!(Foo: !Bar).len() > 0, concat!(stringify!(Foo: !Bar), "Lorem ipsum dolor sit amet, consectetur adipiscing elit"));
    };
}

fail_dedented_nonidempotent_2!();

formats to

mod ok {
    mod ok {
        const _: &'static str = stringify!(Foo: !Bar);
    }
}

macro_rules! ok_2 {
    () => {
        const _: i32 = !1;
    };
}
ok_2!();

macro_rules! fail_dedented {
    () => {
const _: &'static str = stringify!(Foo: !Bar);
    };
}
fail_dedented!();

macro_rules! fail_dedented_nonidempotent {
    () => {
const _: () = assert!(
            stringify!(Foo: !Bar).len() > 0,
            concat!(
                stringify!(Foo: !Bar),
                "Lorem ipsum dolor sit amet, consectetur adipiscing elit"
            )
        );
    };
}
fail_dedented_nonidempotent!();

macro_rules! fail_dedented_nonidempotent_2 {
    () => {
const _: () = assert!(
            stringify!(Foo: !Bar).len() > 0,
            concat!(
                stringify!(Foo: !Bar),
                "Lorem ipsum dolor sit amet, consectetur adipiscing elit"
            )
        );
    };
}

fail_dedented_nonidempotent_2!();

formats to

mod ok {
    mod ok {
        const _: &'static str = stringify!(Foo: !Bar);
    }
}

macro_rules! ok_2 {
    () => {
        const _: i32 = !1;
    };
}
ok_2!();

macro_rules! fail_dedented {
    () => {
const _: &'static str = stringify!(Foo: !Bar);
    };
}
fail_dedented!();

macro_rules! fail_dedented_nonidempotent {
    () => {
        const _: () = assert!(
    stringify!(Foo: !Bar).len() > 0,
            concat!(
        stringify!(Foo: !Bar),
                "Lorem ipsum dolor sit amet, consectetur adipiscing elit"
            )
        );
    };
}
fail_dedented_nonidempotent!();

macro_rules! fail_dedented_nonidempotent_2 {
    () => {
        const _: () = assert!(
    stringify!(Foo: !Bar).len() > 0,
            concat!(
        stringify!(Foo: !Bar),
                "Lorem ipsum dolor sit amet, consectetur adipiscing elit"
            )
        );
    };
}

fail_dedented_nonidempotent_2!();
@jinohkang-theori
Copy link
Author

Not fixed by 0097a90 (PR #5473).

@ytmimi
Copy link
Contributor

ytmimi commented Dec 29, 2022

Thanks for reaching out. I'll see if I can look into this later to determine what's going on here

@ytmimi ytmimi added a-macros bug Panic, non-idempotency, invalid code, etc. labels Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-macros bug Panic, non-idempotency, invalid code, etc.
Projects
None yet
Development

No branches or pull requests

2 participants