File tree Expand file tree Collapse file tree 3 files changed +45
-26
lines changed Expand file tree Collapse file tree 3 files changed +45
-26
lines changed Original file line number Diff line number Diff line change
1
+ // run-rustfix
2
+
3
+ #[allow(clippy::no_effect, clippy::unnecessary_operation)]
4
+ #[warn(clippy::int_plus_one)]
5
+ fn main() {
6
+ let x = 1i32;
7
+ let y = 0i32;
8
+
9
+ let _ = x > y;
10
+ let _ = y < x;
11
+
12
+ let _ = x > y;
13
+ let _ = y < x;
14
+
15
+ let _ = x > y; // should be ok
16
+ let _ = y < x; // should be ok
17
+ }
Original file line number Diff line number Diff line change
1
+ // run-rustfix
2
+
1
3
#[ allow( clippy:: no_effect, clippy:: unnecessary_operation) ]
2
4
#[ warn( clippy:: int_plus_one) ]
3
5
fn main ( ) {
4
6
let x = 1i32 ;
5
7
let y = 0i32 ;
6
8
7
- x >= y + 1 ;
8
- y + 1 <= x;
9
+ let _ = x >= y + 1 ;
10
+ let _ = y + 1 <= x;
9
11
10
- x - 1 >= y;
11
- y <= x - 1 ;
12
+ let _ = x - 1 >= y;
13
+ let _ = y <= x - 1 ;
12
14
13
- x > y; // should be ok
14
- y < x; // should be ok
15
+ let _ = x > y; // should be ok
16
+ let _ = y < x; // should be ok
15
17
}
Original file line number Diff line number Diff line change 1
1
error: Unnecessary `>= y + 1` or `x - 1 >=`
2
- --> $DIR/int_plus_one.rs:7:5
2
+ --> $DIR/int_plus_one.rs:9:13
3
3
|
4
- LL | x >= y + 1;
5
- | ^^^^^^^^^^
4
+ LL | let _ = x >= y + 1;
5
+ | ^^^^^^^^^^
6
6
|
7
7
= note: `-D clippy::int-plus-one` implied by `-D warnings`
8
8
help: change `>= y + 1` to `> y` as shown
9
9
|
10
- LL | x > y;
11
- | ^^^^^
10
+ LL | let _ = x > y;
11
+ | ^^^^^
12
12
13
13
error: Unnecessary `>= y + 1` or `x - 1 >=`
14
- --> $DIR/int_plus_one.rs:8:5
14
+ --> $DIR/int_plus_one.rs:10:13
15
15
|
16
- LL | y + 1 <= x;
17
- | ^^^^^^^^^^
16
+ LL | let _ = y + 1 <= x;
17
+ | ^^^^^^^^^^
18
18
help: change `>= y + 1` to `> y` as shown
19
19
|
20
- LL | y < x;
21
- | ^^^^^
20
+ LL | let _ = y < x;
21
+ | ^^^^^
22
22
23
23
error: Unnecessary `>= y + 1` or `x - 1 >=`
24
- --> $DIR/int_plus_one.rs:10:5
24
+ --> $DIR/int_plus_one.rs:12:13
25
25
|
26
- LL | x - 1 >= y;
27
- | ^^^^^^^^^^
26
+ LL | let _ = x - 1 >= y;
27
+ | ^^^^^^^^^^
28
28
help: change `>= y + 1` to `> y` as shown
29
29
|
30
- LL | x > y;
31
- | ^^^^^
30
+ LL | let _ = x > y;
31
+ | ^^^^^
32
32
33
33
error: Unnecessary `>= y + 1` or `x - 1 >=`
34
- --> $DIR/int_plus_one.rs:11:5
34
+ --> $DIR/int_plus_one.rs:13:13
35
35
|
36
- LL | y <= x - 1;
37
- | ^^^^^^^^^^
36
+ LL | let _ = y <= x - 1;
37
+ | ^^^^^^^^^^
38
38
help: change `>= y + 1` to `> y` as shown
39
39
|
40
- LL | y < x;
41
- | ^^^^^
40
+ LL | let _ = y < x;
41
+ | ^^^^^
42
42
43
43
error: aborting due to 4 previous errors
44
44
You can’t perform that action at this time.
0 commit comments