Skip to content

Commit 4e4a8b5

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

File tree

3 files changed

+94
-90
lines changed

3 files changed

+94
-90
lines changed

tests/ui/unit_arg.fixed

Lines changed: 0 additions & 64 deletions
This file was deleted.

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: 85 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,134 @@
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((), foo(1));
113+
| ^^
114+
help: ...and use unit literals instead
115+
|
116+
LL | taking_multiple_units(foo(0), ());
117+
| ^^
118+
119+
error: passing a unit value to a function
120+
--> $DIR/unit_arg.rs:71:5
121+
|
122+
LL | Some(foo(1))
123+
| ^^^^^^^^^^^^
124+
help: move the expressions in front of the call...
125+
|
126+
LL | foo(1); Some(foo(1))
127+
| ^^^^^^^
128+
help: ...and use unit literals instead
129+
|
130+
LL | Some(())
131+
| ^^
132+
133+
error: aborting due to 8 previous errors
74134

0 commit comments

Comments
 (0)