fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
1.6 KiB83 linesraw
1#![allow(clippy::assertions_on_constants, clippy::equatable_if_let, clippy::needless_if)]
2
3#[rustfmt::skip]
4#[warn(clippy::collapsible_if)]
5#[warn(clippy::collapsible_else_if)]
6
7fn main() {
8    let x = "hello";
9    let y = "world";
10    // Collapse `else { if .. }` to `else if ..`
11    if x == "hello" {
12        print!("Hello ");
13    } else if y == "world" {
14        println!("world!")
15    }
16
17    if x == "hello" {
18        print!("Hello ");
19    } else if let Some(42) = Some(42) {
20        println!("world!")
21    }
22
23    if x == "hello" {
24        print!("Hello ");
25    } else if y == "world" {
26        println!("world")
27    }
28    else {
29        println!("!")
30    }
31
32    if x == "hello" {
33        print!("Hello ");
34    } else if let Some(42) = Some(42) {
35        println!("world")
36    }
37    else {
38        println!("!")
39    }
40
41    if let Some(42) = Some(42) {
42        print!("Hello ");
43    } else if let Some(42) = Some(42) {
44        println!("world")
45    }
46    else {
47        println!("!")
48    }
49
50    if let Some(42) = Some(42) {
51        print!("Hello ");
52    } else if x == "hello" {
53        println!("world")
54    }
55    else {
56        println!("!")
57    }
58
59    if let Some(42) = Some(42) {
60        print!("Hello ");
61    } else if let Some(42) = Some(42) {
62        println!("world")
63    }
64    else {
65        println!("!")
66    }
67
68    if x == "hello" {
69        print!("Hello ");
70    } else {
71        #[cfg(not(roflol))]
72        if y == "world" {
73            println!("world!")
74        }
75    }
76}
77
78#[rustfmt::skip]
79#[allow(dead_code)]
80fn issue_7318() {
81    if true { println!("I've been resolved!")
82    }else if false {}
83}