Skip to content

Rustfmt generated unaligned indent code block #7003

Description

@A4-Tacks

Summary

I tried to format this code:

fn main() {
    {
        _ = if let Some(term_node) = sema
            .token_ancestors_with_macros(token.clone())
            .find(|node| {
                matches!(
                    node.kind(),
                    BLOCK_EXPR | ARG_LIST | PAREN_EXPR | ARRAY_EXPR | MATCH_EXPR
                )
            }) {
            match term_node.kind() {}
        };
    }
}

Expected behavior

fn main() {
    {
        _ = if let Some(term_node) = sema
            .token_ancestors_with_macros(token.clone())
            .find(|node| {
                matches!(
                    node.kind(),
                    BLOCK_EXPR | ARG_LIST | PAREN_EXPR | ARRAY_EXPR | MATCH_EXPR
                )
            })
        {
            match term_node.kind() {}
        };
    }
}

Actual behavior

Referece Summary is formatted code

Configuration

rustfmt cli options used (if applicable):

$ rustfmt < foo.rs

rustfmt configuration file (e.g. rustfmt.toml, if applicable):

Reproduction Steps

  1. Run cli

Meta

rustfmt --version:

rustfmt 1.9.0-nightly (36ba2c7712 2026-04-23)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions