mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 15:23:46 +00:00
Remove one use of compare_const_vals
.
A direct comparison has the same effect. This also avoids the need for a type test within `compare_const_vals`.
This commit is contained in:
parent
9b4b34a0a6
commit
b67635fdfd
@ -848,16 +848,7 @@ impl<'tcx> Constructor<'tcx> {
|
||||
(Str(self_val), Str(other_val)) => {
|
||||
// FIXME Once valtrees are available we can directly use the bytes
|
||||
// in the `Str` variant of the valtree for the comparison here.
|
||||
match compare_const_vals(
|
||||
pcx.cx.tcx,
|
||||
*self_val,
|
||||
*other_val,
|
||||
pcx.cx.param_env,
|
||||
pcx.ty,
|
||||
) {
|
||||
Some(comparison) => comparison == Ordering::Equal,
|
||||
None => false,
|
||||
}
|
||||
self_val == other_val
|
||||
}
|
||||
(Slice(self_slice), Slice(other_slice)) => self_slice.is_covered_by(*other_slice),
|
||||
|
||||
|
@ -755,16 +755,12 @@ pub(crate) fn compare_const_vals<'tcx>(
|
||||
ty: Ty<'tcx>,
|
||||
) -> Option<Ordering> {
|
||||
assert_eq!(a.ty(), b.ty());
|
||||
assert_eq!(a.ty(), ty);
|
||||
|
||||
let from_bool = |v: bool| v.then_some(Ordering::Equal);
|
||||
|
||||
let fallback = || from_bool(a == b);
|
||||
|
||||
// Use the fallback if any type differs
|
||||
if a.ty() != ty {
|
||||
return fallback();
|
||||
}
|
||||
|
||||
if a == b {
|
||||
return from_bool(true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user