]> git.lizzy.rs Git - rust.git/blob - tests/ui/needless_return.rs
Adapt the *.stderr files of the ui-tests to the tool_lints
[rust.git] / tests / ui / needless_return.rs
1 #![feature(tool_lints)]
2
3
4 #![warn(clippy::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 fn test_no_semicolon() -> bool {
15     return true
16 }
17
18 fn test_if_block() -> bool {
19     if true {
20         return true;
21     } else {
22         return false;
23     }
24 }
25
26 fn test_match(x: bool) -> bool {
27     match x {
28         true => return false,
29         false => {
30             return true;
31         }
32     }
33 }
34
35 fn test_closure() {
36     let _ = || {
37         return true;
38     };
39     let _ = || return true;
40 }
41
42 fn main() {
43     let _ = test_end_of_fn();
44     let _ = test_no_semicolon();
45     let _ = test_if_block();
46     let _ = test_match(true);
47     test_closure();
48 }