-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Closed
Copy link
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-let_chains`#![feature(let_chains)]``#![feature(let_chains)]`L-irrefutable_let_patternsLint: irrefutable_let_patternsLint: irrefutable_let_patternsT-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.T-langRelevant to the language teamRelevant to the language team
Description
The following triggers irrefutable_let_patterns
:
fn expensive() -> u32 {
0
}
fn option(x: u32) -> Option<u32> {
Some(x)
}
fn f(x: bool) {
if x {
// something
} else if let foo = expensive()
&& let Some(bar) = option(foo)
{
// use `foo` and `bar`
} else {
// something
}
}
Though let foo = expensive()
is irrefutable, it would add an extra layer of nesting to move it into a regular let
statement. e.g.
if x {
// something
} else {
let foo = expensive()
if let Some(bar) = option(foo) {
// use `foo` and `bar`
} else {
// something
}
}
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-let_chains`#![feature(let_chains)]``#![feature(let_chains)]`L-irrefutable_let_patternsLint: irrefutable_let_patternsLint: irrefutable_let_patternsT-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.T-langRelevant to the language teamRelevant to the language team