2 #![allow(clippy::assertions_on_constants, clippy::equatable_if_let)]
5 #[warn(clippy::collapsible_if)]
11 println!("Hello world!");
15 if x == "hello" || x == "world" {
16 if y == "world" || y == "hello" {
17 println!("Hello world!");
21 if x == "hello" && x == "world" {
22 if y == "world" || y == "hello" {
23 println!("Hello world!");
27 if x == "hello" || x == "world" {
28 if y == "world" && y == "hello" {
29 println!("Hello world!");
33 if x == "hello" && x == "world" {
34 if y == "world" && y == "hello" {
35 println!("Hello world!");
45 // Works because any if with an else statement cannot be collapsed.
48 println!("Hello world!");
51 println!("Not Hello world");
56 println!("Hello world!");
58 println!("Hello something else");
71 assert!(true); // assert! is just an `if`
75 // The following tests check for the fix of https://github.com/rust-lang/rust-clippy/issues/798
76 if x == "hello" {// Not collapsible
78 println!("Hello world!");
82 if x == "hello" { // Not collapsible
84 println!("Hello world!");
91 println!("Hello world!");
96 if y == "world" { // Collapsible
97 println!("Hello world!");
114 if let Some(42) = Some(42) {
120 /* Not collapsible */
122 println!("Hello world!");
126 if x == "hello" { /* Not collapsible */
128 println!("Hello world!");
132 // Test behavior wrt. `let_chains`.
133 // None of the cases below should be collapsed.
134 fn truth() -> bool { true }
154 if matches!(true, true) {
155 if matches!(true, true) {}
161 println!("Hello world!");