about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/unit_arg_fixable.fixed8
-rw-r--r--tests/ui/unit_arg_fixable.rs7
-rw-r--r--tests/ui/unit_arg_fixable.stderr14
3 files changed, 28 insertions, 1 deletions
diff --git a/tests/ui/unit_arg_fixable.fixed b/tests/ui/unit_arg_fixable.fixed
index 3ef6a953c72..03353a14081 100644
--- a/tests/ui/unit_arg_fixable.fixed
+++ b/tests/ui/unit_arg_fixable.fixed
@@ -67,4 +67,12 @@ fn issue14857() {
     mac!(empty_block);
     fn_take_unit(());
     //~^ unit_arg
+
+    fn def<T: Default>() -> T {
+        Default::default()
+    }
+
+    let _: () = def();
+    fn_take_unit(());
+    //~^ unit_arg
 }
diff --git a/tests/ui/unit_arg_fixable.rs b/tests/ui/unit_arg_fixable.rs
index 097d51e9481..03fd96efdf9 100644
--- a/tests/ui/unit_arg_fixable.rs
+++ b/tests/ui/unit_arg_fixable.rs
@@ -61,4 +61,11 @@ fn issue14857() {
     //~^ unit_arg
     fn_take_unit(mac!(empty_block));
     //~^ unit_arg
+
+    fn def<T: Default>() -> T {
+        Default::default()
+    }
+
+    fn_take_unit(def());
+    //~^ unit_arg
 }
diff --git a/tests/ui/unit_arg_fixable.stderr b/tests/ui/unit_arg_fixable.stderr
index 94063f02a3f..ccd5aa8322f 100644
--- a/tests/ui/unit_arg_fixable.stderr
+++ b/tests/ui/unit_arg_fixable.stderr
@@ -94,5 +94,17 @@ LL ~     mac!(empty_block);
 LL ~     fn_take_unit(());
    |
 
-error: aborting due to 9 previous errors
+error: passing a unit value to a function
+  --> tests/ui/unit_arg_fixable.rs:69:5
+   |
+LL |     fn_take_unit(def());
+   |     ^^^^^^^^^^^^^^^^^^^
+   |
+help: move the expression in front of the call and replace it with the unit literal `()`
+   |
+LL ~     let _: () = def();
+LL ~     fn_take_unit(());
+   |
+
+error: aborting due to 10 previous errors