diff options
| author | Colin Baumgarten <colin.baumgarten@gmail.com> | 2022-10-01 00:40:59 +0200 |
|---|---|---|
| committer | Colin Baumgarten <colin.baumgarten@gmail.com> | 2022-10-01 01:05:01 +0200 |
| commit | b9e85bf60ab4376a321f03078c06cd95ea5143ef (patch) | |
| tree | d5e0b17555b953ef234b34452d8f3a601e0b8323 /library/alloc/src | |
| parent | 75d3027fb5ce1af6712e4503c9574802212101bd (diff) | |
| download | rust-b9e85bf60ab4376a321f03078c06cd95ea5143ef.tar.gz rust-b9e85bf60ab4376a321f03078c06cd95ea5143ef.zip | |
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
Diffstat (limited to 'library/alloc/src')
| -rw-r--r-- | library/alloc/src/fmt.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/library/alloc/src/fmt.rs b/library/alloc/src/fmt.rs index ed398b56612..799ce9d5daa 100644 --- a/library/alloc/src/fmt.rs +++ b/library/alloc/src/fmt.rs @@ -327,7 +327,7 @@ //! - `text` must not contain any `'{'` or `'}'` characters, //! - `ws` is any character for which [`char::is_whitespace`] returns `true`, has no semantic //! meaning and is completely optional, -//! - `integer` is a decimal integer that may contain leading zeroes and +//! - `integer` is a decimal integer that may contain leading zeroes and must fit into an `usize` and //! - `identifier` is an `IDENTIFIER_OR_KEYWORD` (not an `IDENTIFIER`) as defined by the [Rust language reference](https://doc.rust-lang.org/reference/identifiers.html). //! //! # Formatting traits |
