rustfmt should keep array types together when possible
Open
@Blackgaurd is already working on this.
Since Jul 29, 2026.
C-bug
I-poor-formatting
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
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)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.