Skip to content

rustfmt stops formatting after line comment following .. in a struct pattern #6040

@laikoni

Description

@laikoni

I wondered why suddenly only half of my file got formatted and boiled down the code to the following MWE:

fn main() {
match e { // this line still gets formatted
        MyStruct {
            field_a,
            .. // this comment here apparently causes trouble
        } => (),
_ => (), // this line is no longer formatted
    };
}

Notably, rustfmt does not complain, it just ignores everything after the offending comment and formats the file only up to that point.

I saw that there are already many open issues revolving around comments, so my apologies if this exact issue has been reported before.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions