mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-03 18:09:42 +00:00
ignore single-match for or patterns
This commit is contained in:
parent
982c51e769
commit
b5cadd734e
1 changed files with 5 additions and 0 deletions
|
@ -255,6 +255,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Matches {
|
|||
#[rustfmt::skip]
|
||||
fn check_single_match(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm], expr: &Expr) {
|
||||
if arms.len() == 2 && arms[0].guard.is_none() && arms[1].guard.is_none() {
|
||||
if let PatKind::Or(..) = arms[0].pat.node {
|
||||
// don't lint for or patterns for now, this makes
|
||||
// the lint noisy in unnecessary situations
|
||||
return;
|
||||
}
|
||||
let els = remove_blocks(&arms[1].body);
|
||||
let els = if is_unit_expr(els) {
|
||||
None
|
||||
|
|
Loading…
Reference in a new issue