diff options
| author | Philipp Hansch <dev@phansch.net> | 2019-08-18 09:24:30 +0200 |
|---|---|---|
| committer | Philipp Hansch <dev@phansch.net> | 2019-08-28 07:23:23 +0200 |
| commit | b6e87c6ae35febbf85b3834f41e4628e4088ccb4 (patch) | |
| tree | 43bec6c3a8633177e18452827d88537ed314ab00 | |
| parent | cb341c8090868dbcc645573ee2606007e45a9c98 (diff) | |
| download | rust-b6e87c6ae35febbf85b3834f41e4628e4088ccb4.tar.gz rust-b6e87c6ae35febbf85b3834f41e4628e4088ccb4.zip | |
Add run-rustfix for int_plus_one test
| -rw-r--r-- | tests/ui/int_plus_one.fixed | 17 | ||||
| -rw-r--r-- | tests/ui/int_plus_one.rs | 14 | ||||
| -rw-r--r-- | tests/ui/int_plus_one.stderr | 40 |
3 files changed, 45 insertions, 26 deletions
diff --git a/tests/ui/int_plus_one.fixed b/tests/ui/int_plus_one.fixed new file mode 100644 index 00000000000..642830f24f5 --- /dev/null +++ b/tests/ui/int_plus_one.fixed @@ -0,0 +1,17 @@ +// run-rustfix + +#[allow(clippy::no_effect, clippy::unnecessary_operation)] +#[warn(clippy::int_plus_one)] +fn main() { + let x = 1i32; + let y = 0i32; + + let _ = x > y; + let _ = y < x; + + let _ = x > y; + let _ = y < x; + + let _ = x > y; // should be ok + let _ = y < x; // should be ok +} diff --git a/tests/ui/int_plus_one.rs b/tests/ui/int_plus_one.rs index 42d8045244f..0755a0c79d2 100644 --- a/tests/ui/int_plus_one.rs +++ b/tests/ui/int_plus_one.rs @@ -1,15 +1,17 @@ +// run-rustfix + #[allow(clippy::no_effect, clippy::unnecessary_operation)] #[warn(clippy::int_plus_one)] fn main() { let x = 1i32; let y = 0i32; - x >= y + 1; - y + 1 <= x; + let _ = x >= y + 1; + let _ = y + 1 <= x; - x - 1 >= y; - y <= x - 1; + let _ = x - 1 >= y; + let _ = y <= x - 1; - x > y; // should be ok - y < x; // should be ok + let _ = x > y; // should be ok + let _ = y < x; // should be ok } diff --git a/tests/ui/int_plus_one.stderr b/tests/ui/int_plus_one.stderr index 4a783e50c67..d4ea0725fef 100644 --- a/tests/ui/int_plus_one.stderr +++ b/tests/ui/int_plus_one.stderr @@ -1,44 +1,44 @@ error: Unnecessary `>= y + 1` or `x - 1 >=` - --> $DIR/int_plus_one.rs:7:5 + --> $DIR/int_plus_one.rs:9:13 | -LL | x >= y + 1; - | ^^^^^^^^^^ +LL | let _ = x >= y + 1; + | ^^^^^^^^^^ | = note: `-D clippy::int-plus-one` implied by `-D warnings` help: change `>= y + 1` to `> y` as shown | -LL | x > y; - | ^^^^^ +LL | let _ = x > y; + | ^^^^^ error: Unnecessary `>= y + 1` or `x - 1 >=` - --> $DIR/int_plus_one.rs:8:5 + --> $DIR/int_plus_one.rs:10:13 | -LL | y + 1 <= x; - | ^^^^^^^^^^ +LL | let _ = y + 1 <= x; + | ^^^^^^^^^^ help: change `>= y + 1` to `> y` as shown | -LL | y < x; - | ^^^^^ +LL | let _ = y < x; + | ^^^^^ error: Unnecessary `>= y + 1` or `x - 1 >=` - --> $DIR/int_plus_one.rs:10:5 + --> $DIR/int_plus_one.rs:12:13 | -LL | x - 1 >= y; - | ^^^^^^^^^^ +LL | let _ = x - 1 >= y; + | ^^^^^^^^^^ help: change `>= y + 1` to `> y` as shown | -LL | x > y; - | ^^^^^ +LL | let _ = x > y; + | ^^^^^ error: Unnecessary `>= y + 1` or `x - 1 >=` - --> $DIR/int_plus_one.rs:11:5 + --> $DIR/int_plus_one.rs:13:13 | -LL | y <= x - 1; - | ^^^^^^^^^^ +LL | let _ = y <= x - 1; + | ^^^^^^^^^^ help: change `>= y + 1` to `> y` as shown | -LL | y < x; - | ^^^^^ +LL | let _ = y < x; + | ^^^^^ error: aborting due to 4 previous errors |
