Skip to content

Commit f674f89

Browse files
committed
Store Const directly in ConstantRange
1 parent 0192124 commit f674f89

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/librustc_mir/hair/pattern/_match.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ enum Constructor<'tcx> {
594594
/// Ranges of integer literal values (`2`, `2..=5` or `2..5`).
595595
IntRange(IntRange<'tcx>),
596596
/// Ranges of non-integer literal values (`2.0..=5.2`).
597-
ConstantRange(u128, u128, Ty<'tcx>, RangeEnd, Span),
597+
ConstantRange(&'tcx ty::Const<'tcx>, &'tcx ty::Const<'tcx>, Ty<'tcx>, RangeEnd, Span),
598598
/// Array patterns of length `n`.
599599
FixedLenSlice(u64),
600600
/// Slice patterns. Captures any array constructor of `length >= i + j`.
@@ -939,11 +939,7 @@ impl<'tcx> Constructor<'tcx> {
939939
PatKind::Slice { prefix, slice: Some(wild), suffix }
940940
}
941941
&ConstantValue(value, _) => PatKind::Constant { value },
942-
&ConstantRange(lo, hi, ty, end, _) => PatKind::Range(PatRange {
943-
lo: ty::Const::from_bits(cx.tcx, lo, ty::ParamEnv::empty().and(ty)),
944-
hi: ty::Const::from_bits(cx.tcx, hi, ty::ParamEnv::empty().and(ty)),
945-
end,
946-
}),
942+
&ConstantRange(lo, hi, _, end, _) => PatKind::Range(PatRange { lo, hi, end }),
947943
IntRange(range) => {
948944
return range.to_pat(cx.tcx);
949945
}
@@ -1730,9 +1726,14 @@ fn pat_constructor<'tcx>(
17301726
}
17311727
PatKind::Range(PatRange { lo, hi, end }) => {
17321728
let ty = lo.ty;
1733-
let lo = lo.eval_bits(tcx, param_env, lo.ty);
1734-
let hi = hi.eval_bits(tcx, param_env, hi.ty);
1735-
if let Some(int_range) = IntRange::from_range(tcx, lo, hi, ty, &end, pat.span) {
1729+
if let Some(int_range) = IntRange::from_range(
1730+
tcx,
1731+
lo.eval_bits(tcx, param_env, lo.ty),
1732+
hi.eval_bits(tcx, param_env, hi.ty),
1733+
ty,
1734+
&end,
1735+
pat.span,
1736+
) {
17361737
Some(IntRange(int_range))
17371738
} else {
17381739
Some(ConstantRange(lo, hi, ty, end, pat.span))
@@ -2132,10 +2133,9 @@ fn constructor_covered_by_range<'tcx>(
21322133
PatKind::Range(PatRange { lo, hi, end }) => (lo, hi, end, lo.ty),
21332134
_ => bug!("`constructor_covered_by_range` called with {:?}", pat),
21342135
};
2135-
let from_bits = |bits| ty::Const::from_bits(tcx, bits, ty::ParamEnv::empty().and(ty));
21362136
let (ctor_from, ctor_to, ctor_end) = match *ctor {
21372137
ConstantValue(value, _) => (value, value, RangeEnd::Included),
2138-
ConstantRange(from, to, _, ctor_end, _) => (from_bits(from), from_bits(to), ctor_end),
2138+
ConstantRange(from, to, _, ctor_end, _) => (from, to, ctor_end),
21392139
_ => bug!("`constructor_covered_by_range` called with {:?}", ctor),
21402140
};
21412141
trace!("constructor_covered_by_range {:#?}, {:#?}, {:#?}, {}", ctor, pat_from, pat_to, ty);

0 commit comments

Comments
 (0)