]> git.lizzy.rs Git - rust.git/blob - tests/ui/unit_arg.rs
Adapt stderr and fixed files
[rust.git] / tests / ui / unit_arg.rs
1 // run-rustfix
2 #![warn(clippy::unit_arg)]
3 #![allow(clippy::no_effect, unused_must_use, unused_variables)]
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         1;
27     });
28     foo(foo(1));
29     foo({
30         foo(1);
31         foo(2);
32     });
33     foo3({}, 2, 2);
34     let b = Bar;
35     b.bar({
36         1;
37     });
38     taking_multiple_units(foo(0), foo(1));
39 }
40
41 fn ok() {
42     foo(());
43     foo(1);
44     foo({ 1 });
45     foo3("a", 3, vec![3]);
46     let b = Bar;
47     b.bar({ 1 });
48     b.bar(());
49     question_mark();
50 }
51
52 fn question_mark() -> Result<(), ()> {
53     Ok(Ok(())?)?;
54     Ok(Ok(()))??;
55     Ok(())
56 }
57
58 #[allow(dead_code)]
59 mod issue_2945 {
60     fn unit_fn() -> Result<(), i32> {
61         Ok(())
62     }
63
64     fn fallible() -> Result<(), i32> {
65         Ok(unit_fn()?)
66     }
67 }
68
69 #[allow(dead_code)]
70 fn returning_expr() -> Option<()> {
71     Some(foo(1))
72 }
73
74 fn taking_multiple_units(a: (), b: ()) {}
75
76 fn main() {
77     bad();
78     ok();
79 }