Skip to content

Commit b67635f

Browse files
committed
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`.
1 parent 9b4b34a commit b67635f

File tree

2 files changed

+2
-15
lines changed

2 files changed

+2
-15
lines changed

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -848,16 +848,7 @@ impl<'tcx> Constructor<'tcx> {
848848
(Str(self_val), Str(other_val)) => {
849849
// FIXME Once valtrees are available we can directly use the bytes
850850
// in the `Str` variant of the valtree for the comparison here.
851-
match compare_const_vals(
852-
pcx.cx.tcx,
853-
*self_val,
854-
*other_val,
855-
pcx.cx.param_env,
856-
pcx.ty,
857-
) {
858-
Some(comparison) => comparison == Ordering::Equal,
859-
None => false,
860-
}
851+
self_val == other_val
861852
}
862853
(Slice(self_slice), Slice(other_slice)) => self_slice.is_covered_by(*other_slice),
863854

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -755,16 +755,12 @@ pub(crate) fn compare_const_vals<'tcx>(
755755
ty: Ty<'tcx>,
756756
) -> Option<Ordering> {
757757
assert_eq!(a.ty(), b.ty());
758+
assert_eq!(a.ty(), ty);
758759

759760
let from_bool = |v: bool| v.then_some(Ordering::Equal);
760761

761762
let fallback = || from_bool(a == b);
762763

763-
// Use the fallback if any type differs
764-
if a.ty() != ty {
765-
return fallback();
766-
}
767-
768764
if a == b {
769765
return from_bool(true);
770766
}

0 commit comments

Comments
 (0)