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

Commit 246a5e0

Browse files
committed
Remove ty arg from compare_const_vals.
It's now only used in no-longer-interesting assertion.
1 parent 3ab6ef1 commit 246a5e0

File tree

3 files changed

+8
-21
lines changed

3 files changed

+8
-21
lines changed

compiler/rustc_mir_build/src/build/matches/test.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -639,16 +639,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
639639
return Some(0);
640640
}
641641

642-
let tcx = self.tcx;
643-
let test_ty = test.lo.ty();
644-
645642
// For performance, it's important to only do the second
646643
// `compare_const_vals` if necessary.
647644
let no_overlap = if matches!(
648-
(compare_const_vals(tcx, test.hi, pat.lo, self.param_env, test_ty)?, test.end),
645+
(compare_const_vals(self.tcx, test.hi, pat.lo, self.param_env)?, test.end),
649646
(Less, _) | (Equal, RangeEnd::Excluded) // test < pat
650647
) || matches!(
651-
(compare_const_vals(tcx, test.lo, pat.hi, self.param_env, test_ty)?, pat.end),
648+
(compare_const_vals(self.tcx, test.lo, pat.hi, self.param_env)?, pat.end),
652649
(Greater, _) | (Equal, RangeEnd::Excluded) // test > pat
653650
) {
654651
Some(1)
@@ -762,15 +759,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
762759
) -> Option<bool> {
763760
use std::cmp::Ordering::*;
764761

765-
let tcx = self.tcx;
766-
let param_env = self.param_env;
767-
let ty = range.lo.ty();
768762
// For performance, it's important to only do the second
769763
// `compare_const_vals` if necessary.
770764
Some(
771-
matches!(compare_const_vals(tcx, range.lo, value, param_env, ty)?, Less | Equal)
765+
matches!(compare_const_vals(self.tcx, range.lo, value, self.param_env)?, Less | Equal)
772766
&& matches!(
773-
(compare_const_vals(tcx, value, range.hi, param_env, ty)?, range.end),
767+
(compare_const_vals(self.tcx, value, range.hi, self.param_env)?, range.end),
774768
(Less, _) | (Equal, RangeEnd::Included)
775769
),
776770
)

compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -828,14 +828,8 @@ impl<'tcx> Constructor<'tcx> {
828828
FloatRange(other_from, other_to, other_end),
829829
) => {
830830
match (
831-
compare_const_vals(pcx.cx.tcx, *self_to, *other_to, pcx.cx.param_env, pcx.ty),
832-
compare_const_vals(
833-
pcx.cx.tcx,
834-
*self_from,
835-
*other_from,
836-
pcx.cx.param_env,
837-
pcx.ty,
838-
),
831+
compare_const_vals(pcx.cx.tcx, *self_to, *other_to, pcx.cx.param_env),
832+
compare_const_vals(pcx.cx.tcx, *self_from, *other_from, pcx.cx.param_env),
839833
) {
840834
(Some(to), Some(from)) => {
841835
(from == Ordering::Greater || from == Ordering::Equal)

compiler/rustc_mir_build/src/thir/pattern/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
128128
) -> PatKind<'tcx> {
129129
assert_eq!(lo.ty(), ty);
130130
assert_eq!(hi.ty(), ty);
131-
let cmp = compare_const_vals(self.tcx, lo, hi, self.param_env, ty);
131+
let cmp = compare_const_vals(self.tcx, lo, hi, self.param_env);
132132
match (end, cmp) {
133133
// `x..y` where `x < y`.
134134
// Non-empty because the range includes at least `x`.
@@ -752,15 +752,14 @@ pub(crate) fn compare_const_vals<'tcx>(
752752
a: mir::ConstantKind<'tcx>,
753753
b: mir::ConstantKind<'tcx>,
754754
param_env: ty::ParamEnv<'tcx>,
755-
ty: Ty<'tcx>,
756755
) -> Option<Ordering> {
757756
assert_eq!(a.ty(), b.ty());
758-
assert_eq!(a.ty(), ty);
759757

760758
if a == b {
761759
return Some(Ordering::Equal);
762760
}
763761

762+
let ty = a.ty();
764763
let a_bits = a.try_eval_bits(tcx, param_env, ty);
765764
let b_bits = b.try_eval_bits(tcx, param_env, ty);
766765

0 commit comments

Comments
 (0)