Skip to content

Commit b123415

Browse files
committed
Store Const directly in ConstantRange
1 parent 4b4e6bd commit b123415

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/librustc_mir/hair/pattern/_match.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ enum Constructor<'tcx> {
587587
/// Ranges of integer literal values (`2`, `2..=5` or `2..5`).
588588
IntRange(IntRange<'tcx>),
589589
/// Ranges of non-integer literal values (`2.0..=5.2`).
590-
ConstantRange(u128, u128, Ty<'tcx>, RangeEnd, Span),
590+
ConstantRange(&'tcx ty::Const<'tcx>, &'tcx ty::Const<'tcx>, Ty<'tcx>, RangeEnd, Span),
591591
/// Array patterns of length `n`.
592592
FixedLenSlice(u64),
593593
/// Slice patterns. Captures any array constructor of `length >= i + j`.
@@ -926,11 +926,7 @@ impl<'tcx> Constructor<'tcx> {
926926

927927
_ => match *self {
928928
ConstantValue(value, _) => PatKind::Constant { value },
929-
ConstantRange(lo, hi, ty, end, _) => PatKind::Range(PatRange {
930-
lo: ty::Const::from_bits(cx.tcx, lo, ty::ParamEnv::empty().and(ty)),
931-
hi: ty::Const::from_bits(cx.tcx, hi, ty::ParamEnv::empty().and(ty)),
932-
end,
933-
}),
929+
ConstantRange(lo, hi, _, end, _) => PatKind::Range(PatRange { lo, hi, end }),
934930
IntRange(ref range) => {
935931
return range.to_pat(cx.tcx);
936932
}
@@ -1719,9 +1715,14 @@ fn pat_constructor<'tcx>(
17191715
}
17201716
PatKind::Range(PatRange { lo, hi, end }) => {
17211717
let ty = lo.ty;
1722-
let lo = lo.eval_bits(tcx, param_env, lo.ty);
1723-
let hi = hi.eval_bits(tcx, param_env, hi.ty);
1724-
if let Some(int_range) = IntRange::from_range(tcx, lo, hi, ty, &end, pat.span) {
1718+
if let Some(int_range) = IntRange::from_range(
1719+
tcx,
1720+
lo.eval_bits(tcx, param_env, lo.ty),
1721+
hi.eval_bits(tcx, param_env, hi.ty),
1722+
ty,
1723+
&end,
1724+
pat.span,
1725+
) {
17251726
Some(IntRange(int_range))
17261727
} else {
17271728
Some(ConstantRange(lo, hi, ty, end, pat.span))
@@ -2108,10 +2109,9 @@ fn constructor_covered_by_range<'tcx>(
21082109
PatKind::Range(PatRange { lo, hi, end }) => (lo, hi, end, lo.ty),
21092110
_ => bug!("`constructor_covered_by_range` called with {:?}", pat),
21102111
};
2111-
let from_bits = |bits| ty::Const::from_bits(tcx, bits, ty::ParamEnv::empty().and(ty));
21122112
let (ctor_from, ctor_to, ctor_end) = match *ctor {
21132113
ConstantValue(value, _) => (value, value, RangeEnd::Included),
2114-
ConstantRange(from, to, _, ctor_end, _) => (from_bits(from), from_bits(to), ctor_end),
2114+
ConstantRange(from, to, _, ctor_end, _) => (from, to, ctor_end),
21152115
_ => bug!("`constructor_covered_by_range` called with {:?}", ctor),
21162116
};
21172117
trace!("constructor_covered_by_range {:#?}, {:#?}, {:#?}, {}", ctor, pat_from, pat_to, ty);

0 commit comments

Comments
 (0)