]> git.lizzy.rs Git - rust.git/blob - tests/ui/needless_return.fixed
Rollup merge of #5517 - flip1995:deploy_time_travel, r=Manishearth
[rust.git] / tests / ui / needless_return.fixed
1 // run-rustfix
2
3 #![allow(unused, clippy::needless_bool)]
4 #![allow(clippy::if_same_then_else, clippy::single_match)]
5 #![warn(clippy::needless_return)]
6
7 macro_rules! the_answer {
8     () => {
9         42
10     };
11 }
12
13 fn test_end_of_fn() -> bool {
14     if true {
15         // no error!
16         return true;
17     }
18     true
19 }
20
21 fn test_no_semicolon() -> bool {
22     true
23 }
24
25 fn test_if_block() -> bool {
26     if true {
27         true
28     } else {
29         false
30     }
31 }
32
33 fn test_match(x: bool) -> bool {
34     match x {
35         true => false,
36         false => {
37             true
38         },
39     }
40 }
41
42 fn test_closure() {
43     let _ = || {
44         true
45     };
46     let _ = || true;
47 }
48
49 fn test_macro_call() -> i32 {
50     return the_answer!();
51 }
52
53 fn test_void_fun() {
54     
55 }
56
57 fn test_void_if_fun(b: bool) {
58     if b {
59         
60     } else {
61         
62     }
63 }
64
65 fn test_void_match(x: u32) {
66     match x {
67         0 => (),
68         _ => {},
69     }
70 }
71
72 fn main() {
73     let _ = test_end_of_fn();
74     let _ = test_no_semicolon();
75     let _ = test_if_block();
76     let _ = test_match(true);
77     test_closure();
78 }