mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-04 18:40:57 +03:00
Only run MATCH_OVERLAPPING_ARM on integral matches
This commit is contained in:
+4
-3
@@ -98,7 +98,7 @@ fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
|
||||
if let ExprMatch(ref ex, ref arms, MatchSource::Normal) = expr.node {
|
||||
check_single_match(cx, ex, arms, expr);
|
||||
check_match_bool(cx, ex, arms, expr);
|
||||
check_overlapping_arms(cx, arms);
|
||||
check_overlapping_arms(cx, ex, arms);
|
||||
}
|
||||
if let ExprMatch(ref ex, ref arms, source) = expr.node {
|
||||
check_match_ref_pats(cx, ex, arms, source, expr);
|
||||
@@ -187,8 +187,9 @@ fn check_match_bool(cx: &LateContext, ex: &Expr, arms: &[Arm], expr: &Expr) {
|
||||
}
|
||||
}
|
||||
|
||||
fn check_overlapping_arms(cx: &LateContext, arms: &[Arm]) {
|
||||
if arms.len() >= 2 {
|
||||
fn check_overlapping_arms(cx: &LateContext, ex: &Expr, arms: &[Arm]) {
|
||||
if arms.len() >= 2 &&
|
||||
cx.tcx.expr_ty(ex).is_integral() {
|
||||
let ranges = all_ranges(cx, arms);
|
||||
let overlap = match type_ranges(&ranges) {
|
||||
TypedRanges::IntRanges(ranges) => overlapping(&ranges).map(|(start, end)| (start.span, end.span)),
|
||||
|
||||
Reference in New Issue
Block a user