about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tests/ui/unit_arg.rs2
-rw-r--r--tests/ui/unit_arg.stderr46
-rw-r--r--tests/ui/unit_arg_empty_blocks.rs26
-rw-r--r--tests/ui/unit_arg_empty_blocks.stderr51
4 files changed, 85 insertions, 40 deletions
diff --git a/tests/ui/unit_arg.rs b/tests/ui/unit_arg.rs
index 7d1b99fedc9..2992abae775 100644
--- a/tests/ui/unit_arg.rs
+++ b/tests/ui/unit_arg.rs
@@ -20,7 +20,6 @@ impl Bar {
 }
 
 fn bad() {
-    foo({});
     foo({
         1;
     });
@@ -29,7 +28,6 @@ fn bad() {
         foo(1);
         foo(2);
     });
-    foo3({}, 2, 2);
     let b = Bar;
     b.bar({
         1;
diff --git a/tests/ui/unit_arg.stderr b/tests/ui/unit_arg.stderr
index 145b3c62b06..56f6a855dfa 100644
--- a/tests/ui/unit_arg.stderr
+++ b/tests/ui/unit_arg.stderr
@@ -1,27 +1,12 @@
 error: passing a unit value to a function
   --> $DIR/unit_arg.rs:23:5
    |
-LL |     foo({});
-   |     ^^^^^^^
-   |
-   = note: `-D clippy::unit-arg` implied by `-D warnings`
-help: move the expression in front of the call...
-   |
-LL |     {};
-   |
-help: ...and use a unit literal instead
-   |
-LL |     foo(());
-   |         ^^
-
-error: passing a unit value to a function
-  --> $DIR/unit_arg.rs:24:5
-   |
 LL | /     foo({
 LL | |         1;
 LL | |     });
    | |______^
    |
+   = note: `-D clippy::unit-arg` implied by `-D warnings`
 help: remove the semicolon from the last statement in the block
    |
 LL |         1
@@ -38,7 +23,7 @@ LL |     foo(());
    |         ^^
 
 error: passing a unit value to a function
-  --> $DIR/unit_arg.rs:27:5
+  --> $DIR/unit_arg.rs:26:5
    |
 LL |     foo(foo(1));
    |     ^^^^^^^^^^^
@@ -53,7 +38,7 @@ LL |     foo(());
    |         ^^
 
 error: passing a unit value to a function
-  --> $DIR/unit_arg.rs:28:5
+  --> $DIR/unit_arg.rs:27:5
    |
 LL | /     foo({
 LL | |         foo(1);
@@ -80,21 +65,6 @@ LL |     foo(());
 error: passing a unit value to a function
   --> $DIR/unit_arg.rs:32:5
    |
-LL |     foo3({}, 2, 2);
-   |     ^^^^^^^^^^^^^^
-   |
-help: move the expression in front of the call...
-   |
-LL |     {};
-   |
-help: ...and use a unit literal instead
-   |
-LL |     foo3((), 2, 2);
-   |          ^^
-
-error: passing a unit value to a function
-  --> $DIR/unit_arg.rs:34:5
-   |
 LL | /     b.bar({
 LL | |         1;
 LL | |     });
@@ -116,7 +86,7 @@ LL |     b.bar(());
    |           ^^
 
 error: passing unit values to a function
-  --> $DIR/unit_arg.rs:37:5
+  --> $DIR/unit_arg.rs:35:5
    |
 LL |     taking_multiple_units(foo(0), foo(1));
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -132,7 +102,7 @@ LL |     taking_multiple_units((), ());
    |                           ^^  ^^
 
 error: passing unit values to a function
-  --> $DIR/unit_arg.rs:38:5
+  --> $DIR/unit_arg.rs:36:5
    |
 LL | /     taking_multiple_units(foo(0), {
 LL | |         foo(1);
@@ -158,7 +128,7 @@ LL |     taking_multiple_units((), ());
    |                           ^^  ^^
 
 error: passing unit values to a function
-  --> $DIR/unit_arg.rs:42:5
+  --> $DIR/unit_arg.rs:40:5
    |
 LL | /     taking_multiple_units(
 LL | |         {
@@ -193,7 +163,7 @@ LL |         (),
    |
 
 error: passing a unit value to a function
-  --> $DIR/unit_arg.rs:84:5
+  --> $DIR/unit_arg.rs:82:5
    |
 LL |     Some(foo(1))
    |     ^^^^^^^^^^^^
@@ -207,5 +177,5 @@ help: ...and use a unit literal instead
 LL |     Some(())
    |          ^^
 
-error: aborting due to 10 previous errors
+error: aborting due to 8 previous errors
 
diff --git a/tests/ui/unit_arg_empty_blocks.rs b/tests/ui/unit_arg_empty_blocks.rs
new file mode 100644
index 00000000000..18a31eb3dee
--- /dev/null
+++ b/tests/ui/unit_arg_empty_blocks.rs
@@ -0,0 +1,26 @@
+#![warn(clippy::unit_arg)]
+#![allow(clippy::no_effect, unused_must_use, unused_variables)]
+
+use std::fmt::Debug;
+
+fn foo<T: Debug>(t: T) {
+    println!("{:?}", t);
+}
+
+fn foo3<T1: Debug, T2: Debug, T3: Debug>(t1: T1, t2: T2, t3: T3) {
+    println!("{:?}, {:?}, {:?}", t1, t2, t3);
+}
+
+fn bad() {
+    foo({});
+    foo3({}, 2, 2);
+    taking_two_units({}, foo(0));
+    taking_three_units({}, foo(0), foo(1));
+}
+
+fn taking_two_units(a: (), b: ()) {}
+fn taking_three_units(a: (), b: (), c: ()) {}
+
+fn main() {
+    bad();
+}
diff --git a/tests/ui/unit_arg_empty_blocks.stderr b/tests/ui/unit_arg_empty_blocks.stderr
new file mode 100644
index 00000000000..bb58483584b
--- /dev/null
+++ b/tests/ui/unit_arg_empty_blocks.stderr
@@ -0,0 +1,51 @@
+error: passing a unit value to a function
+  --> $DIR/unit_arg_empty_blocks.rs:15:5
+   |
+LL |     foo({});
+   |     ^^^^--^
+   |         |
+   |         help: use a unit literal instead: `()`
+   |
+   = note: `-D clippy::unit-arg` implied by `-D warnings`
+
+error: passing a unit value to a function
+  --> $DIR/unit_arg_empty_blocks.rs:16:5
+   |
+LL |     foo3({}, 2, 2);
+   |     ^^^^^--^^^^^^^
+   |          |
+   |          help: use a unit literal instead: `()`
+
+error: passing unit values to a function
+  --> $DIR/unit_arg_empty_blocks.rs:17:5
+   |
+LL |     taking_two_units({}, foo(0));
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: move the expression in front of the call...
+   |
+LL |     foo(0);
+   |
+help: ...and use unit literals instead
+   |
+LL |     taking_two_units((), ());
+   |                      ^^  ^^
+
+error: passing unit values to a function
+  --> $DIR/unit_arg_empty_blocks.rs:18:5
+   |
+LL |     taking_three_units({}, foo(0), foo(1));
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: move the expressions in front of the call...
+   |
+LL |     foo(0);
+LL |     foo(1);
+   |
+help: ...and use unit literals instead
+   |
+LL |     taking_three_units((), (), ());
+   |                        ^^  ^^  ^^
+
+error: aborting due to 4 previous errors
+