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
Copy file name to clipboardExpand all lines: compiler/rustc_lint/messages.ftl
+1
Original file line number
Diff line number
Diff line change
@@ -425,6 +425,7 @@ lint_overflowing_bin_hex = literal out of range for `{$ty}`
425
425
.negative_becomes_note = and the value `-{$lit}` will become `{$actually}{$ty}`
426
426
.positive_note = the literal `{$lit}` (decimal `{$dec}`) does not fit into the type `{$ty}` and will become `{$actually}{$ty}`
427
427
.suggestion = consider using the type `{$suggestion_ty}` instead
428
+
.sign_bit_suggestion = to use as a negative number (decimal `{$negative_val}`), consider using the type `{$uint_ty}` for the literal and cast it to `{$int_ty}`
428
429
.help = consider using the type `{$suggestion_ty}` instead
429
430
430
431
lint_overflowing_int = literal out of range for `{$ty}`
Copy file name to clipboardExpand all lines: tests/ui/lint/type-overflow.stderr
+26-2
Original file line number
Diff line number
Diff line change
@@ -16,17 +16,33 @@ warning: literal out of range for `i8`
16
16
--> $DIR/type-overflow.rs:10:16
17
17
|
18
18
LL | let fail = 0b1000_0001i8;
19
-
| ^^^^^^^^^^^^^ help: consider using the type `u8` instead: `0b1000_0001u8`
19
+
| ^^^^^^^^^^^^^
20
20
|
21
21
= note: the literal `0b1000_0001i8` (decimal `129`) does not fit into the type `i8` and will become `-127i8`
22
+
help: consider using the type `u8` instead
23
+
|
24
+
LL | let fail = 0b1000_0001u8;
25
+
| ~~~~~~~~~~~~~
26
+
help: to use as a negative number (decimal `-127`), consider using the type `u8` for the literal and cast it to `i8`
27
+
|
28
+
LL | let fail = 0b1000_0001u8 as i8;
29
+
| ~~~~~~~~~~~~~~~~~~~
22
30
23
31
warning: literal out of range for `i64`
24
32
--> $DIR/type-overflow.rs:12:16
25
33
|
26
34
LL | let fail = 0x8000_0000_0000_0000i64;
27
-
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using the type `u64` instead: `0x8000_0000_0000_0000u64`
35
+
| ^^^^^^^^^^^^^^^^^^^^^^^^
28
36
|
29
37
= note: the literal `0x8000_0000_0000_0000i64` (decimal `9223372036854775808`) does not fit into the type `i64` and will become `-9223372036854775808i64`
38
+
help: consider using the type `u64` instead
39
+
|
40
+
LL | let fail = 0x8000_0000_0000_0000u64;
41
+
| ~~~~~~~~~~~~~~~~~~~~~~~~
42
+
help: to use as a negative number (decimal `-9223372036854775808`), consider using the type `u64` for the literal and cast it to `i64`
= note: the literal `0x8000_0000_0000_0000_0000_0000_0000_0000` (decimal `170141183460469231731687303715884105728`) does not fit into the type `i128` and will become `-170141183460469231731687303715884105728i128`
46
62
= help: consider using the type `u128` instead
63
+
help: to use as a negative number (decimal `-170141183460469231731687303715884105728`), consider using the type `u128` for the literal and cast it to `i128`
64
+
|
65
+
LL | let fail: i128 = 0x8000_0000_0000_0000_0000_0000_0000_0000u128 as i128;
0 commit comments