mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-26 22:50:56 +00:00
2b562dece6
Revert "Fix span issue on `implicit_saturating_sub`"
This reverts commit 140a1275f2
.
24 lines
687 B
Rust
24 lines
687 B
Rust
#![warn(clippy::implicit_saturating_sub, clippy::inverted_saturating_sub)]
|
|
#![allow(clippy::if_same_then_else)]
|
|
|
|
fn main() {
|
|
let a = 12u32;
|
|
let b = 13u32;
|
|
let c = 8u32;
|
|
|
|
let result = a.saturating_sub(b);
|
|
//~^ ERROR: manual arithmetic check found
|
|
let result = a.saturating_sub(b);
|
|
//~^ ERROR: manual arithmetic check found
|
|
|
|
let result = a.saturating_sub(b);
|
|
//~^ ERROR: manual arithmetic check found
|
|
let result = a.saturating_sub(b);
|
|
//~^ ERROR: manual arithmetic check found
|
|
|
|
// Should not warn!
|
|
let result = if a > b { a - b } else { a - c };
|
|
|
|
// Just to check it won't break clippy.
|
|
let result = if b > a { 0 } else { 0 };
|
|
}
|