Remove ty
arg from compare_const_vals
.
It's now only used in no-longer-interesting assertion.
This commit is contained in:
parent
3ab6ef1938
commit
246a5e08bf
3 changed files with 8 additions and 21 deletions
|
@ -639,16 +639,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
return Some(0);
|
||||
}
|
||||
|
||||
let tcx = self.tcx;
|
||||
let test_ty = test.lo.ty();
|
||||
|
||||
// For performance, it's important to only do the second
|
||||
// `compare_const_vals` if necessary.
|
||||
let no_overlap = if matches!(
|
||||
(compare_const_vals(tcx, test.hi, pat.lo, self.param_env, test_ty)?, test.end),
|
||||
(compare_const_vals(self.tcx, test.hi, pat.lo, self.param_env)?, test.end),
|
||||
(Less, _) | (Equal, RangeEnd::Excluded) // test < pat
|
||||
) || matches!(
|
||||
(compare_const_vals(tcx, test.lo, pat.hi, self.param_env, test_ty)?, pat.end),
|
||||
(compare_const_vals(self.tcx, test.lo, pat.hi, self.param_env)?, pat.end),
|
||||
(Greater, _) | (Equal, RangeEnd::Excluded) // test > pat
|
||||
) {
|
||||
Some(1)
|
||||
|
@ -762,15 +759,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
) -> Option<bool> {
|
||||
use std::cmp::Ordering::*;
|
||||
|
||||
let tcx = self.tcx;
|
||||
let param_env = self.param_env;
|
||||
let ty = range.lo.ty();
|
||||
// For performance, it's important to only do the second
|
||||
// `compare_const_vals` if necessary.
|
||||
Some(
|
||||
matches!(compare_const_vals(tcx, range.lo, value, param_env, ty)?, Less | Equal)
|
||||
matches!(compare_const_vals(self.tcx, range.lo, value, self.param_env)?, Less | Equal)
|
||||
&& matches!(
|
||||
(compare_const_vals(tcx, value, range.hi, param_env, ty)?, range.end),
|
||||
(compare_const_vals(self.tcx, value, range.hi, self.param_env)?, range.end),
|
||||
(Less, _) | (Equal, RangeEnd::Included)
|
||||
),
|
||||
)
|
||||
|
|
|
@ -828,14 +828,8 @@ impl<'tcx> Constructor<'tcx> {
|
|||
FloatRange(other_from, other_to, other_end),
|
||||
) => {
|
||||
match (
|
||||
compare_const_vals(pcx.cx.tcx, *self_to, *other_to, pcx.cx.param_env, pcx.ty),
|
||||
compare_const_vals(
|
||||
pcx.cx.tcx,
|
||||
*self_from,
|
||||
*other_from,
|
||||
pcx.cx.param_env,
|
||||
pcx.ty,
|
||||
),
|
||||
compare_const_vals(pcx.cx.tcx, *self_to, *other_to, pcx.cx.param_env),
|
||||
compare_const_vals(pcx.cx.tcx, *self_from, *other_from, pcx.cx.param_env),
|
||||
) {
|
||||
(Some(to), Some(from)) => {
|
||||
(from == Ordering::Greater || from == Ordering::Equal)
|
||||
|
|
|
@ -128,7 +128,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
) -> PatKind<'tcx> {
|
||||
assert_eq!(lo.ty(), ty);
|
||||
assert_eq!(hi.ty(), ty);
|
||||
let cmp = compare_const_vals(self.tcx, lo, hi, self.param_env, ty);
|
||||
let cmp = compare_const_vals(self.tcx, lo, hi, self.param_env);
|
||||
match (end, cmp) {
|
||||
// `x..y` where `x < y`.
|
||||
// Non-empty because the range includes at least `x`.
|
||||
|
@ -752,15 +752,14 @@ pub(crate) fn compare_const_vals<'tcx>(
|
|||
a: mir::ConstantKind<'tcx>,
|
||||
b: mir::ConstantKind<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
) -> Option<Ordering> {
|
||||
assert_eq!(a.ty(), b.ty());
|
||||
assert_eq!(a.ty(), ty);
|
||||
|
||||
if a == b {
|
||||
return Some(Ordering::Equal);
|
||||
}
|
||||
|
||||
let ty = a.ty();
|
||||
let a_bits = a.try_eval_bits(tcx, param_env, ty);
|
||||
let b_bits = b.try_eval_bits(tcx, param_env, ty);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue