Skip to content

rustfmt should keep array types together when possible #6976

Description

@jrose-signal

Summary

I tried to format this code:

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:

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:

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)

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-poor-formattingIssue: poor formatting

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions