about summary refs log tree commit diff
diff options
context:
space:
mode:
authorflip1995 <hello@philkrones.com>2019-08-26 19:35:25 +0200
committerflip1995 <hello@philkrones.com>2020-05-31 18:48:28 +0200
commit380d941a045dc213ae28807d74fc32d1b1841e22 (patch)
tree555a03edb455bec125d92bc484d54e6e1274e0ce
parent0ab823c509897ce2f516feb760fe1bf02cf77443 (diff)
downloadrust-380d941a045dc213ae28807d74fc32d1b1841e22.tar.gz
rust-380d941a045dc213ae28807d74fc32d1b1841e22.zip
Adapt stderr and fixed files
-rw-r--r--tests/ui/unit_arg.fixed29
-rw-r--r--tests/ui/unit_arg.rs10
-rw-r--r--tests/ui/unit_arg.stderr112
3 files changed, 118 insertions, 33 deletions
diff --git a/tests/ui/unit_arg.fixed b/tests/ui/unit_arg.fixed
index a739cf7ad81..67c6bdf8873 100644
--- a/tests/ui/unit_arg.fixed
+++ b/tests/ui/unit_arg.fixed
@@ -1,6 +1,6 @@
 // run-rustfix
 #![warn(clippy::unit_arg)]
-#![allow(unused_braces, clippy::no_effect, unused_must_use)]
+#![allow(clippy::no_effect, unused_must_use, unused_variables)]
 
 use std::fmt::Debug;
 
@@ -21,13 +21,21 @@ impl Bar {
 }
 
 fn bad() {
-    foo(());
-    foo(());
-    foo(());
-    foo(());
-    foo3((), 2, 2);
+    {}; foo(());
+    {
+        1;
+    }; foo(());
+    foo(1); foo(());
+    {
+        foo(1);
+        foo(2);
+    }; foo(());
+    {}; foo3((), 2, 2);
     let b = Bar;
-    b.bar(());
+    {
+        1;
+    }; b.bar(());
+    foo(0); foo(1); taking_multiple_units((), ());
 }
 
 fn ok() {
@@ -58,6 +66,13 @@ mod issue_2945 {
     }
 }
 
+#[allow(dead_code)]
+fn returning_expr() -> Option<()> {
+    foo(1); Some(())
+}
+
+fn taking_multiple_units(a: (), b: ()) {}
+
 fn main() {
     bad();
     ok();
diff --git a/tests/ui/unit_arg.rs b/tests/ui/unit_arg.rs
index d90c49f79de..c6e465b2e4c 100644
--- a/tests/ui/unit_arg.rs
+++ b/tests/ui/unit_arg.rs
@@ -1,6 +1,6 @@
 // run-rustfix
 #![warn(clippy::unit_arg)]
-#![allow(unused_braces, clippy::no_effect, unused_must_use)]
+#![allow(clippy::no_effect, unused_must_use, unused_variables)]
 
 use std::fmt::Debug;
 
@@ -35,6 +35,7 @@ fn bad() {
     b.bar({
         1;
     });
+    taking_multiple_units(foo(0), foo(1));
 }
 
 fn ok() {
@@ -65,6 +66,13 @@ mod issue_2945 {
     }
 }
 
+#[allow(dead_code)]
+fn returning_expr() -> Option<()> {
+    Some(foo(1))
+}
+
+fn taking_multiple_units(a: (), b: ()) {}
+
 fn main() {
     bad();
     ok();
diff --git a/tests/ui/unit_arg.stderr b/tests/ui/unit_arg.stderr
index 21ccc684ea9..ce9ab2f1271 100644
--- a/tests/ui/unit_arg.stderr
+++ b/tests/ui/unit_arg.stderr
@@ -1,79 +1,141 @@
 error: passing a unit value to a function
-  --> $DIR/unit_arg.rs:24:9
+  --> $DIR/unit_arg.rs:24:5
    |
 LL |     foo({});
-   |         ^^
+   |     ^^^^^^^
    |
    = note: `-D clippy::unit-arg` implied by `-D warnings`
-help: if you intended to pass a unit value, use a unit literal instead
+help: move the expressions in front of the call...
+   |
+LL |     {}; foo({});
+   |     ^^^
+help: ...and use unit literals instead
    |
 LL |     foo(());
    |         ^^
 
 error: passing a unit value to a function
-  --> $DIR/unit_arg.rs:25:9
+  --> $DIR/unit_arg.rs:25:5
    |
-LL |       foo({
-   |  _________^
+LL | /     foo({
 LL | |         1;
 LL | |     });
-   | |_____^
+   | |______^
+   |
+help: move the expressions in front of the call...
+   |
+LL |     {
+LL |         1;
+LL |     }; foo({
    |
-help: if you intended to pass a unit value, use a unit literal instead
+help: ...and use unit literals instead
    |
 LL |     foo(());
    |         ^^
 
 error: passing a unit value to a function
-  --> $DIR/unit_arg.rs:28:9
+  --> $DIR/unit_arg.rs:28:5
    |
 LL |     foo(foo(1));
-   |         ^^^^^^
+   |     ^^^^^^^^^^^
    |
-help: if you intended to pass a unit value, use a unit literal instead
+help: move the expressions in front of the call...
+   |
+LL |     foo(1); foo(foo(1));
+   |     ^^^^^^^
+help: ...and use unit literals instead
    |
 LL |     foo(());
    |         ^^
 
 error: passing a unit value to a function
-  --> $DIR/unit_arg.rs:29:9
+  --> $DIR/unit_arg.rs:29:5
    |
-LL |       foo({
-   |  _________^
+LL | /     foo({
 LL | |         foo(1);
 LL | |         foo(2);
 LL | |     });
-   | |_____^
+   | |______^
+   |
+help: move the expressions in front of the call...
+   |
+LL |     {
+LL |         foo(1);
+LL |         foo(2);
+LL |     }; foo({
    |
-help: if you intended to pass a unit value, use a unit literal instead
+help: ...and use unit literals instead
    |
 LL |     foo(());
    |         ^^
 
 error: passing a unit value to a function
-  --> $DIR/unit_arg.rs:33:10
+  --> $DIR/unit_arg.rs:33:5
    |
 LL |     foo3({}, 2, 2);
-   |          ^^
+   |     ^^^^^^^^^^^^^^
+   |
+help: move the expressions in front of the call...
    |
-help: if you intended to pass a unit value, use a unit literal instead
+LL |     {}; foo3({}, 2, 2);
+   |     ^^^
+help: ...and use unit literals instead
    |
 LL |     foo3((), 2, 2);
    |          ^^
 
 error: passing a unit value to a function
-  --> $DIR/unit_arg.rs:35:11
+  --> $DIR/unit_arg.rs:35:5
    |
-LL |       b.bar({
-   |  ___________^
+LL | /     b.bar({
 LL | |         1;
 LL | |     });
-   | |_____^
+   | |______^
+   |
+help: move the expressions in front of the call...
    |
-help: if you intended to pass a unit value, use a unit literal instead
+LL |     {
+LL |         1;
+LL |     }; b.bar({
+   |
+help: ...and use unit literals instead
    |
 LL |     b.bar(());
    |           ^^
 
-error: aborting due to 6 previous errors
+error: passing a unit value to a function
+  --> $DIR/unit_arg.rs:38:5
+   |
+LL |     taking_multiple_units(foo(0), foo(1));
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: move the expressions in front of the call...
+   |
+LL |     foo(0); foo(1); taking_multiple_units(foo(0), foo(1));
+   |     ^^^^^^^^^^^^^^^
+help: ...and use unit literals instead
+   |
+LL |     taking_multiple_units((), foo(1));
+   |                           ^^
+help: ...and use unit literals instead
+   |
+LL |     taking_multiple_units(foo(0), ());
+   |                                   ^^
+
+error: passing a unit value to a function
+  --> $DIR/unit_arg.rs:71:5
+   |
+LL |     Some(foo(1))
+   |     ^^^^^^^^^^^^
+   |
+help: move the expressions in front of the call...
+   |
+LL |     foo(1); Some(foo(1))
+   |     ^^^^^^^
+help: ...and use unit literals instead
+   |
+LL |     Some(())
+   |          ^^
+
+error: aborting due to 8 previous errors