Skip to content

Commit cbe6eec

Browse files
committed
Add original test case from issue
1 parent 9fe9d94 commit cbe6eec

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

tests/ui/unit_arg.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,26 @@ fn baz<T: Debug>(t: T) {
3131
foo(t);
3232
}
3333

34+
trait Tr {
35+
type Args;
36+
fn do_it(args: Self::Args);
37+
}
38+
39+
struct A;
40+
impl Tr for A {
41+
type Args = ();
42+
fn do_it(_: Self::Args) {}
43+
}
44+
45+
struct B;
46+
impl Tr for B {
47+
type Args = <A as Tr>::Args;
48+
49+
fn do_it(args: Self::Args) {
50+
A::do_it(args)
51+
}
52+
}
53+
3454
fn bad() {
3555
foo({
3656
1;
@@ -78,6 +98,7 @@ fn ok() {
7898
let named_unit_arg = ();
7999
foo(named_unit_arg);
80100
baz(());
101+
B::do_it(());
81102
}
82103

83104
fn question_mark() -> Result<(), ()> {

tests/ui/unit_arg.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: passing a unit value to a function
2-
--> $DIR/unit_arg.rs:35:5
2+
--> $DIR/unit_arg.rs:55:5
33
|
44
LL | / foo({
55
LL | | 1;
@@ -20,7 +20,7 @@ LL | foo(());
2020
|
2121

2222
error: passing a unit value to a function
23-
--> $DIR/unit_arg.rs:38:5
23+
--> $DIR/unit_arg.rs:58:5
2424
|
2525
LL | foo(foo(1));
2626
| ^^^^^^^^^^^
@@ -32,7 +32,7 @@ LL | foo(());
3232
|
3333

3434
error: passing a unit value to a function
35-
--> $DIR/unit_arg.rs:39:5
35+
--> $DIR/unit_arg.rs:59:5
3636
|
3737
LL | / foo({
3838
LL | | foo(1);
@@ -54,7 +54,7 @@ LL | foo(());
5454
|
5555

5656
error: passing a unit value to a function
57-
--> $DIR/unit_arg.rs:44:5
57+
--> $DIR/unit_arg.rs:64:5
5858
|
5959
LL | / b.bar({
6060
LL | | 1;
@@ -74,7 +74,7 @@ LL | b.bar(());
7474
|
7575

7676
error: passing unit values to a function
77-
--> $DIR/unit_arg.rs:47:5
77+
--> $DIR/unit_arg.rs:67:5
7878
|
7979
LL | taking_multiple_units(foo(0), foo(1));
8080
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -87,7 +87,7 @@ LL | taking_multiple_units((), ());
8787
|
8888

8989
error: passing unit values to a function
90-
--> $DIR/unit_arg.rs:48:5
90+
--> $DIR/unit_arg.rs:68:5
9191
|
9292
LL | / taking_multiple_units(foo(0), {
9393
LL | | foo(1);
@@ -110,7 +110,7 @@ LL | taking_multiple_units((), ());
110110
|
111111

112112
error: passing unit values to a function
113-
--> $DIR/unit_arg.rs:52:5
113+
--> $DIR/unit_arg.rs:72:5
114114
|
115115
LL | / taking_multiple_units(
116116
LL | | {
@@ -140,7 +140,7 @@ LL | foo(2);
140140
...
141141

142142
error: passing a unit value to a function
143-
--> $DIR/unit_arg.rs:63:13
143+
--> $DIR/unit_arg.rs:83:13
144144
|
145145
LL | None.or(Some(foo(2)));
146146
| ^^^^^^^^^^^^
@@ -154,7 +154,7 @@ LL | });
154154
|
155155

156156
error: passing a unit value to a function
157-
--> $DIR/unit_arg.rs:66:5
157+
--> $DIR/unit_arg.rs:86:5
158158
|
159159
LL | foo(foo(()));
160160
| ^^^^^^^^^^^^
@@ -166,7 +166,7 @@ LL | foo(());
166166
|
167167

168168
error: passing a unit value to a function
169-
--> $DIR/unit_arg.rs:102:5
169+
--> $DIR/unit_arg.rs:123:5
170170
|
171171
LL | Some(foo(1))
172172
| ^^^^^^^^^^^^

0 commit comments

Comments
 (0)