]> git.lizzy.rs Git - rust.git/blob - tests/ui/bool_comparison.rs
Merge branch 'master' into rustfmt_tests
[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 }