You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto merge of #102529 - colinba:master, r=joshtriplett
Detect and reject out-of-range integers in format string literals
Until now out-of-range integers in format string literals were silently ignored. They wrapped around to zero at usize::MAX, producing unexpected results.
When using debug builds of rustc, such integers in format string literals even cause an 'attempt to add with overflow' panic in rustc.
Fix this by producing an error diagnostic for integers in format string literals which do not fit into usize.
Fixes#102528
Copy file name to clipboardexpand all lines: library/alloc/src/fmt.rs
+1-1
Original file line number
Diff line number
Diff line change
@@ -327,7 +327,7 @@
327
327
//! - `text` must not contain any `'{'` or `'}'` characters,
328
328
//! - `ws` is any character for which [`char::is_whitespace`] returns `true`, has no semantic
329
329
//! meaning and is completely optional,
330
-
//! - `integer` is a decimal integer that may contain leading zeroes and
330
+
//! - `integer` is a decimal integer that may contain leading zeroes and must fit into an `usize` and
331
331
//! - `identifier` is an `IDENTIFIER_OR_KEYWORD` (not an `IDENTIFIER`) as defined by the [Rust language reference](https://doc.rust-lang.org/reference/identifiers.html).
0 commit comments