Assert type equality of a and b in compare_const_vals.

Because they're always equal.
This commit is contained in:
Nicholas Nethercote 2022-06-09 09:24:08 +10:00
parent d5a13e2ca0
commit 9b4b34a0a6

View File

@ -754,12 +754,14 @@ pub(crate) fn compare_const_vals<'tcx>(
param_env: ty::ParamEnv<'tcx>,
ty: Ty<'tcx>,
) -> Option<Ordering> {
assert_eq!(a.ty(), b.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() != b.ty() || a.ty() != ty {
if a.ty() != ty {
return fallback();
}