mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Auto merge of #142090 - compiler-errors:perf-stable-root-var, r=lcnr
Make root vars more stable Never resolve a ty/ct vid to a higher vid as its root. This should make the optimization in rust-lang/rust#141500 more "stable" when there are a lot of vars flying around. r? `@ghost`
This commit is contained in:
@@ -238,6 +238,9 @@ fn from_index(i: u32) -> Self {
|
||||
fn tag() -> &'static str {
|
||||
"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> {
|
||||
|
||||
@@ -137,6 +137,9 @@ fn from_index(i: u32) -> Self {
|
||||
fn tag() -> &'static str {
|
||||
"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> {
|
||||
|
||||
@@ -771,23 +771,6 @@ pub enum InferTy {
|
||||
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 {
|
||||
type Error = NoError;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user