Skip to content
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

Illegally adds comma to macro invocation #6496

Open
Person-93 opened this issue Mar 10, 2025 · 1 comment
Open

Illegally adds comma to macro invocation #6496

Person-93 opened this issue Mar 10, 2025 · 1 comment
Labels
a-macros bug Panic, non-idempotency, invalid code, etc.

Comments

@Person-93
Copy link

Rustfmt adds a comma to the following and causes a compiler error.

macro_rules! idx {
    ($(#[$attr:meta])* $vis:vis struct $name:ident; $metadata:ident) => {
        $(#[$attr])*
        $vis struct $name(usize);
    };
}

idx!(
    #[derive(Debug)]
    pub struct FooIdx; // rustfmt adds a comma here
    Meta
);
@ytmimi ytmimi added bug Panic, non-idempotency, invalid code, etc. a-macros labels Mar 10, 2025
@ytmimi
Copy link
Contributor

ytmimi commented Mar 10, 2025

Thanks for the report. Confirming I can reproduce this with rustfmt 1.8.0-nightly (c6c8159 2025-02-27)

Input:

idx!(
    #[derive(Debug)]
    pub struct FooIdx; // rustfmt adds a comma here
    Meta
);

Output:

idx!(
    #[derive(Debug)]
    pub struct FooIdx;, // rustfmt adds a comma here
    Meta
);

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