Skip to content

Commit 2f78075

Browse files
committed
get rid of visit_constant in thir visitor
1 parent bca346b commit 2f78075

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

clippy_lints/src/matches/overlapping_arms.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use clippy_utils::consts::{constant, constant_full_int, FullInt};
1+
use clippy_utils::consts::{constant, constant_full_int, miri_to_const, FullInt};
22
use clippy_utils::diagnostics::span_lint_and_note;
33
use core::cmp::Ordering;
44
use rustc_hir::{Arm, Expr, PatKind, RangeEnd};
@@ -32,15 +32,16 @@ fn all_ranges<'tcx>(cx: &LateContext<'tcx>, arms: &'tcx [Arm<'_>], ty: Ty<'tcx>)
3232
.filter_map(|arm| {
3333
if let Arm { pat, guard: None, .. } = *arm {
3434
if let PatKind::Range(ref lhs, ref rhs, range_end) = pat.kind {
35-
let lhs_val = match lhs {
36-
Some(lhs) => constant(cx, cx.typeck_results(), lhs)?.0.int_value(cx, ty)?,
37-
None => FullInt::U(ty.numeric_min_val(cx.tcx)?),
35+
let lhs_const = match lhs {
36+
Some(lhs) => constant(cx, cx.typeck_results(), lhs)?.0,
37+
None => miri_to_const(ty.numeric_min_val(cx.tcx)?)?,
3838
};
39-
let rhs_val = match rhs {
40-
Some(rhs) => constant(cx, cx.typeck_results(), rhs)?.0.int_value(cx, ty)?,
41-
None => FullInt::U(ty.numeric_max_val(cx.tcx)?),
39+
let rhs_const = match rhs {
40+
Some(rhs) => constant(cx, cx.typeck_results(), rhs)?.0,
41+
None => miri_to_const(ty.numeric_max_val(cx.tcx)?)?,
4242
};
43-
43+
let lhs_val = lhs_const.int_value(cx, ty)?;
44+
let rhs_val = rhs_const.int_value(cx, ty)?;
4445
let rhs_bound = match range_end {
4546
RangeEnd::Included => EndBound::Included(rhs_val),
4647
RangeEnd::Excluded => EndBound::Excluded(rhs_val),

0 commit comments

Comments
 (0)