Skip to content

Commit f8433f0

Browse files
committed
Adapt stderr and fixed files
1 parent 197a3ea commit f8433f0

File tree

3 files changed

+108
-31
lines changed

3 files changed

+108
-31
lines changed

tests/ui/unit_arg.fixed

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,21 @@ impl Bar {
2121
}
2222

2323
fn bad() {
24-
foo(());
25-
foo(());
26-
foo(());
27-
foo(());
28-
foo3((), 2, 2);
24+
{}; foo(());
25+
{
26+
1;
27+
}; foo(());
28+
foo(1); foo(());
29+
{
30+
foo(1);
31+
foo(2);
32+
}; foo(());
33+
{}; foo3((), 2, 2);
2934
let b = Bar;
30-
b.bar(());
35+
{
36+
1;
37+
}; b.bar(());
38+
foo(0); foo(1); taking_multiple_units((), ());
3139
}
3240

3341
fn ok() {
@@ -58,6 +66,12 @@ mod issue_2945 {
5866
}
5967
}
6068

69+
fn returning_expr() -> Option<()> {
70+
foo(1); Some(())
71+
}
72+
73+
fn taking_multiple_units(a: (), b: ()) {}
74+
6175
fn main() {
6276
bad();
6377
ok();

tests/ui/unit_arg.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ fn bad() {
3535
b.bar({
3636
1;
3737
});
38+
taking_multiple_units(foo(0), foo(1));
3839
}
3940

4041
fn ok() {
@@ -65,6 +66,12 @@ mod issue_2945 {
6566
}
6667
}
6768

69+
fn returning_expr() -> Option<()> {
70+
Some(foo(1))
71+
}
72+
73+
fn taking_multiple_units(a: (), b: ()) {}
74+
6875
fn main() {
6976
bad();
7077
ok();

tests/ui/unit_arg.stderr

Lines changed: 81 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,130 @@
11
error: passing a unit value to a function
2-
--> $DIR/unit_arg.rs:24:9
2+
--> $DIR/unit_arg.rs:24:5
33
|
44
LL | foo({});
5-
| ^^
5+
| ^^^^^^^
66
|
77
= note: `-D clippy::unit-arg` implied by `-D warnings`
8-
help: if you intended to pass a unit value, use a unit literal instead
8+
help: move the expressions in front of the call...
9+
|
10+
LL | {}; foo({});
11+
| ^^^
12+
help: ...and use unit literals instead
913
|
1014
LL | foo(());
1115
| ^^
1216

1317
error: passing a unit value to a function
14-
--> $DIR/unit_arg.rs:25:9
18+
--> $DIR/unit_arg.rs:25:5
1519
|
16-
LL | foo({
17-
| _________^
20+
LL | / foo({
1821
LL | | 1;
1922
LL | | });
20-
| |_____^
21-
help: if you intended to pass a unit value, use a unit literal instead
23+
| |______^
24+
help: move the expressions in front of the call...
25+
|
26+
LL | {
27+
LL | 1;
28+
LL | }; foo({
29+
|
30+
help: ...and use unit literals instead
2231
|
2332
LL | foo(());
2433
| ^^
2534

2635
error: passing a unit value to a function
27-
--> $DIR/unit_arg.rs:28:9
36+
--> $DIR/unit_arg.rs:28:5
2837
|
2938
LL | foo(foo(1));
30-
| ^^^^^^
31-
help: if you intended to pass a unit value, use a unit literal instead
39+
| ^^^^^^^^^^^
40+
help: move the expressions in front of the call...
41+
|
42+
LL | foo(1); foo(foo(1));
43+
| ^^^^^^^
44+
help: ...and use unit literals instead
3245
|
3346
LL | foo(());
3447
| ^^
3548

3649
error: passing a unit value to a function
37-
--> $DIR/unit_arg.rs:29:9
50+
--> $DIR/unit_arg.rs:29:5
3851
|
39-
LL | foo({
40-
| _________^
52+
LL | / foo({
4153
LL | | foo(1);
4254
LL | | foo(2);
4355
LL | | });
44-
| |_____^
45-
help: if you intended to pass a unit value, use a unit literal instead
56+
| |______^
57+
help: move the expressions in front of the call...
58+
|
59+
LL | {
60+
LL | foo(1);
61+
LL | foo(2);
62+
LL | }; foo({
63+
|
64+
help: ...and use unit literals instead
4665
|
4766
LL | foo(());
4867
| ^^
4968

5069
error: passing a unit value to a function
51-
--> $DIR/unit_arg.rs:33:10
70+
--> $DIR/unit_arg.rs:33:5
5271
|
5372
LL | foo3({}, 2, 2);
54-
| ^^
55-
help: if you intended to pass a unit value, use a unit literal instead
73+
| ^^^^^^^^^^^^^^
74+
help: move the expressions in front of the call...
75+
|
76+
LL | {}; foo3({}, 2, 2);
77+
| ^^^
78+
help: ...and use unit literals instead
5679
|
5780
LL | foo3((), 2, 2);
5881
| ^^
5982

6083
error: passing a unit value to a function
61-
--> $DIR/unit_arg.rs:35:11
84+
--> $DIR/unit_arg.rs:35:5
6285
|
63-
LL | b.bar({
64-
| ___________^
86+
LL | / b.bar({
6587
LL | | 1;
6688
LL | | });
67-
| |_____^
68-
help: if you intended to pass a unit value, use a unit literal instead
89+
| |______^
90+
help: move the expressions in front of the call...
91+
|
92+
LL | {
93+
LL | 1;
94+
LL | }; b.bar({
95+
|
96+
help: ...and use unit literals instead
6997
|
7098
LL | b.bar(());
7199
| ^^
72100

73-
error: aborting due to 6 previous errors
101+
error: passing a unit value to a function
102+
--> $DIR/unit_arg.rs:38:5
103+
|
104+
LL | taking_multiple_units(foo(0), foo(1));
105+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
106+
help: move the expressions in front of the call...
107+
|
108+
LL | foo(0); foo(1); taking_multiple_units(foo(0), foo(1));
109+
| ^^^^^^^^^^^^^^^
110+
help: ...and use unit literals instead
111+
|
112+
LL | taking_multiple_units((), ());
113+
| ^^ ^^
114+
115+
error: passing a unit value to a function
116+
--> $DIR/unit_arg.rs:70:5
117+
|
118+
LL | Some(foo(1))
119+
| ^^^^^^^^^^^^
120+
help: move the expressions in front of the call...
121+
|
122+
LL | foo(1); Some(foo(1))
123+
| ^^^^^^^
124+
help: ...and use unit literals instead
125+
|
126+
LL | Some(())
127+
| ^^
128+
129+
error: aborting due to 8 previous errors
74130

0 commit comments

Comments
 (0)