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 rust-lang#136424 - 11happy:overflow.hex.fix, r=fmease
fix: overflowing bin hex
**Overview:**
- This PR fixesrust-lang#135404.
**Testing**
- Tested the updated functionality.
- previously emitted diagnostics:
```bash
error: literal out of range for `i32`
--> src/main.rs:2:9
|
2 | _ = 0x8FFF_FFFF_FFFF_FFFE;
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: the literal `0x8FFF_FFFF_FFFF_FFFE` (decimal `10376293541461622782`) does not fit into the type `i32` and will become `-2i32`
= help: consider using the type `i128` instead
= note: `#[deny(overflowing_literals)]` on by default
help: to use as a negative number (decimal `-2`), consider using the type `u32` for the literal and cast it to `i32`
|
2 | _ = 0x8FFF_FFFF_FFFF_FFFEu32 as i32;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
- current diagnostics:
```bash
error: literal out of range for `i32`
--> ../temp.rs:2:13
|
2 | let x = 0x8FFF_FFFF_FFFF_FFFE;
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: the literal `0x8FFF_FFFF_FFFF_FFFE` (decimal `10376293541461622782`) does not fit into the type `i32` and will become `-2i32`
= help: consider using the type `u64` instead
= note: `#[deny(overflowing_literals)]` on by default
help: to use as a negative number (decimal `-2`), consider using the type `u64` for the literal and cast it to `i32`
|
2 | let x = 0x8FFF_FFFF_FFFF_FFFEu64 as i32;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
Copy file name to clipboardexpand all lines: tests/ui/lint/type-overflow.stderr
+16-3
Original file line number
Diff line number
Diff line change
@@ -112,9 +112,9 @@ LL | let fail = 0x8FFF_FFFF_FFFF_FFFE;
112
112
|
113
113
= note: the literal `0x8FFF_FFFF_FFFF_FFFE` (decimal `10376293541461622782`) does not fit into the type `i32` and will become `-2i32`
114
114
= 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`
116
116
|
117
-
LL | let fail = 0x8FFF_FFFF_FFFF_FFFEu32 as i32;
117
+
LL | let fail = 0x8FFF_FFFF_FFFF_FFFEu64 as i32;
118
118
| ++++++++++
119
119
120
120
warning: literal out of range for `i8`
@@ -126,5 +126,18 @@ LL | let fail = -0b1111_1111i8;
126
126
= note: the literal `0b1111_1111i8` (decimal `255`) does not fit into the type `i8`
127
127
= note: and the value `-0b1111_1111i8` will become `1i8`
128
128
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;
0 commit comments