2023-07-02 12:35:19 +00:00
|
|
|
#![allow(clippy::assertions_on_constants, clippy::equatable_if_let, clippy::needless_if)]
|
2020-01-07 06:06:23 +00:00
|
|
|
|
|
|
|
#[rustfmt::skip]
|
|
|
|
#[warn(clippy::collapsible_if)]
|
2021-01-15 09:56:44 +00:00
|
|
|
#[warn(clippy::collapsible_else_if)]
|
|
|
|
|
2020-01-07 06:06:23 +00:00
|
|
|
fn main() {
|
|
|
|
let x = "hello";
|
|
|
|
let y = "world";
|
|
|
|
// Collapse `else { if .. }` to `else if ..`
|
|
|
|
if x == "hello" {
|
|
|
|
print!("Hello ");
|
|
|
|
} else if y == "world" {
|
2020-02-04 15:13:06 +00:00
|
|
|
println!("world!")
|
|
|
|
}
|
2020-01-07 06:06:23 +00:00
|
|
|
|
|
|
|
if x == "hello" {
|
|
|
|
print!("Hello ");
|
|
|
|
} else if let Some(42) = Some(42) {
|
2020-02-04 15:13:06 +00:00
|
|
|
println!("world!")
|
|
|
|
}
|
2020-01-07 06:06:23 +00:00
|
|
|
|
|
|
|
if x == "hello" {
|
|
|
|
print!("Hello ");
|
|
|
|
} else if y == "world" {
|
2020-02-04 15:13:06 +00:00
|
|
|
println!("world")
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
println!("!")
|
|
|
|
}
|
2020-01-07 06:06:23 +00:00
|
|
|
|
|
|
|
if x == "hello" {
|
|
|
|
print!("Hello ");
|
|
|
|
} else if let Some(42) = Some(42) {
|
2020-02-04 15:13:06 +00:00
|
|
|
println!("world")
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
println!("!")
|
|
|
|
}
|
2020-01-07 06:06:23 +00:00
|
|
|
|
|
|
|
if let Some(42) = Some(42) {
|
|
|
|
print!("Hello ");
|
|
|
|
} else if let Some(42) = Some(42) {
|
2020-02-04 15:13:06 +00:00
|
|
|
println!("world")
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
println!("!")
|
|
|
|
}
|
2020-01-07 06:06:23 +00:00
|
|
|
|
|
|
|
if let Some(42) = Some(42) {
|
|
|
|
print!("Hello ");
|
|
|
|
} else if x == "hello" {
|
2020-02-04 15:13:06 +00:00
|
|
|
println!("world")
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
println!("!")
|
|
|
|
}
|
2020-01-07 06:06:23 +00:00
|
|
|
|
|
|
|
if let Some(42) = Some(42) {
|
|
|
|
print!("Hello ");
|
|
|
|
} else if let Some(42) = Some(42) {
|
2020-02-04 15:13:06 +00:00
|
|
|
println!("world")
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
println!("!")
|
|
|
|
}
|
2021-02-25 10:25:22 +00:00
|
|
|
|
|
|
|
if x == "hello" {
|
|
|
|
print!("Hello ");
|
|
|
|
} else {
|
|
|
|
#[cfg(not(roflol))]
|
|
|
|
if y == "world" {
|
|
|
|
println!("world!")
|
|
|
|
}
|
|
|
|
}
|
2020-01-07 06:06:23 +00:00
|
|
|
}
|
2022-05-05 14:12:52 +00:00
|
|
|
|
|
|
|
#[rustfmt::skip]
|
|
|
|
#[allow(dead_code)]
|
|
|
|
fn issue_7318() {
|
|
|
|
if true { println!("I've been resolved!")
|
|
|
|
}else if false {}
|
|
|
|
}
|