Skip to content

Commit c325137

Browse files
committed
Add run-rustfix to unit_arg test
1 parent 67be421 commit c325137

File tree

3 files changed

+61
-7
lines changed

3 files changed

+61
-7
lines changed

Diff for: tests/ui/unit_arg.fixed

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// run-rustfix
2+
#![warn(clippy::unit_arg)]
3+
#![allow(clippy::no_effect, unused_must_use)]
4+
5+
use std::fmt::Debug;
6+
7+
fn foo<T: Debug>(t: T) {
8+
println!("{:?}", t);
9+
}
10+
11+
fn foo3<T1: Debug, T2: Debug, T3: Debug>(t1: T1, t2: T2, t3: T3) {
12+
println!("{:?}, {:?}, {:?}", t1, t2, t3);
13+
}
14+
15+
struct Bar;
16+
17+
impl Bar {
18+
fn bar<T: Debug>(&self, t: T) {
19+
println!("{:?}", t);
20+
}
21+
}
22+
23+
fn bad() {
24+
foo(());
25+
foo(());
26+
foo(());
27+
foo(());
28+
foo3((), 2, 2);
29+
let b = Bar;
30+
b.bar(());
31+
}
32+
33+
fn ok() {
34+
foo(());
35+
foo(1);
36+
foo({ 1 });
37+
foo3("a", 3, vec![3]);
38+
let b = Bar;
39+
b.bar({ 1 });
40+
b.bar(());
41+
question_mark();
42+
}
43+
44+
fn question_mark() -> Result<(), ()> {
45+
Ok(Ok(())?)?;
46+
Ok(Ok(()))??;
47+
Ok(())
48+
}
49+
50+
fn main() {
51+
bad();
52+
ok();
53+
}

Diff for: tests/ui/unit_arg.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
// run-rustfix
12
#![warn(clippy::unit_arg)]
2-
#![allow(clippy::no_effect)]
3+
#![allow(clippy::no_effect, unused_must_use)]
34

45
use std::fmt::Debug;
56

Diff for: tests/ui/unit_arg.stderr

+6-6
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:23:9
2+
--> $DIR/unit_arg.rs:24:9
33
|
44
LL | foo({});
55
| ^^
@@ -11,7 +11,7 @@ LL | foo(());
1111
| ^^
1212

1313
error: passing a unit value to a function
14-
--> $DIR/unit_arg.rs:24:9
14+
--> $DIR/unit_arg.rs:25:9
1515
|
1616
LL | foo({
1717
| _________^
@@ -24,7 +24,7 @@ LL | foo(());
2424
| ^^
2525

2626
error: passing a unit value to a function
27-
--> $DIR/unit_arg.rs:27:9
27+
--> $DIR/unit_arg.rs:28:9
2828
|
2929
LL | foo(foo(1));
3030
| ^^^^^^
@@ -34,7 +34,7 @@ LL | foo(());
3434
| ^^
3535

3636
error: passing a unit value to a function
37-
--> $DIR/unit_arg.rs:28:9
37+
--> $DIR/unit_arg.rs:29:9
3838
|
3939
LL | foo({
4040
| _________^
@@ -48,7 +48,7 @@ LL | foo(());
4848
| ^^
4949

5050
error: passing a unit value to a function
51-
--> $DIR/unit_arg.rs:32:10
51+
--> $DIR/unit_arg.rs:33:10
5252
|
5353
LL | foo3({}, 2, 2);
5454
| ^^
@@ -58,7 +58,7 @@ LL | foo3((), 2, 2);
5858
| ^^
5959

6060
error: passing a unit value to a function
61-
--> $DIR/unit_arg.rs:34:11
61+
--> $DIR/unit_arg.rs:35:11
6262
|
6363
LL | b.bar({
6464
| ___________^

0 commit comments

Comments
 (0)