Skip to content

Commit 0444574

Browse files
Rollup merge of #165417 - xbwwj:doc-format-width-panic, r=ChrisDenton
Mention width limit panic in fmt doc `format!` will panic if dynamic width exceeds 65535. Mention this in the doc. ```rust fn main() { println!("Hello {:width$}!", "x", width = 65536); } // thread 'main' (2688852) panicked at src/main.rs:2:5: // Formatting argument out of range // note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ```
2 parents 7ec3132 + bd23dae commit 0444574

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎library/alloc/src/fmt.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@
139139
//! The width can also be provided dynamically by referencing another argument
140140
//! with a `$` suffix. Use `{:N$}` to reference the Nth positional argument
141141
//! (where N is an integer), or `{:name$}` to reference a named argument. The
142-
//! referenced argument must be of type [`usize`].
142+
//! referenced argument must be of type [`usize`]. Currently formatting will
143+
//! panic if the width exceeds [`u16::MAX`].
143144
//!
144145
//! Referring to an argument with the dollar syntax does not affect the "next
145146
//! argument" counter, so it's usually a good idea to refer to arguments by

0 commit comments

Comments
 (0)