|
1 | | -use clippy_utils::consts::{constant, constant_full_int, FullInt}; |
| 1 | +use clippy_utils::consts::{constant, constant_full_int, miri_to_const, FullInt}; |
2 | 2 | use clippy_utils::diagnostics::span_lint_and_note; |
3 | 3 | use core::cmp::Ordering; |
4 | 4 | use rustc_hir::{Arm, Expr, PatKind, RangeEnd}; |
@@ -32,15 +32,16 @@ fn all_ranges<'tcx>(cx: &LateContext<'tcx>, arms: &'tcx [Arm<'_>], ty: Ty<'tcx>) |
32 | 32 | .filter_map(|arm| { |
33 | 33 | if let Arm { pat, guard: None, .. } = *arm { |
34 | 34 | 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)?)?, |
38 | 38 | }; |
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)?)?, |
42 | 42 | }; |
43 | | - |
| 43 | + let lhs_val = lhs_const.int_value(cx, ty)?; |
| 44 | + let rhs_val = rhs_const.int_value(cx, ty)?; |
44 | 45 | let rhs_bound = match range_end { |
45 | 46 | RangeEnd::Included => EndBound::Included(rhs_val), |
46 | 47 | RangeEnd::Excluded => EndBound::Excluded(rhs_val), |
|
0 commit comments