Skip to content

comment inside of empty enum variant payload with explicit discriminant results in invalid syntax after rustfmt run #5686

@LizzyFleckenstein03

Description

@LizzyFleckenstein03

Example code:

#[repr(u8)]
enum MyEnum {
    MyVariant {
        /* Comment */
    } = 0,
}

This compiles fine.

rustfmt 1.5.2-nightly (50d3ba5 2023-02-04) inserts a line:

#[repr(u8)]
enum MyEnum {
    MyVariant {
        /* Comment */
        } =
    } = 0,
}

This is a syntax error:

error: unexpected closing delimiter: `}`
 --> src/main.rs:7:1
  |
3 |     MyVariant {
  |               - this delimiter might not be properly closed...
4 |         /* Comment */
5 |         } =
  |         - ...as it matches this but it has different indentation
6 |     } = 0,
7 | }
  | ^ unexpected closing delimiter

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-commentsArea: commentsC-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICEE-help-wantedCall for participation: help is requested to fix this issuegood first issueIssues up for grabs, also good candidates for new rustfmt contributors

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions