Skip to content

Commit 90da468

Browse files
committed
Adapt stderr and fixed files
1 parent 2abaa96 commit 90da468

File tree

3 files changed

+118
-33
lines changed

3 files changed

+118
-33
lines changed

tests/ui/unit_arg.fixed

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// run-rustfix
22
#![warn(clippy::unit_arg)]
3-
#![allow(clippy::no_effect, unused_must_use)]
3+
#![allow(clippy::no_effect, unused_must_use, unused_variables)]
44

55
use std::fmt::Debug;
66

@@ -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,13 @@ mod issue_2945 {
5866
}
5967
}
6068

69+
#[allow(dead_code)]
70+
fn returning_expr() -> Option<()> {
71+
foo(1); Some(())
72+
}
73+
74+
fn taking_multiple_units(a: (), b: ()) {}
75+
6176
fn main() {
6277
bad();
6378
ok();

tests/ui/unit_arg.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// run-rustfix
22
#![warn(clippy::unit_arg)]
3-
#![allow(clippy::no_effect, unused_must_use)]
3+
#![allow(clippy::no_effect, unused_must_use, unused_variables)]
44

55
use std::fmt::Debug;
66

@@ -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,13 @@ mod issue_2945 {
6566
}
6667
}
6768

69+
#[allow(dead_code)]
70+
fn returning_expr() -> Option<()> {
71+
Some(foo(1))
72+
}
73+
74+
fn taking_multiple_units(a: (), b: ()) {}
75+
6876
fn main() {
6977
bad();
7078
ok();

tests/ui/unit_arg.stderr

Lines changed: 87 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,141 @@
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-
| |_____^
23+
| |______^
24+
|
25+
help: move the expressions in front of the call...
26+
|
27+
LL | {
28+
LL | 1;
29+
LL | }; foo({
2130
|
22-
help: if you intended to pass a unit value, use a unit literal instead
31+
help: ...and use unit literals instead
2332
|
2433
LL | foo(());
2534
| ^^
2635

2736
error: passing a unit value to a function
28-
--> $DIR/unit_arg.rs:28:9
37+
--> $DIR/unit_arg.rs:28:5
2938
|
3039
LL | foo(foo(1));
31-
| ^^^^^^
40+
| ^^^^^^^^^^^
3241
|
33-
help: if you intended to pass a unit value, use a unit literal instead
42+
help: move the expressions in front of the call...
43+
|
44+
LL | foo(1); foo(foo(1));
45+
| ^^^^^^^
46+
help: ...and use unit literals instead
3447
|
3548
LL | foo(());
3649
| ^^
3750

3851
error: passing a unit value to a function
39-
--> $DIR/unit_arg.rs:29:9
52+
--> $DIR/unit_arg.rs:29:5
4053
|
41-
LL | foo({
42-
| _________^
54+
LL | / foo({
4355
LL | | foo(1);
4456
LL | | foo(2);
4557
LL | | });
46-
| |_____^
58+
| |______^
59+
|
60+
help: move the expressions in front of the call...
61+
|
62+
LL | {
63+
LL | foo(1);
64+
LL | foo(2);
65+
LL | }; foo({
4766
|
48-
help: if you intended to pass a unit value, use a unit literal instead
67+
help: ...and use unit literals instead
4968
|
5069
LL | foo(());
5170
| ^^
5271

5372
error: passing a unit value to a function
54-
--> $DIR/unit_arg.rs:33:10
73+
--> $DIR/unit_arg.rs:33:5
5574
|
5675
LL | foo3({}, 2, 2);
57-
| ^^
76+
| ^^^^^^^^^^^^^^
77+
|
78+
help: move the expressions in front of the call...
5879
|
59-
help: if you intended to pass a unit value, use a unit literal instead
80+
LL | {}; foo3({}, 2, 2);
81+
| ^^^
82+
help: ...and use unit literals instead
6083
|
6184
LL | foo3((), 2, 2);
6285
| ^^
6386

6487
error: passing a unit value to a function
65-
--> $DIR/unit_arg.rs:35:11
88+
--> $DIR/unit_arg.rs:35:5
6689
|
67-
LL | b.bar({
68-
| ___________^
90+
LL | / b.bar({
6991
LL | | 1;
7092
LL | | });
71-
| |_____^
93+
| |______^
94+
|
95+
help: move the expressions in front of the call...
7296
|
73-
help: if you intended to pass a unit value, use a unit literal instead
97+
LL | {
98+
LL | 1;
99+
LL | }; b.bar({
100+
|
101+
help: ...and use unit literals instead
74102
|
75103
LL | b.bar(());
76104
| ^^
77105

78-
error: aborting due to 6 previous errors
106+
error: passing a unit value to a function
107+
--> $DIR/unit_arg.rs:38:5
108+
|
109+
LL | taking_multiple_units(foo(0), foo(1));
110+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
111+
|
112+
help: move the expressions in front of the call...
113+
|
114+
LL | foo(0); foo(1); taking_multiple_units(foo(0), foo(1));
115+
| ^^^^^^^^^^^^^^^
116+
help: ...and use unit literals instead
117+
|
118+
LL | taking_multiple_units((), foo(1));
119+
| ^^
120+
help: ...and use unit literals instead
121+
|
122+
LL | taking_multiple_units(foo(0), ());
123+
| ^^
124+
125+
error: passing a unit value to a function
126+
--> $DIR/unit_arg.rs:71:5
127+
|
128+
LL | Some(foo(1))
129+
| ^^^^^^^^^^^^
130+
|
131+
help: move the expressions in front of the call...
132+
|
133+
LL | foo(1); Some(foo(1))
134+
| ^^^^^^^
135+
help: ...and use unit literals instead
136+
|
137+
LL | Some(())
138+
| ^^
139+
140+
error: aborting due to 8 previous errors
79141

0 commit comments

Comments
 (0)