Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit f4bf855

Browse files
committed
perf+
1 parent 56f21c0 commit f4bf855

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

compiler/rustc_middle/src/thir.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,13 @@ impl<'tcx> PatRangeBoundary<'tcx> {
941941
param_env: ty::ParamEnv<'tcx>,
942942
) -> u128 {
943943
match self {
944+
Self::Finite {
945+
value: mir::Const::Val(mir::ConstValue::Scalar(Scalar::Int(scalar_int)), _),
946+
} => scalar_int.assert_bits(scalar_int.size()),
947+
Self::Finite {
948+
value: mir::Const::Ty(c),
949+
} if let ty::ConstKind::Value(ty::ValTree::Leaf(scalar_int)) = c.kind()
950+
=> scalar_int.assert_bits(scalar_int.size()),
944951
Self::Finite { value } => value.eval_bits(tcx, param_env),
945952
// Self::NegInfinity => {
946953
// // Unwrap is ok because the type is known to be numeric.
@@ -977,10 +984,6 @@ impl<'tcx> PatRangeBoundary<'tcx> {
977984
{
978985
return Some(a.kind().cmp(&b.kind()));
979986
}
980-
(
981-
Finite { value: mir::Const::Val(mir::ConstValue::Scalar(Scalar::Int(a)), _) },
982-
Finite { value: mir::Const::Val(mir::ConstValue::Scalar(Scalar::Int(b)), _) },
983-
) if matches!(ty.kind(), ty::Uint(_) | ty::Char) => return Some(a.cmp(&b)),
984987
_ => {}
985988
}
986989

0 commit comments

Comments
 (0)