Skip to content

Commit

Permalink
ignore single-match for or patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Sep 25, 2019
1 parent 982c51e commit b5cadd7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions clippy_lints/src/matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b5cadd7

Please sign in to comment.