]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/tests/ui/collapsible_else_if.fixed
Update upstream source from tag 'upstream/1.52.1+dfsg1'
[rustc.git] / src / tools / clippy / tests / ui / collapsible_else_if.fixed
CommitLineData
f20569fa
XL
1// run-rustfix
2#![allow(clippy::assertions_on_constants)]
3
4#[rustfmt::skip]
5#[warn(clippy::collapsible_if)]
6#[warn(clippy::collapsible_else_if)]
7
8fn main() {
9 let x = "hello";
10 let y = "world";
11 // Collapse `else { if .. }` to `else if ..`
12 if x == "hello" {
13 print!("Hello ");
14 } else if y == "world" {
15 println!("world!")
16 }
17
18 if x == "hello" {
19 print!("Hello ");
20 } else if let Some(42) = Some(42) {
21 println!("world!")
22 }
23
24 if x == "hello" {
25 print!("Hello ");
26 } else if y == "world" {
27 println!("world")
28 }
29 else {
30 println!("!")
31 }
32
33 if x == "hello" {
34 print!("Hello ");
35 } else if let Some(42) = Some(42) {
36 println!("world")
37 }
38 else {
39 println!("!")
40 }
41
42 if let Some(42) = Some(42) {
43 print!("Hello ");
44 } else if let Some(42) = Some(42) {
45 println!("world")
46 }
47 else {
48 println!("!")
49 }
50
51 if let Some(42) = Some(42) {
52 print!("Hello ");
53 } else if x == "hello" {
54 println!("world")
55 }
56 else {
57 println!("!")
58 }
59
60 if let Some(42) = Some(42) {
61 print!("Hello ");
62 } else if let Some(42) = Some(42) {
63 println!("world")
64 }
65 else {
66 println!("!")
67 }
68
69 if x == "hello" {
70 print!("Hello ");
71 } else {
72 #[cfg(not(roflol))]
73 if y == "world" {
74 println!("world!")
75 }
76 }
77}