Code
fn main() {
let _: i32 = 0xC020660B;
}
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=2fdce59d2c87bae32e0270d3468da8d1
Current output
error: literal out of range for `i32`
--> src/main.rs:2:18
|
2 | let _: i32 = 0xC020660B;
| ^^^^^^^^^^
|
= note: the literal `0xC020660B` (decimal `3223348747`) does not fit into the type `i32` and will become `-1071618549i32`
= help: consider using the type `u32` instead
= note: `#[deny(overflowing_literals)]` on by default
help: to use as a negative number (decimal `-1071618549`), consider using the type `u32` for the literal and cast it to `i32`
|
2 | let _: i32 = 0xC020660Bu32 as i32;
| ++++++++++
Desired output
Recommend cast_signed() rather than the as cast. It has been around for a little while and is guarantees the conversion is same-size without loss of data.
Rust Version
1.99.0-nightly 2025-08-01
Code
Current output
Desired output
Recommend
cast_signed()rather than theascast. It has been around for a little while and is guarantees the conversion is same-size without loss of data.Rust Version