]> git.lizzy.rs Git - rust.git/blob - tests/ui/needless_return.rs
2751089bddadf118c2b7f527269d7a7ff02f231d
[rust.git] / tests / ui / needless_return.rs
1 #![feature(plugin)]
2 #![plugin(clippy)]
3
4 #![deny(needless_return)]
5
6 fn test_end_of_fn() -> bool {
7     if true {
8         // no error!
9         return true;
10     }
11     return true;
12
13
14
15 }
16
17 fn test_no_semicolon() -> bool {
18     return true
19
20
21
22 }
23
24 fn test_if_block() -> bool {
25     if true {
26         return true;
27
28
29
30     } else {
31         return false;
32
33
34
35     }
36 }
37
38 fn test_match(x: bool) -> bool {
39     match x {
40         true => return false,
41
42
43
44
45         false => {
46             return true;
47
48
49
50         }
51     }
52 }
53
54 fn test_closure() {
55     let _ = || {
56         return true;
57
58
59
60     };
61     let _ = || return true;
62
63
64
65 }
66
67 fn main() {
68     let _ = test_end_of_fn();
69     let _ = test_no_semicolon();
70     let _ = test_if_block();
71     let _ = test_match(true);
72     test_closure();
73 }