Skip to content

Regression in 1.94.0 beta: Rustfmt produces broken code for const blocks in array lengths #6788

@theemathas

Description

@theemathas

Given the following code:

fn foo() {
    let a = [(); const { let x = 1; x }];
}

On version 1.94.0-beta.2 (2026-01-25 23a44d3c70448c08dc6a), rustfmt will format this code into the following code, which is broken:

fn foo() {
    let a = [(); {        onst {        let x = 1;
        x
    }];
}

On version 1.93.0, however, rustfmt correctly formats the code as follows:

fn foo() {
    let a = [(); const {
        let x = 1;
        x
    }];
}

Metadata

Metadata

Assignees

Labels

C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICEI-invalid-codeIssue: formatting causes compile-pass code to compile-failP-highHigh priorityS-has-bisectionStatus: a bisection has been found for this issueS-has-mcveStatus: a Minimal Complete and Verifiable Example has been found for this issueregression-from-stable-to-betaRegression from stable to beta.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions