Skip to content

Commit c8c261b

Browse files
committed
rebase
Signed-off-by: 11happy <[email protected]>
1 parent 33a0468 commit c8c261b

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

tests/ui/lint/type-overflow.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,12 @@ fn main() {
4141

4242
let fail = 0x8FFF_FFFF_FFFF_FFFE; //~WARNING literal out of range for `i32`
4343
//~| HELP consider using the type `u64` instead
44-
//~| HELP
44+
//~| HELP consider using the type `u64` for the literal and cast it to `i32`
4545

4646
let fail = -0b1111_1111i8; //~WARNING literal out of range for `i8`
4747
//~| HELP consider using the type `i16` instead
48+
49+
let fail = 0x8000_0000_0000_0000_0000_0000_FFFF_FFFE; //~WARNING literal out of range for `i32`
50+
//~| HELP consider using the type `u128` instead
51+
//~| HELP consider using the type `u128` for the literal and cast it to `i32`
4852
}

tests/ui/lint/type-overflow.stderr

+17-4
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ LL | let fail = 0x8FFF_FFFF_FFFF_FFFE;
112112
|
113113
= note: the literal `0x8FFF_FFFF_FFFF_FFFE` (decimal `10376293541461622782`) does not fit into the type `i32` and will become `-2i32`
114114
= help: consider using the type `u64` instead
115-
help: to use as a negative number (decimal `-2`), consider using the type `u32` for the literal and cast it to `i32`
115+
help: to use as a negative number (decimal `-2`), consider using the type `u64` for the literal and cast it to `i32`
116116
|
117-
LL | let fail = 0x8FFF_FFFF_FFFF_FFFEu32 as i32;
118-
| ++++++++++
117+
LL | let fail = 0x8FFF_FFFF_FFFF_FFFEu64 as i32;
118+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
119119

120120
warning: literal out of range for `i8`
121121
--> $DIR/type-overflow.rs:46:17
@@ -126,5 +126,18 @@ LL | let fail = -0b1111_1111i8;
126126
= note: the literal `0b1111_1111i8` (decimal `255`) does not fit into the type `i8`
127127
= note: and the value `-0b1111_1111i8` will become `1i8`
128128

129-
warning: 11 warnings emitted
129+
warning: literal out of range for `i32`
130+
--> $DIR/type-overflow.rs:49:16
131+
|
132+
LL | let fail = 0x8000_0000_0000_0000_0000_0000_FFFF_FFFE;
133+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
134+
|
135+
= note: the literal `0x8000_0000_0000_0000_0000_0000_FFFF_FFFE` (decimal `170141183460469231731687303720179073022`) does not fit into the type `i32` and will become `-2i32`
136+
= help: consider using the type `u128` instead
137+
help: to use as a negative number (decimal `-2`), consider using the type `u128` for the literal and cast it to `i32`
138+
|
139+
LL | let fail = 0x8000_0000_0000_0000_0000_0000_FFFF_FFFEu128 as i32;
140+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
141+
142+
warning: 12 warnings emitted
130143

0 commit comments

Comments
 (0)