Skip to content

Is an initial | on match arms a formatting issue? #119

@nrc

Description

@nrc

It is now possible in Rust to start a match arm with a |, e.g.,

match foo {
    | whatever => {}
}

Currently Rustfmt treats a leading | or not as significant code, i.e., preserves what the user chose to do. However, it is not semantically significant, so one might consider it a style issue, in which case Rustfmt should change it one way or the other (since we believe in consistent formatting, not preserving user input). As a counter-point, we do not strip unnecessary () although these also are not semantically significant.

So, there are three options:

  • never use an initial |
  • always use an intial |
  • preserve the user choice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions