2015-05-29 09:07:34 -05:00
|
|
|
#![feature(plugin)]
|
|
|
|
#![plugin(clippy)]
|
|
|
|
|
|
|
|
#[deny(collapsible_if)]
|
|
|
|
fn main() {
|
|
|
|
let x = "hello";
|
|
|
|
let y = "world";
|
2015-08-12 03:46:49 -05:00
|
|
|
if x == "hello" { //~ERROR this if statement can be collapsed
|
2015-05-29 09:07:34 -05:00
|
|
|
if y == "world" {
|
|
|
|
println!("Hello world!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-12 03:46:49 -05:00
|
|
|
if x == "hello" || x == "world" { //~ERROR this if statement can be collapsed
|
2015-05-29 09:07:34 -05:00
|
|
|
if y == "world" || y == "hello" {
|
|
|
|
println!("Hello world!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Works because any if with an else statement cannot be collapsed.
|
|
|
|
if x == "hello" {
|
|
|
|
if y == "world" {
|
|
|
|
println!("Hello world!");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
println!("Not Hello world");
|
|
|
|
}
|
|
|
|
|
|
|
|
if x == "hello" {
|
|
|
|
if y == "world" {
|
|
|
|
println!("Hello world!");
|
|
|
|
} else {
|
|
|
|
println!("Hello something else");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-11 13:22:20 -05:00
|
|
|
if x == "hello" {
|
|
|
|
print!("Hello ");
|
|
|
|
if y == "world" {
|
|
|
|
println!("world!")
|
|
|
|
}
|
|
|
|
}
|
2015-05-29 09:07:34 -05:00
|
|
|
}
|