2 #[warn(clippy::collapsible_if)]
8 println!("Hello world!");
12 if x == "hello" || x == "world" {
13 if y == "world" || y == "hello" {
14 println!("Hello world!");
18 if x == "hello" && x == "world" {
19 if y == "world" || y == "hello" {
20 println!("Hello world!");
24 if x == "hello" || x == "world" {
25 if y == "world" && y == "hello" {
26 println!("Hello world!");
30 if x == "hello" && x == "world" {
31 if y == "world" && y == "hello" {
32 println!("Hello world!");
42 // Collapse `else { if .. }` to `else if ..`
54 if let Some(42) = Some(42) {
73 if let Some(42) = Some(42) {
81 if let Some(42) = Some(42) {
84 if let Some(42) = Some(42) {
92 if let Some(42) = Some(42) {
103 if let Some(42) = Some(42) {
106 if let Some(42) = Some(42) {
114 // Works because any if with an else statement cannot be collapsed.
117 println!("Hello world!");
120 println!("Not Hello world");
125 println!("Hello world!");
127 println!("Hello something else");
140 assert!(true); // assert! is just an `if`
144 // The following tests check for the fix of https://github.com/rust-lang/rust-clippy/issues/798
145 if x == "hello" {// Not collapsible
147 println!("Hello world!");
151 if x == "hello" { // Not collapsible
153 println!("Hello world!");
160 println!("Hello world!");
165 if y == "world" { // Collapsible
166 println!("Hello world!");
183 if let Some(42) = Some(42) {
189 /* Not collapsible */
191 println!("Hello world!");
195 if x == "hello" { /* Not collapsible */
197 println!("Hello world!");