]>
Commit | Line | Data |
---|---|---|
f20569fa XL |
1 | // run-rustfix |
2 | ||
3 | #![warn(clippy::implicit_return)] | |
4 | #![allow(clippy::needless_return, unused)] | |
5 | ||
6 | fn test_end_of_fn() -> bool { | |
7 | if true { | |
8 | // no error! | |
9 | return true; | |
10 | } | |
11 | ||
12 | true | |
13 | } | |
14 | ||
15 | #[allow(clippy::needless_bool)] | |
16 | fn test_if_block() -> bool { | |
17 | if true { true } else { false } | |
18 | } | |
19 | ||
20 | #[rustfmt::skip] | |
21 | fn test_match(x: bool) -> bool { | |
22 | match x { | |
23 | true => false, | |
24 | false => { true }, | |
25 | } | |
26 | } | |
27 | ||
28 | #[allow(clippy::needless_return)] | |
29 | fn test_match_with_unreachable(x: bool) -> bool { | |
30 | match x { | |
31 | true => return false, | |
32 | false => unreachable!(), | |
33 | } | |
34 | } | |
35 | ||
36 | #[allow(clippy::never_loop)] | |
37 | fn test_loop() -> bool { | |
38 | loop { | |
39 | break true; | |
40 | } | |
41 | } | |
42 | ||
43 | #[allow(clippy::never_loop)] | |
44 | fn test_loop_with_block() -> bool { | |
45 | loop { | |
46 | { | |
47 | break true; | |
48 | } | |
49 | } | |
50 | } | |
51 | ||
52 | #[allow(clippy::never_loop)] | |
53 | fn test_loop_with_nests() -> bool { | |
54 | loop { | |
55 | if true { | |
56 | break true; | |
57 | } else { | |
58 | let _ = true; | |
59 | } | |
60 | } | |
61 | } | |
62 | ||
63 | #[allow(clippy::redundant_pattern_matching)] | |
64 | fn test_loop_with_if_let() -> bool { | |
65 | loop { | |
66 | if let Some(x) = Some(true) { | |
67 | return x; | |
68 | } | |
69 | } | |
70 | } | |
71 | ||
72 | fn test_closure() { | |
73 | #[rustfmt::skip] | |
74 | let _ = || { true }; | |
75 | let _ = || true; | |
76 | } | |
77 | ||
78 | fn test_panic() -> bool { | |
79 | panic!() | |
80 | } | |
81 | ||
82 | fn test_return_macro() -> String { | |
83 | format!("test {}", "test") | |
84 | } | |
85 | ||
86 | fn main() { | |
87 | let _ = test_end_of_fn(); | |
88 | let _ = test_if_block(); | |
89 | let _ = test_match(true); | |
90 | let _ = test_match_with_unreachable(true); | |
91 | let _ = test_loop(); | |
92 | let _ = test_loop_with_block(); | |
93 | let _ = test_loop_with_nests(); | |
94 | let _ = test_loop_with_if_let(); | |
95 | test_closure(); | |
96 | let _ = test_return_macro(); | |
97 | } |