Skip to content

Commit 4bbe532

Browse files
committed
More detail for format! width bigger than u16::MAX
Formatting the width of a numeric value is limited to a `u16`, but the macros accept any `usize` and can panic at runtime. Previously the panic didn't provide any additional information about the failure, other than "too big".
1 parent 5c7ae0c commit 4bbe532

File tree

1 file changed

+1
-1
lines changed
  • library/core/src/fmt

1 file changed

+1
-1
lines changed

library/core/src/fmt/rt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl Argument<'_> {
150150
#[track_caller]
151151
pub const fn from_usize(x: &usize) -> Argument<'_> {
152152
if *x > u16::MAX as usize {
153-
panic!("Formatting argument out of range");
153+
panic!("Formatting argument out of range: `{x}` is bigger than `u16::MAX`");
154154
}
155155
Argument { ty: ArgumentType::Count(*x as u16) }
156156
}

0 commit comments

Comments
 (0)