]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/unit_arg.rs
Rollup merge of #71829 - kper:issue71136, r=matthewjasper
[rust.git] / src / tools / clippy / tests / ui / unit_arg.rs
1 // run-rustfix
2 #![warn(clippy::unit_arg)]
3 #![allow(unused_braces, 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         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 }
39
40 fn ok() {
41     foo(());
42     foo(1);
43     foo({ 1 });
44     foo3("a", 3, vec![3]);
45     let b = Bar;
46     b.bar({ 1 });
47     b.bar(());
48     question_mark();
49 }
50
51 fn question_mark() -> Result<(), ()> {
52     Ok(Ok(())?)?;
53     Ok(Ok(()))??;
54     Ok(())
55 }
56
57 #[allow(dead_code)]
58 mod issue_2945 {
59     fn unit_fn() -> Result<(), i32> {
60         Ok(())
61     }
62
63     fn fallible() -> Result<(), i32> {
64         Ok(unit_fn()?)
65     }
66 }
67
68 fn main() {
69     bad();
70     ok();
71 }