From b5cadd734eed6f4ba317550f8d6e3ab019fe1bcb Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 25 Sep 2019 13:34:55 -0700 Subject: [PATCH] ignore single-match for or patterns --- clippy_lints/src/matches.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index 3d765af21..ac4f012f3 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -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