Skip to content

Certain match expressions are unnecessarily indented and placed on next line #6865

@taylordotfish

Description

@taylordotfish

Summary

I tried to format this code:

fn main() {
    let x = match y {
        z => Some(z.checked_add(1).expect(
            "1234567890123456789012345678901234567890123456789012345678901234567890123",
        )),
    };
}

Expected behavior

I expected the code to stay the same, because none of the lines exceed the length limit of 100.

Actual behavior

Instead, Rustfmt formats the code like this:

fn main() {
    let x =
        match y {
            z => Some(z.checked_add(1).expect(
                "1234567890123456789012345678901234567890123456789012345678901234567890123",
            )),
        };
}

The only difference compared to the input is that the match expression has been indented and placed on the next line. I think this is clearly worse than the input.

Configuration

Default configuration (blank rustfmt.toml).

Reproduction Steps

Run rustfmt on the sample code with default options.

Meta

rustfmt --version:

rustfmt 1.9.0-nightly (e8e4541ff1 2026-04-15)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-call-chainsArea: method call chainsA-expressionsArea: expressionsA-matchesArea: match arms, patterns, blocks, etcC-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICES-has-mcveStatus: a Minimal Complete and Verifiable Example has been found for this issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions