Skip to content

Range's Debug implementation misbehaves with formatting #90240

Open
@JaniM

Description

@JaniM

Range's Debug implementation applies formatting rules separately to the start and to the end of the range.

I tried this code:

format!("{:<10?} foo", 0usize..10usize)

I expected to see this happen: Output of

"0..10      foo"`

Instead, this happened: Output of

"0         ..10         foo"

Meta

Tested on latest nightly in the playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=932977922d8d8ae4f5def137c0f93ed2

rustc --version --verbose:

rustc 1.55.0 (c8dfcfe04 2021-09-06)
binary: rustc
commit-hash: c8dfcfe046a7680554bf4eb612bad840e7631c4b
commit-date: 2021-09-06
host: x86_64-unknown-linux-gnu
release: 1.55.0
LLVM version: 12.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-fmtArea: `core::fmt`C-bugCategory: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions