-
Notifications
You must be signed in to change notification settings - Fork 962
Open
Labels
a-macrosbugPanic, non-idempotency, invalid code, etc.Panic, non-idempotency, invalid code, etc.poor-formatting
Description
TLDR: a ,
is inserted between struct/enum declaration and other fragment specifiers in macros, which cause them to break after formatting.
This happens for both tupled and named structs and enums, but does not happen for unions. This is clearly not linked to the macro definition itself.
Input
mac!(struct Foo {} bar);
mac!(struct Foo; bar);
mac!(enum Foo {} bar);
Output
mac!(struct Foo {}, bar);
mac!(struct Foo;, bar);
mac!(enum Foo {}, bar);
Notice the ,
inserted between the struct/enum declaration, which can break the macro.
Expected output
mac!(struct Foo {} bar);
mac!(struct Foo; bar);
mac!(enum Foo {} bar);
I have created a playground link, so that it is easier to see what's wrong.
Meta
- rustfmt version: rustfmt 1.4.15-stable (530eadf 2020-06-02) (tested, also reproducible on the playground)
- From where did you install rustfmt?: Installed via NixOS package manager, but also happens on the playground.
Feel free to ping me if other information is needed.
Edits
- 2020/08/27: specify that this is independent from the macro definition itself, mention enums and unions.
Metadata
Metadata
Assignees
Labels
a-macrosbugPanic, non-idempotency, invalid code, etc.Panic, non-idempotency, invalid code, etc.poor-formatting