#6976·rustfmt

rustfmt should keep array types together when possible

Author: jrose-signalCreated Jul 22, 2026Updated Sep 9, 2026
LabelsC-bugI-poor-formatting

Summary

I tried to format this code:

rust
pub(super) const ENCRYPTED_USERNAME_ENTROPY: [u8; usernames::constants::USERNAME_LINK_ENTROPY_SIZE] =
    const_str::hex!("4302c613c092a51c5394becffeb6f697300a605348e93f03c3db95e0b03d28f1");

(don't worry, this is not sensitive entropy data, it was generated for a test case)

Expected behavior

I expected to get this, splitting after the colon:

rust
pub(super) const ENCRYPTED_USERNAME_ENTROPY:
    [u8; usernames::constants::USERNAME_LINK_ENTROPY_SIZE] =
    const_str::hex!("4302c613c092a51c5394becffeb6f697300a605348e93f03c3db95e0b03d28f1");

Actual behavior

Instead, rustfmt did this, splitting the array type after the semicolon:

rust
pub(super) const ENCRYPTED_USERNAME_ENTROPY: [u8;
    usernames::constants::USERNAME_LINK_ENTROPY_SIZE] =
    const_str::hex!("4302c613c092a51c5394becffeb6f697300a605348e93f03c3db95e0b03d28f1");

Configuration

None

Meta

Playground rustfmt 1.9.0-stable, also 1.9.0-nightly (0e29c21d93 2026-07-21)