rust/tests/ui/collapsible_if_let_chains.fixed
Samuel Tardieu cd70152470 Make collapsible_if recognize the let_chains feature
Until `if let` chains are stabilized, we do not collapse them together
or with other `if` expressions unless the `let_chains` feature is
enabled. This is the case for example in Clippy sources.
2025-03-27 14:40:44 +01:00

29 lines
604 B
Rust

#![feature(let_chains)]
#![warn(clippy::collapsible_if)]
fn main() {
if let Some(a) = Some(3) {
// with comment, so do not lint
if let Some(b) = Some(4) {
let _ = a + b;
}
}
if let Some(a) = Some(3)
&& let Some(b) = Some(4) {
let _ = a + b;
}
//~^^^^^ collapsible_if
if let Some(a) = Some(3)
&& a + 1 == 4 {
let _ = a;
}
//~^^^^^ collapsible_if
if Some(3) == Some(4).map(|x| x - 1)
&& let Some(b) = Some(4) {
let _ = b;
}
//~^^^^^ collapsible_if
}