]> git.lizzy.rs Git - rust.git/blob - tests/ui/unit_arg.rs
Auto merge of #3645 - phansch:remove_copyright_headers, r=oli-obk
[rust.git] / tests / ui / unit_arg.rs
1 #![warn(clippy::unit_arg)]
2 #![allow(clippy::no_effect)]
3
4 use std::fmt::Debug;
5
6 fn foo<T: Debug>(t: T) {
7     println!("{:?}", t);
8 }
9
10 fn foo3<T1: Debug, T2: Debug, T3: Debug>(t1: T1, t2: T2, t3: T3) {
11     println!("{:?}, {:?}, {:?}", t1, t2, t3);
12 }
13
14 struct Bar;
15
16 impl Bar {
17     fn bar<T: Debug>(&self, t: T) {
18         println!("{:?}", t);
19     }
20 }
21
22 fn bad() {
23     foo({});
24     foo({
25         1;
26     });
27     foo(foo(1));
28     foo({
29         foo(1);
30         foo(2);
31     });
32     foo3({}, 2, 2);
33     let b = Bar;
34     b.bar({
35         1;
36     });
37 }
38
39 fn ok() {
40     foo(());
41     foo(1);
42     foo({ 1 });
43     foo3("a", 3, vec![3]);
44     let b = Bar;
45     b.bar({ 1 });
46     b.bar(());
47     question_mark();
48 }
49
50 fn question_mark() -> Result<(), ()> {
51     Ok(Ok(())?)?;
52     Ok(Ok(()))??;
53     Ok(())
54 }
55
56 fn main() {
57     bad();
58     ok();
59 }