Skip to content

If-chain wrapping when use_small_heuristics = "Max" #5948

Open
@digama0

Description

@digama0

This is a follow up to rust-lang/style-team#169 (comment). Currently, rustfmt is formatting if-chains on nightly, but it uses a line-break-heavy style that is the current front-runner on rust-lang/style-team#169 and other popular styles also exist. In particular, use_small_heuristics = "Max" is IMO a strong indication of intent from the author to not have spurious line breaks, and rustfmt should instead format let chains the same as regular binary operators, filling the line if space permits. (An option specific to if-chains is also reasonable, but use_small_heuristics = "Max" should imply it.)

before:

if let 1 = 1
  && true
{
}

after:

if let 1 = 1 && true {}

This relates to a discussion on Zulip.

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