Skip to content

A long string in a match arm breaks formatting for the whole match expressionΒ #4797

Open
@arnaudgolfouse

Description

@arnaudgolfouse

Describe the bug

If an arm of a match expression contains a string with >= 87 characters, formatting fails on the whole match

To Reproduce

match 0 {
    0 => {"hello"} 1 => { ""}
      _ => {"veeeeeeeeeeery loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong string"}
};

Expected behavior

 match 0 {
    0 => "hello",
    1 => "",
    _ => {
        "veeeeeeeeeeery loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong string"
    }
};

If the third string is less than 86 characters, formatting works as expected.

Meta

  • rustfmt version: rustfmt 1.4.36-stable (7de6968 2021-02-07)
  • From where did you install rustfmt?: rustup
  • How do you run rustfmt: rustfmt, cargo-fmt, and rust-analyzer formatting in VSCode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    1x-backport:pendingFixed/resolved in source but not yet backported to a 1x branch and releasea-matchesmatch arms, patterns, blocks, etchelp wantedp-low

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions