]> git.lizzy.rs Git - rust.git/blob - tests/ui/collapsible_else_if.fixed
Split up `collapsible_if` ui test
[rust.git] / tests / ui / collapsible_else_if.fixed
1 // run-rustfix
2 #![allow(clippy::cognitive_complexity, 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 if y == "world" {
13     println!("world!")
14 }
15
16     if x == "hello" {
17         print!("Hello ");
18     } else if let Some(42) = Some(42) {
19     println!("world!")
20 }
21
22     if x == "hello" {
23         print!("Hello ");
24     } else if y == "world" {
25     println!("world")
26 }
27 else {
28     println!("!")
29 }
30
31     if x == "hello" {
32         print!("Hello ");
33     } else if let Some(42) = Some(42) {
34     println!("world")
35 }
36 else {
37     println!("!")
38 }
39
40     if let Some(42) = Some(42) {
41         print!("Hello ");
42     } else if let Some(42) = Some(42) {
43     println!("world")
44 }
45 else {
46     println!("!")
47 }
48
49     if let Some(42) = Some(42) {
50         print!("Hello ");
51     } else if x == "hello" {
52     println!("world")
53 }
54 else {
55     println!("!")
56 }
57
58     if let Some(42) = Some(42) {
59         print!("Hello ");
60     } else if let Some(42) = Some(42) {
61     println!("world")
62 }
63 else {
64     println!("!")
65 }
66 }