-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Closed
Copy link
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
I tried this code:
fn main() {
let x: i32 = 0b1000_0000_0000_0000_0000_0000_0000_0000i32;
println!("{}", x);
}
I expected the code to compile since its i am assigning into x binary representation of i32::MIN, instead the compiler throws an error.
Meta
rustc --version --verbose
:
1.67.1
Backtrace
Compiling playground v0.0.1 (/playground)
error: literal out of range for `i32`
--> src/main.rs:2:18
|
2 | let x: i32 = 0b1000_0000_0000_0000_0000_0000_0000_0000i32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using the type `u32` instead: `0b1000_0000_0000_0000_0000_0000_0000_0000u32`
|
= note: the literal `0b1000_0000_0000_0000_0000_0000_0000_0000i32` (decimal `2147483648`) does not fit into the type `i32` and will become `-2147483648i32`
= note: `#[deny(overflowing_literals)]` on by default
error: could not compile `playground` due to previous error
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.