]> git.lizzy.rs Git - rust.git/blob - tests/ui/unit_arg.rs
Auto merge of #3603 - xfix:random-state-lint, r=phansch
[rust.git] / tests / ui / unit_arg.rs
1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10 #![warn(clippy::unit_arg)]
11 #![allow(clippy::no_effect)]
12
13 use std::fmt::Debug;
14
15 fn foo<T: Debug>(t: T) {
16     println!("{:?}", t);
17 }
18
19 fn foo3<T1: Debug, T2: Debug, T3: Debug>(t1: T1, t2: T2, t3: T3) {
20     println!("{:?}, {:?}, {:?}", t1, t2, t3);
21 }
22
23 struct Bar;
24
25 impl Bar {
26     fn bar<T: Debug>(&self, t: T) {
27         println!("{:?}", t);
28     }
29 }
30
31 fn bad() {
32     foo({});
33     foo({
34         1;
35     });
36     foo(foo(1));
37     foo({
38         foo(1);
39         foo(2);
40     });
41     foo3({}, 2, 2);
42     let b = Bar;
43     b.bar({
44         1;
45     });
46 }
47
48 fn ok() {
49     foo(());
50     foo(1);
51     foo({ 1 });
52     foo3("a", 3, vec![3]);
53     let b = Bar;
54     b.bar({ 1 });
55     b.bar(());
56     question_mark();
57 }
58
59 fn question_mark() -> Result<(), ()> {
60     Ok(Ok(())?)?;
61     Ok(Ok(()))??;
62     Ok(())
63 }
64
65 fn main() {
66     bad();
67     ok();
68 }