Add run-rustfix for short_circuit_statement test

This commit is contained in:
Philipp Hansch 2019-08-22 07:18:08 +02:00
parent 6d9ee9e5eb
commit 9bda1e2264
No known key found for this signature in database
GPG key ID: 82AA61CAA11397E6
3 changed files with 24 additions and 3 deletions

View file

@ -0,0 +1,18 @@
// run-rustfix
#![warn(clippy::short_circuit_statement)]
#![allow(clippy::nonminimal_bool)]
fn main() {
if f() { g(); }
if !f() { g(); }
if !(1 == 2) { g(); }
}
fn f() -> bool {
true
}
fn g() -> bool {
false
}

View file

@ -1,4 +1,7 @@
// run-rustfix
#![warn(clippy::short_circuit_statement)]
#![allow(clippy::nonminimal_bool)]
fn main() {
f() && g();

View file

@ -1,5 +1,5 @@
error: boolean short circuit operator in statement may be clearer using an explicit test
--> $DIR/short_circuit_statement.rs:4:5
--> $DIR/short_circuit_statement.rs:7:5
|
LL | f() && g();
| ^^^^^^^^^^^ help: replace it with: `if f() { g(); }`
@ -7,13 +7,13 @@ LL | f() && g();
= note: `-D clippy::short-circuit-statement` implied by `-D warnings`
error: boolean short circuit operator in statement may be clearer using an explicit test
--> $DIR/short_circuit_statement.rs:5:5
--> $DIR/short_circuit_statement.rs:8:5
|
LL | f() || g();
| ^^^^^^^^^^^ help: replace it with: `if !f() { g(); }`
error: boolean short circuit operator in statement may be clearer using an explicit test
--> $DIR/short_circuit_statement.rs:6:5
--> $DIR/short_circuit_statement.rs:9:5
|
LL | 1 == 2 || g();
| ^^^^^^^^^^^^^^ help: replace it with: `if !(1 == 2) { g(); }`