From cbe6eec3e67347af130769ad4a3bd2168997b411 Mon Sep 17 00:00:00 2001 From: Marc Dominik Migge Date: Thu, 25 Feb 2021 22:03:11 +0100 Subject: [PATCH] Add original test case from issue --- tests/ui/unit_arg.rs | 21 +++++++++++++++++++++ tests/ui/unit_arg.stderr | 20 ++++++++++---------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/tests/ui/unit_arg.rs b/tests/ui/unit_arg.rs index 5ea2e5d65..938cc3c78 100644 --- a/tests/ui/unit_arg.rs +++ b/tests/ui/unit_arg.rs @@ -31,6 +31,26 @@ fn baz(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 = ::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 b3fe9addb..354fd51cd 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)) | ^^^^^^^^^^^^