mirror of
https://github.com/rust-lang/rust.git
synced 2025-12-30 10:15:31 +00:00
Labeled blocks cannot be used as-is in the "then" or "else" part of an `if` expression. They must be enclosed in an anonymous block.
65 lines
1.1 KiB
Rust
65 lines
1.1 KiB
Rust
#![deny(clippy::match_bool)]
|
|
#![allow(clippy::nonminimal_bool, clippy::eq_op)]
|
|
|
|
fn match_bool() {
|
|
let test: bool = true;
|
|
|
|
if test { 0 } else { 42 };
|
|
|
|
let option = 1;
|
|
if option == 1 { 1 } else { 0 };
|
|
|
|
if !test {
|
|
println!("Noooo!");
|
|
};
|
|
|
|
if !test {
|
|
println!("Noooo!");
|
|
};
|
|
|
|
if !(test && test) {
|
|
println!("Noooo!");
|
|
};
|
|
|
|
if !test {
|
|
println!("Noooo!");
|
|
} else {
|
|
println!("Yes!");
|
|
};
|
|
|
|
// Not linted
|
|
match option {
|
|
1..=10 => 1,
|
|
11..=20 => 2,
|
|
_ => 3,
|
|
};
|
|
|
|
// Don't lint
|
|
let _ = match test {
|
|
#[cfg(feature = "foo")]
|
|
true if option == 5 => 10,
|
|
true => 0,
|
|
false => 1,
|
|
};
|
|
|
|
let _ = if test && option == 5 { 10 } else { 1 };
|
|
|
|
let _ = if !test && option == 5 { 10 } else { 1 };
|
|
|
|
if test && option == 5 { println!("Hello") };
|
|
|
|
if !(test && option == 5) { println!("Hello") };
|
|
|
|
if !test && option == 5 { println!("Hello") };
|
|
|
|
if !(!test && option == 5) { println!("Hello") };
|
|
}
|
|
|
|
fn issue14099() {
|
|
if true { 'a: {
|
|
break 'a;
|
|
} }
|
|
}
|
|
|
|
fn main() {}
|