]> git.lizzy.rs Git - rust.git/blob - tests/ui/needless_return.rs
Merge branch 'master' into add-lints-aseert-checks
[rust.git] / tests / ui / needless_return.rs
1 #![warn(clippy::needless_return)]
2
3 fn test_end_of_fn() -> bool {
4     if true {
5         // no error!
6         return true;
7     }
8     return true;
9 }
10
11 fn test_no_semicolon() -> bool {
12     return true;
13 }
14
15 fn test_if_block() -> bool {
16     if true {
17         return true;
18     } else {
19         return false;
20     }
21 }
22
23 fn test_match(x: bool) -> bool {
24     match x {
25         true => return false,
26         false => {
27             return true;
28         },
29     }
30 }
31
32 fn test_closure() {
33     let _ = || {
34         return true;
35     };
36     let _ = || return true;
37 }
38
39 fn main() {
40     let _ = test_end_of_fn();
41     let _ = test_no_semicolon();
42     let _ = test_if_block();
43     let _ = test_match(true);
44     test_closure();
45 }