Rollup merge of #115634 - nnethercote:IntVid-FloatVid, r=oli-obk
Use `newtype_index` for `IntVid` and `FloatVid`. `TyVid` already uses `newtype_index`.
This commit is contained in:
commit
1979772772
@ -764,13 +764,13 @@ pub fn unsolved_variables(&self) -> Vec<Ty<'tcx>> {
|
||||
.collect();
|
||||
vars.extend(
|
||||
(0..inner.int_unification_table().len())
|
||||
.map(|i| ty::IntVid { index: i as u32 })
|
||||
.map(|i| ty::IntVid::from_u32(i as u32))
|
||||
.filter(|&vid| inner.int_unification_table().probe_value(vid).is_none())
|
||||
.map(|v| Ty::new_int_var(self.tcx, v)),
|
||||
);
|
||||
vars.extend(
|
||||
(0..inner.float_unification_table().len())
|
||||
.map(|i| ty::FloatVid { index: i as u32 })
|
||||
.map(|i| ty::FloatVid::from_u32(i as u32))
|
||||
.filter(|&vid| inner.float_unification_table().probe_value(vid).is_none())
|
||||
.map(|v| Ty::new_float_var(self.tcx, v)),
|
||||
);
|
||||
|
@ -574,16 +574,16 @@ pub enum IntVarValue {
|
||||
pub struct TyVid {}
|
||||
}
|
||||
|
||||
/// An **int**egral (`u32`, `i32`, `usize`, etc.) type **v**ariable **ID**.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable, Decodable)]
|
||||
pub struct IntVid {
|
||||
pub index: u32,
|
||||
rustc_index::newtype_index! {
|
||||
/// An **int**egral (`u32`, `i32`, `usize`, etc.) type **v**ariable **ID**.
|
||||
#[debug_format = "?{}i"]
|
||||
pub struct IntVid {}
|
||||
}
|
||||
|
||||
/// An **float**ing-point (`f32` or `f64`) type **v**ariable **ID**.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable, Decodable)]
|
||||
pub struct FloatVid {
|
||||
pub index: u32,
|
||||
rustc_index::newtype_index! {
|
||||
/// A **float**ing-point (`f32` or `f64`) type **v**ariable **ID**.
|
||||
#[debug_format = "?{}f"]
|
||||
pub struct FloatVid {}
|
||||
}
|
||||
|
||||
/// A placeholder for a type that hasn't been inferred yet.
|
||||
@ -645,11 +645,11 @@ impl UnifyKey for IntVid {
|
||||
type Value = Option<IntVarValue>;
|
||||
#[inline] // make this function eligible for inlining - it is quite hot.
|
||||
fn index(&self) -> u32 {
|
||||
self.index
|
||||
self.as_u32()
|
||||
}
|
||||
#[inline]
|
||||
fn from_index(i: u32) -> IntVid {
|
||||
IntVid { index: i }
|
||||
IntVid::from_u32(i)
|
||||
}
|
||||
fn tag() -> &'static str {
|
||||
"IntVid"
|
||||
@ -662,11 +662,11 @@ impl UnifyKey for FloatVid {
|
||||
type Value = Option<FloatVarValue>;
|
||||
#[inline]
|
||||
fn index(&self) -> u32 {
|
||||
self.index
|
||||
self.as_u32()
|
||||
}
|
||||
#[inline]
|
||||
fn from_index(i: u32) -> FloatVid {
|
||||
FloatVid { index: i }
|
||||
FloatVid::from_u32(i)
|
||||
}
|
||||
fn tag() -> &'static str {
|
||||
"FloatVid"
|
||||
@ -770,18 +770,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for IntVid {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "?{}i", self.index)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for FloatVid {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "?{}f", self.index)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for Variance {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.write_str(match *self {
|
||||
|
Loading…
Reference in New Issue
Block a user