diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2020-01-11 23:21:09 +0900 |
|---|---|---|
| committer | Yuki Okushi <huyuumi.dev@gmail.com> | 2020-01-11 23:21:09 +0900 |
| commit | 3bdf40407606b82becacdb1c0f77e73c2f6c9871 (patch) | |
| tree | 2b0ee1c03f365d5e099663977d6eaf1641ed85d3 | |
| parent | 39947992b57239de6581c9761dfad7ac3cf001c8 (diff) | |
| download | rust-3bdf40407606b82becacdb1c0f77e73c2f6c9871.tar.gz rust-3bdf40407606b82becacdb1c0f77e73c2f6c9871.zip | |
Apply review comments
| -rw-r--r-- | clippy_lints/src/matches.rs | 51 |
1 files 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 { |
