]> git.lizzy.rs Git - rust.git/blob - tests/ui/bool_comparison.rs
Auto merge of #3635 - matthiaskrgr:revert_random_state_3603, r=xfix
[rust.git] / tests / ui / bool_comparison.rs
1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10 #[warn(clippy::bool_comparison)]
11 fn main() {
12     let x = true;
13     if x == true {
14         "yes"
15     } else {
16         "no"
17     };
18     if x == false {
19         "yes"
20     } else {
21         "no"
22     };
23     if true == x {
24         "yes"
25     } else {
26         "no"
27     };
28     if false == x {
29         "yes"
30     } else {
31         "no"
32     };
33     if x != true {
34         "yes"
35     } else {
36         "no"
37     };
38     if x != false {
39         "yes"
40     } else {
41         "no"
42     };
43     if true != x {
44         "yes"
45     } else {
46         "no"
47     };
48     if false != x {
49         "yes"
50     } else {
51         "no"
52     };
53     if x < true {
54         "yes"
55     } else {
56         "no"
57     };
58     if false < x {
59         "yes"
60     } else {
61         "no"
62     };
63     if x > false {
64         "yes"
65     } else {
66         "no"
67     };
68     if true > x {
69         "yes"
70     } else {
71         "no"
72     };
73     let y = true;
74     if x < y {
75         "yes"
76     } else {
77         "no"
78     };
79     if x > y {
80         "yes"
81     } else {
82         "no"
83     };
84 }