blob: 29ecbb9ad2adb7bc1f82c719f08894959384998a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#![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 };
}
|