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
|
@ -57,6 +57,21 @@ fn invalid06() {
|
|||
musterr("{:>>>}")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_position() {
|
||||
musterr("{18446744073709551616}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_width() {
|
||||
musterr("{:18446744073709551616}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_precision() {
|
||||
musterr("{:.18446744073709551616}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn format_nothing() {
|
||||
same(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue