mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 15:11:30 +00:00
96 lines
1.8 KiB
Rust
96 lines
1.8 KiB
Rust
#![allow(clippy::assertions_on_constants, clippy::equatable_if_let, clippy::needless_if)]
|
|
#![warn(clippy::collapsible_if, clippy::collapsible_else_if)]
|
|
|
|
#[rustfmt::skip]
|
|
fn main() {
|
|
let x = "hello";
|
|
let y = "world";
|
|
// Collapse `else { if .. }` to `else if ..`
|
|
if x == "hello" {
|
|
print!("Hello ");
|
|
} else {
|
|
if y == "world" {
|
|
println!("world!")
|
|
}
|
|
}
|
|
|
|
if x == "hello" {
|
|
print!("Hello ");
|
|
} else {
|
|
if let Some(42) = Some(42) {
|
|
println!("world!")
|
|
}
|
|
}
|
|
|
|
if x == "hello" {
|
|
print!("Hello ");
|
|
} else {
|
|
if y == "world" {
|
|
println!("world")
|
|
}
|
|
else {
|
|
println!("!")
|
|
}
|
|
}
|
|
|
|
if x == "hello" {
|
|
print!("Hello ");
|
|
} else {
|
|
if let Some(42) = Some(42) {
|
|
println!("world")
|
|
}
|
|
else {
|
|
println!("!")
|
|
}
|
|
}
|
|
|
|
if let Some(42) = Some(42) {
|
|
print!("Hello ");
|
|
} else {
|
|
if let Some(42) = Some(42) {
|
|
println!("world")
|
|
}
|
|
else {
|
|
println!("!")
|
|
}
|
|
}
|
|
|
|
if let Some(42) = Some(42) {
|
|
print!("Hello ");
|
|
} else {
|
|
if x == "hello" {
|
|
println!("world")
|
|
}
|
|
else {
|
|
println!("!")
|
|
}
|
|
}
|
|
|
|
if let Some(42) = Some(42) {
|
|
print!("Hello ");
|
|
} else {
|
|
if let Some(42) = Some(42) {
|
|
println!("world")
|
|
}
|
|
else {
|
|
println!("!")
|
|
}
|
|
}
|
|
|
|
if x == "hello" {
|
|
print!("Hello ");
|
|
} else {
|
|
#[cfg(not(roflol))]
|
|
if y == "world" {
|
|
println!("world!")
|
|
}
|
|
}
|
|
}
|
|
|
|
#[rustfmt::skip]
|
|
fn issue_7318() {
|
|
if true { println!("I've been resolved!")
|
|
}else{
|
|
if false {}
|
|
}
|
|
}
|