shrink TestBranch::Constant and PatRangeBoundary::Finite

This commit is contained in:
Ralf Jung
2025-07-29 13:28:47 +02:00
parent a1acbfb050
commit dbc030e034
5 changed files with 23 additions and 17 deletions

View File

@@ -722,7 +722,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
match ScalarInt::try_from_uint(bits, size) {
Some(scalar) => {
let valtree = ty::ValTree::from_scalar_int(tcx, scalar);
PatRangeBoundary::Finite(ty::Value { ty: ty.inner(), valtree })
PatRangeBoundary::Finite(valtree)
}
// The value doesn't fit. Since `x >= 0` and 0 always encodes the minimum value
// for a type, the problem isn't that the value is too small. So it must be too
@@ -742,7 +742,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
"_".to_string()
} else if range.is_singleton() {
let lo = cx.hoist_pat_range_bdy(range.lo, ty);
let value = lo.as_finite().unwrap();
let value = ty::Value { ty: ty.inner(), valtree: lo.as_finite().unwrap() };
value.to_string()
} else {
// We convert to an inclusive range for diagnostics.
@@ -756,7 +756,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
// probably clear enough.
let max = ty.numeric_max_val(cx.tcx).unwrap();
let max = ty::ValTree::from_scalar_int(cx.tcx, max.try_to_scalar_int().unwrap());
lo = PatRangeBoundary::Finite(ty::Value { ty: ty.inner(), valtree: max });
lo = PatRangeBoundary::Finite(max);
}
let hi = if let Some(hi) = range.hi.minus_one() {
hi