Skip to content

const statement body expr formatting changed (unexpectedly?) #7092

Description

@jieyouxu

Summary

I tried to format this code: stage0 bump https://github.com/rust-lang/rust/pull/162040/changes#diff-29bf34e005bfe0956e60f3713ab0290027a3c97ce8c2112f818fe4f90b41d82e

pub const POLY_CONST_1<const C: bool>: () = if C { func3() };

Expected behavior

I expected to see this happen: no formatting changes?

Maybe the new formatting is fine, but this should be deliberate and not accidental.

Actual behavior

Instead, this happened: formatting has changed

$ rustfmt +nightly ../reproducer/foo.rs --config-path=/dev/null --style-edition=2024 --edition=2024 --check
Diff in /home/joe/repos/reproducer/foo.rs:1:
-pub const POLY_CONST_1<const C: bool>: () = if C { func3() };
+pub const POLY_CONST_1<const C: bool>: () = if C {
+    func3()
+};

Meta

Version it worked on

It most recently worked on: beta rustfmt 1.10.0-beta (cbae9b4cae 2026-08-28)

Version with regression

Nightly.

rustfmt 1.10.0-nightly (5db7f4be8a 2026-09-01)

I bisected the rust-lang/rust side to the subtree sync rust-lang/rust#161964 (since we recently updated stage0 rustfmt to the commit of that subtree sync). Within that subtree sync, I did manual guessing and bisected to #6956 by reverting the change to see if the formatting difference goes away.

@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions