Skip to content

Commit 3bdf404

Browse files
committed
Apply review comments
1 parent 3994799 commit 3bdf404

File tree

1 file changed

+16
-35
lines changed

1 file changed

+16
-35
lines changed

clippy_lints/src/matches.rs

+16-35
Original file line numberDiff line numberDiff line change
@@ -716,41 +716,22 @@ fn all_ranges<'a, 'tcx>(
716716
} = *arm
717717
{
718718
if let PatKind::Range(ref lhs, ref rhs, range_end) = pat.kind {
719-
match (lhs, rhs) {
720-
(Some(lhs), Some(rhs)) => {
721-
let lhs = constant(cx, cx.tables, lhs)?.0;
722-
let rhs = constant(cx, cx.tables, rhs)?.0;
723-
let rhs = match range_end {
724-
RangeEnd::Included => Bound::Included(rhs),
725-
RangeEnd::Excluded => Bound::Excluded(rhs),
726-
};
727-
return Some(SpannedRange {
728-
span: pat.span,
729-
node: (lhs, rhs),
730-
});
731-
},
732-
(None, Some(rhs)) => {
733-
let lhs = miri_to_const(ty.numeric_min_val(cx.tcx)?)?;
734-
let rhs = constant(cx, cx.tables, rhs)?.0;
735-
let rhs = match range_end {
736-
RangeEnd::Included => Bound::Included(rhs),
737-
RangeEnd::Excluded => Bound::Excluded(rhs),
738-
};
739-
return Some(SpannedRange {
740-
span: pat.span,
741-
node: (lhs, rhs),
742-
});
743-
},
744-
(Some(lhs), None) => {
745-
let lhs = constant(cx, cx.tables, lhs)?.0;
746-
let rhs = miri_to_const(ty.numeric_max_val(cx.tcx)?)?;
747-
return Some(SpannedRange {
748-
span: pat.span,
749-
node: (lhs, Bound::Excluded(rhs)),
750-
});
751-
},
752-
_ => return None,
753-
}
719+
let lhs = match lhs {
720+
Some(lhs) => constant(cx, cx.tables, lhs)?.0,
721+
None => miri_to_const(ty.numeric_min_val(cx.tcx)?)?,
722+
};
723+
let rhs = match rhs {
724+
Some(rhs) => constant(cx, cx.tables, rhs)?.0,
725+
None => miri_to_const(ty.numeric_max_val(cx.tcx)?)?,
726+
};
727+
let rhs = match range_end {
728+
RangeEnd::Included => Bound::Included(rhs),
729+
RangeEnd::Excluded => Bound::Excluded(rhs),
730+
};
731+
return Some(SpannedRange {
732+
span: pat.span,
733+
node: (lhs, rhs),
734+
});
754735
}
755736

756737
if let PatKind::Lit(ref value) = pat.kind {

0 commit comments

Comments
 (0)