]> git.lizzy.rs Git - rust.git/blob - tests/ui/unit_arg.rs
Merge pull request #3265 from mikerite/fix-export
[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
11 #![feature(tool_lints)]
12
13 #![warn(clippy::unit_arg)]
14 #![allow(clippy::no_effect)]
15
16 use std::fmt::Debug;
17
18 fn foo<T: Debug>(t: T) {
19     println!("{:?}", t);
20 }
21
22 fn foo3<T1: Debug, T2: Debug, T3: Debug>(t1: T1, t2: T2, t3: T3) {
23     println!("{:?}, {:?}, {:?}", t1, t2, t3);
24 }
25
26 struct Bar;
27
28 impl Bar {
29     fn bar<T: Debug>(&self, t: T) {
30         println!("{:?}", t);
31     }
32 }
33
34 fn bad() {
35     foo({});
36     foo({ 1; });
37     foo(foo(1));
38     foo({
39         foo(1);
40         foo(2);
41     });
42     foo3({}, 2, 2);
43     let b = Bar;
44     b.bar({ 1; });
45 }
46
47 fn ok() {
48     foo(());
49     foo(1);
50     foo({ 1 });
51     foo3("a", 3, vec![3]);
52     let b = Bar;
53     b.bar({ 1 });
54     b.bar(());
55     question_mark();
56 }
57
58 fn question_mark() -> Result<(), ()> {
59     Ok(Ok(())?)?;
60     Ok(Ok(()))??;
61     Ok(())
62 }
63
64 fn main() {
65     bad();
66     ok();
67 }