mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 05:03:21 +00:00
Add run-rustfix for short_circuit_statement test
This commit is contained in:
parent
6d9ee9e5eb
commit
9bda1e2264
3 changed files with 24 additions and 3 deletions
18
tests/ui/short_circuit_statement.fixed
Normal file
18
tests/ui/short_circuit_statement.fixed
Normal 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
|
||||
}
|
|
@ -1,4 +1,7 @@
|
|||
// run-rustfix
|
||||
|
||||
#![warn(clippy::short_circuit_statement)]
|
||||
#![allow(clippy::nonminimal_bool)]
|
||||
|
||||
fn main() {
|
||||
f() && g();
|
||||
|
|
|
@ -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(); }`
|
||||
|
|
Loading…
Reference in a new issue