blob: fb0f0da772c9f47025ebae5e99bdcd53908c30b9 (
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
error: inverted arithmetic check before subtraction
--> tests/ui/manual_arithmetic_check-2.rs:9:23
|
LL | let result = if a > b { b - a } else { 0 };
| ^ ----- help: try replacing it with: `a - b`
|
note: this subtraction underflows when `b < a`
--> tests/ui/manual_arithmetic_check-2.rs:9:29
|
LL | let result = if a > b { b - a } else { 0 };
| ^^^^^
= note: `#[deny(clippy::inverted_saturating_sub)]` on by default
error: inverted arithmetic check before subtraction
--> tests/ui/manual_arithmetic_check-2.rs:12:23
|
LL | let result = if b < a { b - a } else { 0 };
| ^ ----- help: try replacing it with: `a - b`
|
note: this subtraction underflows when `b < a`
--> tests/ui/manual_arithmetic_check-2.rs:12:29
|
LL | let result = if b < a { b - a } else { 0 };
| ^^^^^
error: inverted arithmetic check before subtraction
--> tests/ui/manual_arithmetic_check-2.rs:15:23
|
LL | let result = if a > b { 0 } else { a - b };
| ^ ----- help: try replacing it with: `b - a`
|
note: this subtraction underflows when `a < b`
--> tests/ui/manual_arithmetic_check-2.rs:15:40
|
LL | let result = if a > b { 0 } else { a - b };
| ^^^^^
error: inverted arithmetic check before subtraction
--> tests/ui/manual_arithmetic_check-2.rs:18:23
|
LL | let result = if a >= b { 0 } else { a - b };
| ^^ ----- help: try replacing it with: `b - a`
|
note: this subtraction underflows when `a < b`
--> tests/ui/manual_arithmetic_check-2.rs:18:41
|
LL | let result = if a >= b { 0 } else { a - b };
| ^^^^^
error: inverted arithmetic check before subtraction
--> tests/ui/manual_arithmetic_check-2.rs:21:23
|
LL | let result = if b < a { 0 } else { a - b };
| ^ ----- help: try replacing it with: `b - a`
|
note: this subtraction underflows when `a < b`
--> tests/ui/manual_arithmetic_check-2.rs:21:40
|
LL | let result = if b < a { 0 } else { a - b };
| ^^^^^
error: inverted arithmetic check before subtraction
--> tests/ui/manual_arithmetic_check-2.rs:24:23
|
LL | let result = if b <= a { 0 } else { a - b };
| ^^ ----- help: try replacing it with: `b - a`
|
note: this subtraction underflows when `a < b`
--> tests/ui/manual_arithmetic_check-2.rs:24:41
|
LL | let result = if b <= a { 0 } else { a - b };
| ^^^^^
error: inverted arithmetic check before subtraction
--> tests/ui/manual_arithmetic_check-2.rs:27:27
|
LL | let result = if b * 2 <= a { 0 } else { a - b * 2 };
| ^^ --------- help: try replacing it with: `b * 2 - a`
|
note: this subtraction underflows when `a < b * 2`
--> tests/ui/manual_arithmetic_check-2.rs:27:45
|
LL | let result = if b * 2 <= a { 0 } else { a - b * 2 };
| ^^^^^^^^^
error: inverted arithmetic check before subtraction
--> tests/ui/manual_arithmetic_check-2.rs:30:23
|
LL | let result = if b <= a * 2 { 0 } else { a * 2 - b };
| ^^ --------- help: try replacing it with: `b - a * 2`
|
note: this subtraction underflows when `a * 2 < b`
--> tests/ui/manual_arithmetic_check-2.rs:30:45
|
LL | let result = if b <= a * 2 { 0 } else { a * 2 - b };
| ^^^^^^^^^
error: inverted arithmetic check before subtraction
--> tests/ui/manual_arithmetic_check-2.rs:33:27
|
LL | let result = if b + 3 <= a + 2 { 0 } else { (a + 2) - (b + 3) };
| ^^ ----------------- help: try replacing it with: `b + 3 - (a + 2)`
|
note: this subtraction underflows when `a + 2 < b + 3`
--> tests/ui/manual_arithmetic_check-2.rs:33:49
|
LL | let result = if b + 3 <= a + 2 { 0 } else { (a + 2) - (b + 3) };
| ^^^^^^^^^^^^^^^^^
error: aborting due to 9 previous errors
|