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
This commit is contained in:
parent
75d3027fb5
commit
b9e85bf60a
3 changed files with 40 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue