about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMarc Dominik Migge <marcmigge@gmx.net>2021-02-25 22:03:11 +0100
committerMarc Dominik Migge <marcmigge@gmx.net>2021-02-25 22:03:11 +0100
commitcbe6eec3e67347af130769ad4a3bd2168997b411 (patch)
tree7c69b12261eeac296b1af5a8181b945efe4662a0
parent9fe9d94abda8d2698d1dede6961007e0026760ea (diff)
downloadrust-cbe6eec3e67347af130769ad4a3bd2168997b411.tar.gz
rust-cbe6eec3e67347af130769ad4a3bd2168997b411.zip
Add original test case from issue
-rw-r--r--tests/ui/unit_arg.rs21
-rw-r--r--tests/ui/unit_arg.stderr20
2 files changed, 31 insertions, 10 deletions
diff --git a/tests/ui/unit_arg.rs b/tests/ui/unit_arg.rs
index 5ea2e5d65c5..938cc3c7859 100644
--- a/tests/ui/unit_arg.rs
+++ b/tests/ui/unit_arg.rs
@@ -31,6 +31,26 @@ fn baz<T: Debug>(t: T) {
     foo(t);
 }
 
+trait Tr {
+    type Args;
+    fn do_it(args: Self::Args);
+}
+
+struct A;
+impl Tr for A {
+    type Args = ();
+    fn do_it(_: Self::Args) {}
+}
+
+struct B;
+impl Tr for B {
+    type Args = <A as Tr>::Args;
+
+    fn do_it(args: Self::Args) {
+        A::do_it(args)
+    }
+}
+
 fn bad() {
     foo({
         1;
@@ -78,6 +98,7 @@ fn ok() {
     let named_unit_arg = ();
     foo(named_unit_arg);
     baz(());
+    B::do_it(());
 }
 
 fn question_mark() -> Result<(), ()> {
diff --git a/tests/ui/unit_arg.stderr b/tests/ui/unit_arg.stderr
index b3fe9addb62..354fd51cd6b 100644
--- a/tests/ui/unit_arg.stderr
+++ b/tests/ui/unit_arg.stderr
@@ -1,5 +1,5 @@
 error: passing a unit value to a function
-  --> $DIR/unit_arg.rs:35:5
+  --> $DIR/unit_arg.rs:55:5
    |
 LL | /     foo({
 LL | |         1;
@@ -20,7 +20,7 @@ LL |     foo(());
    |
 
 error: passing a unit value to a function
-  --> $DIR/unit_arg.rs:38:5
+  --> $DIR/unit_arg.rs:58:5
    |
 LL |     foo(foo(1));
    |     ^^^^^^^^^^^
@@ -32,7 +32,7 @@ LL |     foo(());
    |
 
 error: passing a unit value to a function
-  --> $DIR/unit_arg.rs:39:5
+  --> $DIR/unit_arg.rs:59:5
    |
 LL | /     foo({
 LL | |         foo(1);
@@ -54,7 +54,7 @@ LL |     foo(());
    |
 
 error: passing a unit value to a function
-  --> $DIR/unit_arg.rs:44:5
+  --> $DIR/unit_arg.rs:64:5
    |
 LL | /     b.bar({
 LL | |         1;
@@ -74,7 +74,7 @@ LL |     b.bar(());
    |
 
 error: passing unit values to a function
-  --> $DIR/unit_arg.rs:47:5
+  --> $DIR/unit_arg.rs:67:5
    |
 LL |     taking_multiple_units(foo(0), foo(1));
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -87,7 +87,7 @@ LL |     taking_multiple_units((), ());
    |
 
 error: passing unit values to a function
-  --> $DIR/unit_arg.rs:48:5
+  --> $DIR/unit_arg.rs:68:5
    |
 LL | /     taking_multiple_units(foo(0), {
 LL | |         foo(1);
@@ -110,7 +110,7 @@ LL |     taking_multiple_units((), ());
    |
 
 error: passing unit values to a function
-  --> $DIR/unit_arg.rs:52:5
+  --> $DIR/unit_arg.rs:72:5
    |
 LL | /     taking_multiple_units(
 LL | |         {
@@ -140,7 +140,7 @@ LL |         foo(2);
  ...
 
 error: passing a unit value to a function
-  --> $DIR/unit_arg.rs:63:13
+  --> $DIR/unit_arg.rs:83:13
    |
 LL |     None.or(Some(foo(2)));
    |             ^^^^^^^^^^^^
@@ -154,7 +154,7 @@ LL |     });
    |
 
 error: passing a unit value to a function
-  --> $DIR/unit_arg.rs:66:5
+  --> $DIR/unit_arg.rs:86:5
    |
 LL |     foo(foo(()));
    |     ^^^^^^^^^^^^
@@ -166,7 +166,7 @@ LL |     foo(());
    |
 
 error: passing a unit value to a function
-  --> $DIR/unit_arg.rs:102:5
+  --> $DIR/unit_arg.rs:123:5
    |
 LL |     Some(foo(1))
    |     ^^^^^^^^^^^^