about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPhilipp Hansch <dev@phansch.net>2019-08-22 07:18:08 +0200
committerPhilipp Hansch <dev@phansch.net>2019-08-22 07:21:29 +0200
commit9bda1e2264f68072bf0ca0cc2b0fa01b08ba37df (patch)
treedef4d81ada4f060a7e87d86be7e07fb24616b2fc
parent6d9ee9e5eba16612bb2fc253f77673b823812b8a (diff)
downloadrust-9bda1e2264f68072bf0ca0cc2b0fa01b08ba37df.tar.gz
rust-9bda1e2264f68072bf0ca0cc2b0fa01b08ba37df.zip
Add run-rustfix for short_circuit_statement test
-rw-r--r--tests/ui/short_circuit_statement.fixed18
-rw-r--r--tests/ui/short_circuit_statement.rs3
-rw-r--r--tests/ui/short_circuit_statement.stderr6
3 files changed, 24 insertions, 3 deletions
diff --git a/tests/ui/short_circuit_statement.fixed b/tests/ui/short_circuit_statement.fixed
new file mode 100644
index 00000000000..af0a397bd1a
--- /dev/null
+++ b/tests/ui/short_circuit_statement.fixed
@@ -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
+}
diff --git a/tests/ui/short_circuit_statement.rs b/tests/ui/short_circuit_statement.rs
index 84e736fe080..73a55bf1f5e 100644
--- a/tests/ui/short_circuit_statement.rs
+++ b/tests/ui/short_circuit_statement.rs
@@ -1,4 +1,7 @@
+// run-rustfix
+
 #![warn(clippy::short_circuit_statement)]
+#![allow(clippy::nonminimal_bool)]
 
 fn main() {
     f() && g();
diff --git a/tests/ui/short_circuit_statement.stderr b/tests/ui/short_circuit_statement.stderr
index a526766f698..0a3f60c3d13 100644
--- a/tests/ui/short_circuit_statement.stderr
+++ b/tests/ui/short_circuit_statement.stderr
@@ -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(); }`