Skip to content

Formatter takes two runs to fully format comment after match arm #4757

@wooster0

Description

@wooster0

Input

fn main() {
    match 1 {
        _ => {},
        // hello!
    }
}

Output

fn main() {
    match 1 {
        _ => {}
        // hello!
    }
}

Expected output

fn main() {
    match 1 {
        _ => {} // hello!
    }
}

You get the expected output if you run it a second time. This means that the formatter needs multiple runs to fully finish formatting the code. That does not seem right. I want to be able to trust the formatter in that it will do it all in one run so that I never get into the habit of running it twice each time just to be 100% sure. Therefore I report this as a bug.

Meta

  • rustfmt version: rustfmt 1.4.30-stable (8c6769d 2021-01-18)
  • From where did you install rustfmt?: rustup

Metadata

Metadata

Assignees

No one assigned

    Labels

    a-commentsa-matchesmatch arms, patterns, blocks, etcbugPanic, non-idempotency, invalid code, etc.duplicate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions