Make root vars more stable

This commit is contained in:
Michael Goulet
2025-06-05 17:02:49 +00:00
parent c360e219f5
commit e1567dff24
3 changed files with 6 additions and 17 deletions

View File

@@ -238,6 +238,9 @@ impl<'tcx> ut::UnifyKey for TyVidEqKey<'tcx> {
fn tag() -> &'static str { fn tag() -> &'static str {
"TyVidEqKey" "TyVidEqKey"
} }
fn order_roots(a: Self, _: &Self::Value, b: Self, _: &Self::Value) -> Option<(Self, Self)> {
if a.vid.as_u32() < b.vid.as_u32() { Some((a, b)) } else { Some((b, a)) }
}
} }
impl<'tcx> ut::UnifyValue for TypeVariableValue<'tcx> { impl<'tcx> ut::UnifyValue for TypeVariableValue<'tcx> {

View File

@@ -137,6 +137,9 @@ impl<'tcx> UnifyKey for ConstVidKey<'tcx> {
fn tag() -> &'static str { fn tag() -> &'static str {
"ConstVidKey" "ConstVidKey"
} }
fn order_roots(a: Self, _: &Self::Value, b: Self, _: &Self::Value) -> Option<(Self, Self)> {
if a.vid.as_u32() < b.vid.as_u32() { Some((a, b)) } else { Some((b, a)) }
}
} }
impl<'tcx> UnifyValue for ConstVariableValue<'tcx> { impl<'tcx> UnifyValue for ConstVariableValue<'tcx> {

View File

@@ -771,23 +771,6 @@ pub enum InferTy {
FreshFloatTy(u32), FreshFloatTy(u32),
} }
/// Raw `TyVid` are used as the unification key for `sub_relations`;
/// they carry no values.
impl UnifyKey for TyVid {
type Value = ();
#[inline]
fn index(&self) -> u32 {
self.as_u32()
}
#[inline]
fn from_index(i: u32) -> TyVid {
TyVid::from_u32(i)
}
fn tag() -> &'static str {
"TyVid"
}
}
impl UnifyValue for IntVarValue { impl UnifyValue for IntVarValue {
type Error = NoError; type Error = NoError;