Skip to content

std::path::Display regressed in 1.95.0 Nightly #152804

@jorendorff

Description

@jorendorff

Code

I tried this code (playground):

#[test]
fn format_path() {
    use std::path::Path;
    assert_eq!(format!("{:10}", Path::new("/bin/ls").display()), "/bin/ls   ");
}

I expected this test to pass; formatting should produce a string 10 characters wide.

Instead, the test fails with:

---- tests::format_other stdout ----

thread 'tests::format_other' (208327) panicked at src/lib.rs:14:9:
assertion `left == right` failed
  left: "/bin/ls"
 right: "/bin/ls   "
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Version it worked on

It most recently worked on: 1.94.0-beta.3

Version with regression

rustc --version --verbose:

rustc 1.95.0-nightly (838709580 2026-02-17)
binary: rustc
commit-hash: 8387095803f21a256a9a772ac1f9b41ed4d5aa0a
commit-date: 2026-02-17
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 22.1.0

Backtrace

Backtrace

❯ RUST_BACKTRACE=1 cargo +nightly test
   Compiling wtf v0.1.0 (/home/jorendorff/wtf/wtf)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.36s
     Running unittests src/lib.rs (target/debug/deps/wtf-9a0d8a9c3d31431d)

running 2 tests
test tests::it_works ... ok
test tests::format_path ... FAILED

failures:

---- tests::format_path stdout ----

thread 'tests::format_path' (210283) panicked at src/lib.rs:12:9:
assertion `left == right` failed
  left: "/bin/ls"
 right: "/bin/ls   "
stack backtrace:
   0: __rustc::rust_begin_unwind
             at /rustc/8387095803f21a256a9a772ac1f9b41ed4d5aa0a/library/std/src/panicking.rs:689:5
   1: core::panicking::panic_fmt
             at /rustc/8387095803f21a256a9a772ac1f9b41ed4d5aa0a/library/core/src/panicking.rs:80:14
   2: core::panicking::assert_failed_inner
             at /rustc/8387095803f21a256a9a772ac1f9b41ed4d5aa0a/library/core/src/panicking.rs:439:17
   3: core::panicking::assert_failed::<alloc::string::String, &str>
             at /home/jorendorff/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panicking.rs:394:5
   4: wtf::tests::format_path
             at ./src/lib.rs:12:9
   5: wtf::tests::format_path::{closure#0}
             at ./src/lib.rs:10:21
   6: <wtf::tests::format_path::{closure#0} as core::ops::function::FnOnce<()>>::call_once
             at /home/jorendorff/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
   7: <fn() -> core::result::Result<(), alloc::string::String> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/8387095803f21a256a9a772ac1f9b41ed4d5aa0a/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.


failures:
    tests::format_path

test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.27s

error: test failed, to rerun pass `--lib`

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions