-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.F-if_let_guard`#![feature(if_let_guard)]``#![feature(if_let_guard)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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.
compiler-errors and ChayimFriedman2
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.F-if_let_guard`#![feature(if_let_guard)]``#![feature(if_let_guard)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.