]> git.lizzy.rs Git - rust.git/blob - tests/ui/unit_arg.fixed
Auto merge of #4478 - tsurai:master, r=flip1995
[rust.git] / tests / ui / unit_arg.fixed
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 #[allow(dead_code)]
51 mod issue_2945 {
52     fn unit_fn() -> Result<(), i32> {
53         Ok(())
54     }
55
56     fn fallible() -> Result<(), i32> {
57         Ok(unit_fn()?)
58     }
59 }
60
61 fn main() {
62     bad();
63     ok();
64 }