]> git.lizzy.rs Git - rust.git/blob - tests/ui/collapsible_else_if.rs
Auto merge of #68717 - petrochenkov:stabexpat, r=varkor
[rust.git] / tests / ui / collapsible_else_if.rs
1 // run-rustfix
2 #![allow(clippy::assertions_on_constants)]
3
4 #[rustfmt::skip]
5 #[warn(clippy::collapsible_if)]
6 fn main() {
7     let x = "hello";
8     let y = "world";
9     // Collapse `else { if .. }` to `else if ..`
10     if x == "hello" {
11         print!("Hello ");
12     } else {
13         if y == "world" {
14             println!("world!")
15         }
16     }
17
18     if x == "hello" {
19         print!("Hello ");
20     } else {
21         if let Some(42) = Some(42) {
22             println!("world!")
23         }
24     }
25
26     if x == "hello" {
27         print!("Hello ");
28     } else {
29         if y == "world" {
30             println!("world")
31         }
32         else {
33             println!("!")
34         }
35     }
36
37     if x == "hello" {
38         print!("Hello ");
39     } else {
40         if let Some(42) = Some(42) {
41             println!("world")
42         }
43         else {
44             println!("!")
45         }
46     }
47
48     if let Some(42) = Some(42) {
49         print!("Hello ");
50     } else {
51         if let Some(42) = Some(42) {
52             println!("world")
53         }
54         else {
55             println!("!")
56         }
57     }
58
59     if let Some(42) = Some(42) {
60         print!("Hello ");
61     } else {
62         if x == "hello" {
63             println!("world")
64         }
65         else {
66             println!("!")
67         }
68     }
69
70     if let Some(42) = Some(42) {
71         print!("Hello ");
72     } else {
73         if let Some(42) = Some(42) {
74             println!("world")
75         }
76         else {
77             println!("!")
78         }
79     }
80 }