]> git.lizzy.rs Git - rust.git/blob - tests/ui/unit_arg.rs
Merge pull request #2984 from flip1995/single_char_pattern
[rust.git] / tests / ui / unit_arg.rs
1 #![warn(unit_arg)]
2 #![allow(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({ 1; });
25     foo(foo(1));
26     foo({
27         foo(1);
28         foo(2);
29     });
30     foo3({}, 2, 2);
31     let b = Bar;
32     b.bar({ 1; });
33 }
34
35 fn ok() {
36     foo(());
37     foo(1);
38     foo({ 1 });
39     foo3("a", 3, vec![3]);
40     let b = Bar;
41     b.bar({ 1 });
42     b.bar(());
43     question_mark();
44 }
45
46 fn question_mark() -> Result<(), ()> {
47     Ok(Ok(())?)?;
48     Ok(Ok(()))??;
49     Ok(())
50 }
51
52 fn main() {
53     bad();
54     ok();
55 }