You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rollup merge of #79981 - camelid:overflowing_literals-inference-error, r=lcnr
Add 'consider using' message to overflowing_literals
Fixes#79744.
Ironically, the `overflowing_literals` handler for binary or hex already
had this message! You would think it would be the other way around :)
cc ```@scottmcm```
Copy file name to clipboardExpand all lines: src/test/ui/lint/type-overflow.stderr
+13-12
Original file line number
Diff line number
Diff line change
@@ -10,54 +10,55 @@ note: the lint level is defined here
10
10
LL | #![warn(overflowing_literals)]
11
11
| ^^^^^^^^^^^^^^^^^^^^
12
12
= note: the literal `255i8` does not fit into the type `i8` whose range is `-128..=127`
13
+
= help: consider using the type `u8` instead
13
14
14
-
warning: literal out of range for i8
15
+
warning: literal out of range for `i8`
15
16
--> $DIR/type-overflow.rs:10:16
16
17
|
17
18
LL | let fail = 0b1000_0001i8;
18
-
| ^^^^^^^^^^^^^ help: consider using `u8` instead: `0b1000_0001u8`
19
+
| ^^^^^^^^^^^^^ help: consider using the type `u8` instead: `0b1000_0001u8`
19
20
|
20
21
= note: the literal `0b1000_0001i8` (decimal `129`) does not fit into the type `i8` and will become `-127i8`
21
22
22
-
warning: literal out of range for i64
23
+
warning: literal out of range for `i64`
23
24
--> $DIR/type-overflow.rs:12:16
24
25
|
25
26
LL | let fail = 0x8000_0000_0000_0000i64;
26
-
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `u64` instead: `0x8000_0000_0000_0000u64`
27
+
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using the type `u64` instead: `0x8000_0000_0000_0000u64`
27
28
|
28
29
= note: the literal `0x8000_0000_0000_0000i64` (decimal `9223372036854775808`) does not fit into the type `i64` and will become `-9223372036854775808i64`
29
30
30
-
warning: literal out of range for u32
31
+
warning: literal out of range for `u32`
31
32
--> $DIR/type-overflow.rs:14:16
32
33
|
33
34
LL | let fail = 0x1_FFFF_FFFFu32;
34
-
| ^^^^^^^^^^^^^^^^ help: consider using `u64` instead: `0x1_FFFF_FFFFu64`
35
+
| ^^^^^^^^^^^^^^^^ help: consider using the type `u64` instead: `0x1_FFFF_FFFFu64`
35
36
|
36
37
= note: the literal `0x1_FFFF_FFFFu32` (decimal `8589934591`) does not fit into the type `u32` and will become `4294967295u32`
37
38
38
-
warning: literal out of range for i128
39
+
warning: literal out of range for `i128`
39
40
--> $DIR/type-overflow.rs:16:22
40
41
|
41
42
LL | let fail: i128 = 0x8000_0000_0000_0000_0000_0000_0000_0000;
42
43
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
43
44
|
44
45
= note: the literal `0x8000_0000_0000_0000_0000_0000_0000_0000` (decimal `170141183460469231731687303715884105728`) does not fit into the type `i128` and will become `-170141183460469231731687303715884105728i128`
45
-
= help: consider using `u128` instead
46
+
= help: consider using the type `u128` instead
46
47
47
-
warning: literal out of range for i32
48
+
warning: literal out of range for `i32`
48
49
--> $DIR/type-overflow.rs:19:16
49
50
|
50
51
LL | let fail = 0x8FFF_FFFF_FFFF_FFFE;
51
52
| ^^^^^^^^^^^^^^^^^^^^^
52
53
|
53
54
= note: the literal `0x8FFF_FFFF_FFFF_FFFE` (decimal `10376293541461622782`) does not fit into the type `i32` and will become `-2i32`
54
-
= help: consider using `i128` instead
55
+
= help: consider using the type `i128` instead
55
56
56
-
warning: literal out of range for i8
57
+
warning: literal out of range for `i8`
57
58
--> $DIR/type-overflow.rs:21:17
58
59
|
59
60
LL | let fail = -0b1111_1111i8;
60
-
| ^^^^^^^^^^^^^ help: consider using `i16` instead: `0b1111_1111i16`
61
+
| ^^^^^^^^^^^^^ help: consider using the type `i16` instead: `0b1111_1111i16`
61
62
|
62
63
= note: the literal `0b1111_1111i8` (decimal `255`) does not fit into the type `i8` and will become `-1i8`
0 commit comments