From 3bdf40407606b82becacdb1c0f77e73c2f6c9871 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sat, 11 Jan 2020 23:21:09 +0900 Subject: [PATCH] Apply review comments --- clippy_lints/src/matches.rs | 51 ++++++++++++------------------------- 1 file changed, 16 insertions(+), 35 deletions(-) diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index b11faef1f0d..6e89cba1627 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -716,41 +716,22 @@ fn all_ranges<'a, 'tcx>( } = *arm { if let PatKind::Range(ref lhs, ref rhs, range_end) = pat.kind { - match (lhs, rhs) { - (Some(lhs), Some(rhs)) => { - let lhs = constant(cx, cx.tables, lhs)?.0; - let rhs = constant(cx, cx.tables, rhs)?.0; - let rhs = match range_end { - RangeEnd::Included => Bound::Included(rhs), - RangeEnd::Excluded => Bound::Excluded(rhs), - }; - return Some(SpannedRange { - span: pat.span, - node: (lhs, rhs), - }); - }, - (None, Some(rhs)) => { - let lhs = miri_to_const(ty.numeric_min_val(cx.tcx)?)?; - let rhs = constant(cx, cx.tables, rhs)?.0; - let rhs = match range_end { - RangeEnd::Included => Bound::Included(rhs), - RangeEnd::Excluded => Bound::Excluded(rhs), - }; - return Some(SpannedRange { - span: pat.span, - node: (lhs, rhs), - }); - }, - (Some(lhs), None) => { - let lhs = constant(cx, cx.tables, lhs)?.0; - let rhs = miri_to_const(ty.numeric_max_val(cx.tcx)?)?; - return Some(SpannedRange { - span: pat.span, - node: (lhs, Bound::Excluded(rhs)), - }); - }, - _ => return None, - } + let lhs = match lhs { + Some(lhs) => constant(cx, cx.tables, lhs)?.0, + None => miri_to_const(ty.numeric_min_val(cx.tcx)?)?, + }; + let rhs = match rhs { + Some(rhs) => constant(cx, cx.tables, rhs)?.0, + None => miri_to_const(ty.numeric_max_val(cx.tcx)?)?, + }; + let rhs = match range_end { + RangeEnd::Included => Bound::Included(rhs), + RangeEnd::Excluded => Bound::Excluded(rhs), + }; + return Some(SpannedRange { + span: pat.span, + node: (lhs, rhs), + }); } if let PatKind::Lit(ref value) = pat.kind {