Skip to content

Improvements to match formatting #152763

@traviscross

Description

@traviscross

View all comments

As originally discussed and described in rust-lang/style-team#196 (comment), we want to do the following:

  • We want to say that whenever we wrap the { to a new line, we always put the => on the same line as the { rather than hanging it on the end of the previous line. In other words, "never break between the => and the {".
  • We want to break the => { onto a new line if the pattern spans multiple lines and has indented continuation lines (because it has an if guard).

(2026-03-03:) Originally, there was a third rule proposed:

  • We want to always break a match arm body onto a new line if the pattern spans multiple lines (and thus always use braces for such a match arm, given the default setting of match_arm_blocks).

In #152763 (comment), we decided not to do this one as part of this proposal.

cc @rust-lang/style

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-style-nominatedNominated for discussion during a style team meeting.T-styleRelevant to the style team, which will review and decide on the PR/issue.proposed-final-comment-periodProposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions