-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Open
Labels
C-bugCategory: This is a bug.Category: This is a bug.P-highHigh priorityHigh priorityT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant 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.Performance or correctness regression from stable to nightly.
Description
Code
(See previous issue #152804 and fix #152865.)
I tried this code (playground):
#[test]
fn format_path() {
use std::path::Path;
assert_eq!(format!("{:10.4}", Path::new("/bin/ls").display()), "/bin ");
assert_eq!(format!("{:>10.4}", Path::new("/bin/ls").display()), " /bin");
assert_eq!(format!("{:<10.4}", Path::new("/bin/ls").display()), "/bin ");
assert_eq!(format!("{:^10.4}", Path::new("/bin/ls").display()), " /bin ");
}I expected this test to pass; in Stable, specifying a precision for a string argument causes it to be truncated before padding is applied.
Instead, the test fails with:
---- format_path stdout ----
thread 'format_path' (47) panicked at src/lib.rs:12:5:
assertion `left == right` failed
left: "/bin/ls "
right: "/bin "
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 (c78a29473 2026-02-22)
binary: rustc
commit-hash: c78a29473a68f07012904af11c92ecffa68fcc75
commit-date: 2026-02-22
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 22.1.0
Note this version contains the previous fix in #152865.
Backtrace
Backtrace
$ RUST_BACKTRACE=1 cargo +nightly test
Compiling fmt-test v0.1.0 (/home/jorendorff/src/fmt-test)
Finished `test` profile [unoptimized + debuginfo] target(s) in 0.42s
Running unittests src/main.rs (target/debug/deps/fmt_test-d2bdd0cffa5ebb82)
running 2 tests
test format_str ... ok
test format_path ... FAILED
failures:
---- format_path stdout ----
thread 'format_path' (135186) panicked at src/main.rs:12:5:
assertion `left == right` failed
left: "/bin/ls "
right: "/bin "
stack backtrace:
0: __rustc::rust_begin_unwind
at /rustc/c78a29473a68f07012904af11c92ecffa68fcc75/library/std/src/panicking.rs:689:5
1: core::panicking::panic_fmt
at /rustc/c78a29473a68f07012904af11c92ecffa68fcc75/library/core/src/panicking.rs:80:14
2: core::panicking::assert_failed_inner
at /rustc/c78a29473a68f07012904af11c92ecffa68fcc75/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: fmt_test::format_path
at ./src/main.rs:12:5
5: fmt_test::format_path::{closure#0}
at ./src/main.rs:10:17
6: <fmt_test::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/c78a29473a68f07012904af11c92ecffa68fcc75/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
failures:
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 `--bin fmt-test`@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged
Reactions are currently unavailable
Metadata
Metadata
Labels
C-bugCategory: This is a bug.Category: This is a bug.P-highHigh priorityHigh priorityT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant 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.Performance or correctness regression from stable to nightly.