Closed
Description
#![feature(if_let_guard, let_chains)]
pub fn example(x: Option<Option<&str>>) {
match x {
Some(y) if let z = y.expect("can't be Some(None)") && z != "foo" => {
dbg!(z);
}
_ => (),
}
}
yields this warning:
warning: leading irrefutable pattern in let chain
--> src/lib.rs:5:20
|
5 | Some(y) if let z = y.expect("can't be Some(None)") && z != "foo" => {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(irrefutable_let_patterns)]` on by default
= note: this pattern will always match
= help: consider moving it outside of the construct
However, the suggestion to move it out of the construct doesn't make sense, as y
isn't bound until we've entered the match arm in the first place.