Skip to content

Rustfmt causes compilation error by inserting illegal trailing comma in macro #4675

Closed
@Aloso

Description

@Aloso

Describe the bug

Struct patterns that end with .. can't have a trailing comma. However, rustfmt on nightly inserts one within macro_rules!.

To Reproduce

Run rustup default nightly, then format this code:

macro_rules! foo {
    ($s:ident ( $p:pat )) => {
        Foo {
            name: Name::$s($p),
            ..
        }
    };
}

Expected behavior

The comma should not be inserted to ensure that expanded code compiles.

Meta

  • rustfmt version: rustfmt 1.4.32-nightly (216a643 2021-01-16)
  • From where did you install rustfmt? Via rustup
  • How do you run rustfmt: Either with cargo fmt or with rust-analyzer (makes no difference)

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions