Skip to content

Commit b6e87c6

Browse files
committed
Add run-rustfix for int_plus_one test
1 parent cb341c8 commit b6e87c6

File tree

3 files changed

+45
-26
lines changed

3 files changed

+45
-26
lines changed

tests/ui/int_plus_one.fixed

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
}

tests/ui/int_plus_one.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1+
// run-rustfix
2+
13
#[allow(clippy::no_effect, clippy::unnecessary_operation)]
24
#[warn(clippy::int_plus_one)]
35
fn main() {
46
let x = 1i32;
57
let y = 0i32;
68

7-
x >= y + 1;
8-
y + 1 <= x;
9+
let _ = x >= y + 1;
10+
let _ = y + 1 <= x;
911

10-
x - 1 >= y;
11-
y <= x - 1;
12+
let _ = x - 1 >= y;
13+
let _ = y <= x - 1;
1214

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
1517
}

tests/ui/int_plus_one.stderr

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
error: Unnecessary `>= y + 1` or `x - 1 >=`
2-
--> $DIR/int_plus_one.rs:7:5
2+
--> $DIR/int_plus_one.rs:9:13
33
|
4-
LL | x >= y + 1;
5-
| ^^^^^^^^^^
4+
LL | let _ = x >= y + 1;
5+
| ^^^^^^^^^^
66
|
77
= note: `-D clippy::int-plus-one` implied by `-D warnings`
88
help: change `>= y + 1` to `> y` as shown
99
|
10-
LL | x > y;
11-
| ^^^^^
10+
LL | let _ = x > y;
11+
| ^^^^^
1212

1313
error: Unnecessary `>= y + 1` or `x - 1 >=`
14-
--> $DIR/int_plus_one.rs:8:5
14+
--> $DIR/int_plus_one.rs:10:13
1515
|
16-
LL | y + 1 <= x;
17-
| ^^^^^^^^^^
16+
LL | let _ = y + 1 <= x;
17+
| ^^^^^^^^^^
1818
help: change `>= y + 1` to `> y` as shown
1919
|
20-
LL | y < x;
21-
| ^^^^^
20+
LL | let _ = y < x;
21+
| ^^^^^
2222

2323
error: Unnecessary `>= y + 1` or `x - 1 >=`
24-
--> $DIR/int_plus_one.rs:10:5
24+
--> $DIR/int_plus_one.rs:12:13
2525
|
26-
LL | x - 1 >= y;
27-
| ^^^^^^^^^^
26+
LL | let _ = x - 1 >= y;
27+
| ^^^^^^^^^^
2828
help: change `>= y + 1` to `> y` as shown
2929
|
30-
LL | x > y;
31-
| ^^^^^
30+
LL | let _ = x > y;
31+
| ^^^^^
3232

3333
error: Unnecessary `>= y + 1` or `x - 1 >=`
34-
--> $DIR/int_plus_one.rs:11:5
34+
--> $DIR/int_plus_one.rs:13:13
3535
|
36-
LL | y <= x - 1;
37-
| ^^^^^^^^^^
36+
LL | let _ = y <= x - 1;
37+
| ^^^^^^^^^^
3838
help: change `>= y + 1` to `> y` as shown
3939
|
40-
LL | y < x;
41-
| ^^^^^
40+
LL | let _ = y < x;
41+
| ^^^^^
4242

4343
error: aborting due to 4 previous errors
4444

0 commit comments

Comments
 (0)