-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.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
fn main() {
assert_eq!(i8::min_value(), -128i8);
println!("{}", -128i8.saturating_sub(-1));
}
Errors:
Compiling playground v0.0.1 (/playground)
error: literal out of range for `i8`
--> src/main.rs:3:21
|
3 | println!("{}", -128i8.saturating_sub(-1));
| ^^^^^
|
= note: #[deny(overflowing_literals)] on by default
error: aborting due to previous error
error: Could not compile `playground`.
To learn more, run the command again with --verbose.
-128
is not out of range for i8
, however the lint claims it is. This doesn't happen when printing a plain -128i8
without .saturating_sub
. It also doesn't happen when the -128i8
is passed as arg to .saturating_sub
.
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.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.