Closed
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
.