Skip to content

Rustfmt duplicates commas in struct declarations #4714

@xTibor

Description

@xTibor

Describe the bug

There's a weird interaction between comments and commas in struct declarations that leads to duplication of commas and breaking the syntax of the formatted code (error: expected identifier, found ',')

To Reproduce

Input:

struct Something {
    field: u32/*a*/,/*b*/
}

Formatting result:

struct Something {
    field: u32, /*a*/,/*b*/
}

Expected behavior

Do not duplicate commas.

Meta

  • rustfmt version: 1.4.36-nightly (2021-02-07 7de6968)
  • From where did you install rustfmt?: playground
  • How do you run rustfmt: playground

Metadata

Metadata

Assignees

No one assigned

    Labels

    1x-backport:pendingFixed/resolved in source but not yet backported to a 1x branch and releasea-commentsbugPanic, non-idempotency, invalid code, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions