Skip to content

Commit 38c4885

Browse files
committed
Add more test cases
1 parent 757f5bb commit 38c4885

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
//@ only-64bit
2+
13
fn main() {
24
format_args!("{}", 0x8f_i8); // issue #115423
35
//~^ ERROR literal out of range for `i8`
46
format_args!("{}", 0xffff_ffff_u8); // issue #116633
57
//~^ ERROR literal out of range for `u8`
8+
format_args!("{}", 0xffff_ffff_ffff_ffff_ffff_usize);
9+
//~^ ERROR literal out of range for `usize`
10+
format_args!("{}", 0x8000_0000_0000_0000_isize);
11+
//~^ ERROR literal out of range for `isize`
612
format_args!("{}", 0xffff_ffff); // treat unsuffixed literals as i32
713
//~^ ERROR literal out of range for `i32`
814
}

tests/ui/fmt/no-inline-literals-out-of-range.stderr

+20-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: literal out of range for `i8`
2-
--> $DIR/no-inline-literals-out-of-range.rs:2:24
2+
--> $DIR/no-inline-literals-out-of-range.rs:4:24
33
|
44
LL | format_args!("{}", 0x8f_i8); // issue #115423
55
| ^^^^^^^
@@ -16,15 +16,31 @@ LL | format_args!("{}", 0x8f_u8 as i8); // issue #115423
1616
| ~~~~~~~~~~~~~
1717

1818
error: literal out of range for `u8`
19-
--> $DIR/no-inline-literals-out-of-range.rs:4:24
19+
--> $DIR/no-inline-literals-out-of-range.rs:6:24
2020
|
2121
LL | format_args!("{}", 0xffff_ffff_u8); // issue #116633
2222
| ^^^^^^^^^^^^^^ help: consider using the type `u32` instead: `0xffff_ffff_u32`
2323
|
2424
= note: the literal `0xffff_ffff_u8` (decimal `4294967295`) does not fit into the type `u8` and will become `255u8`
2525

26+
error: literal out of range for `usize`
27+
--> $DIR/no-inline-literals-out-of-range.rs:8:24
28+
|
29+
LL | format_args!("{}", 0xffff_ffff_ffff_ffff_ffff_usize);
30+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
31+
|
32+
= note: the literal `0xffff_ffff_ffff_ffff_ffff_usize` (decimal `1208925819614629174706175`) does not fit into the type `usize` and will become `18446744073709551615usize`
33+
34+
error: literal out of range for `isize`
35+
--> $DIR/no-inline-literals-out-of-range.rs:10:24
36+
|
37+
LL | format_args!("{}", 0x8000_0000_0000_0000_isize);
38+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
39+
|
40+
= note: the literal `0x8000_0000_0000_0000_isize` (decimal `9223372036854775808`) does not fit into the type `isize` and will become `-9223372036854775808isize`
41+
2642
error: literal out of range for `i32`
27-
--> $DIR/no-inline-literals-out-of-range.rs:6:24
43+
--> $DIR/no-inline-literals-out-of-range.rs:12:24
2844
|
2945
LL | format_args!("{}", 0xffff_ffff); // treat unsuffixed literals as i32
3046
| ^^^^^^^^^^^
@@ -36,5 +52,5 @@ help: to use as a negative number (decimal `-1`), consider using the type `u32`
3652
LL | format_args!("{}", 0xffff_ffffu32 as i32); // treat unsuffixed literals as i32
3753
| ~~~~~~~~~~~~~~~~~~~~~
3854

39-
error: aborting due to 3 previous errors
55+
error: aborting due to 5 previous errors
4056

0 commit comments

Comments
 (0)