@@ -574,16 +574,16 @@ rustc_index::newtype_index! {
574
574
pub struct TyVid { }
575
575
}
576
576
577
- /// An **int**egral (`u32`, `i32`, `usize`, etc.) type **v**ariable **ID**.
578
- # [ derive ( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash , Encodable , Decodable ) ]
579
- pub struct IntVid {
580
- pub index : u32 ,
577
+ rustc_index :: newtype_index! {
578
+ /// An **int**egral (`u32`, `i32`, `usize`, etc.) type **v**ariable **ID**.
579
+ # [ debug_format = "?{}i" ]
580
+ pub struct IntVid { }
581
581
}
582
582
583
- /// An **float**ing-point (`f32` or `f64`) type **v**ariable **ID**.
584
- # [ derive ( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash , Encodable , Decodable ) ]
585
- pub struct FloatVid {
586
- pub index : u32 ,
583
+ rustc_index :: newtype_index! {
584
+ /// A **float**ing-point (`f32` or `f64`) type **v**ariable **ID**.
585
+ # [ debug_format = "?{}f" ]
586
+ pub struct FloatVid { }
587
587
}
588
588
589
589
/// A placeholder for a type that hasn't been inferred yet.
@@ -645,11 +645,11 @@ impl UnifyKey for IntVid {
645
645
type Value = Option < IntVarValue > ;
646
646
#[ inline] // make this function eligible for inlining - it is quite hot.
647
647
fn index ( & self ) -> u32 {
648
- self . index
648
+ self . as_u32 ( )
649
649
}
650
650
#[ inline]
651
651
fn from_index ( i : u32 ) -> IntVid {
652
- IntVid { index : i }
652
+ IntVid :: from_u32 ( i )
653
653
}
654
654
fn tag ( ) -> & ' static str {
655
655
"IntVid"
@@ -662,11 +662,11 @@ impl UnifyKey for FloatVid {
662
662
type Value = Option < FloatVarValue > ;
663
663
#[ inline]
664
664
fn index ( & self ) -> u32 {
665
- self . index
665
+ self . as_u32 ( )
666
666
}
667
667
#[ inline]
668
668
fn from_index ( i : u32 ) -> FloatVid {
669
- FloatVid { index : i }
669
+ FloatVid :: from_u32 ( i )
670
670
}
671
671
fn tag ( ) -> & ' static str {
672
672
"FloatVid"
@@ -770,18 +770,6 @@ impl fmt::Debug for FloatVarValue {
770
770
}
771
771
}
772
772
773
- impl fmt:: Debug for IntVid {
774
- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
775
- write ! ( f, "?{}i" , self . index)
776
- }
777
- }
778
-
779
- impl fmt:: Debug for FloatVid {
780
- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
781
- write ! ( f, "?{}f" , self . index)
782
- }
783
- }
784
-
785
773
impl fmt:: Debug for Variance {
786
774
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
787
775
f. write_str ( match * self {
0 commit comments