]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/needless_bool/simple.rs
Rollup merge of #92191 - jackh726:issue-89352, r=nikomatsakis
[rust.git] / src / tools / clippy / tests / ui / needless_bool / simple.rs
1 #![warn(clippy::needless_bool)]
2 #![allow(
3     unused,
4     dead_code,
5     clippy::no_effect,
6     clippy::if_same_then_else,
7     clippy::needless_return,
8     clippy::branches_sharing_code
9 )]
10
11 fn main() {
12     let x = true;
13     let y = false;
14     if x {
15         true
16     } else {
17         true
18     };
19     if x {
20         false
21     } else {
22         false
23     };
24     if x {
25         x
26     } else {
27         false
28     }; // would also be questionable, but we don't catch this yet
29     bool_ret(x);
30     bool_ret2(x);
31 }
32
33 fn bool_ret(x: bool) -> bool {
34     if x {
35         return true;
36     } else {
37         return true;
38     };
39 }
40
41 fn bool_ret2(x: bool) -> bool {
42     if x {
43         return false;
44     } else {
45         return false;
46     };
47 }