@@ -23,6 +23,9 @@ pub mod sty;
2323pub use codec:: * ;
2424pub use sty:: * ;
2525
26+ /// Needed so we can use #[derive(HashStable_Generic)]
27+ pub trait HashStableContext { }
28+
2629pub trait Interner {
2730 type AdtDef : Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord ;
2831 type SubstsRef : Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord ;
@@ -295,6 +298,7 @@ rustc_index::newtype_index! {
295298 /// is the outer fn.
296299 ///
297300 /// [dbi]: https://en.wikipedia.org/wiki/De_Bruijn_index
301+ #[ derive( HashStable_Generic ) ]
298302 pub struct DebruijnIndex {
299303 DEBUG_FORMAT = "DebruijnIndex({})" ,
300304 const INNERMOST = 0 ,
@@ -366,7 +370,7 @@ impl DebruijnIndex {
366370}
367371
368372#[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash , Debug ) ]
369- #[ derive( Encodable , Decodable ) ]
373+ #[ derive( Encodable , Decodable , HashStable_Generic ) ]
370374pub enum IntTy {
371375 Isize ,
372376 I8 ,
@@ -413,7 +417,7 @@ impl IntTy {
413417}
414418
415419#[ derive( Clone , PartialEq , Eq , PartialOrd , Ord , Hash , Copy , Debug ) ]
416- #[ derive( Encodable , Decodable ) ]
420+ #[ derive( Encodable , Decodable , HashStable_Generic ) ]
417421pub enum UintTy {
418422 Usize ,
419423 U8 ,
@@ -460,7 +464,7 @@ impl UintTy {
460464}
461465
462466#[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash , Debug ) ]
463- #[ derive( Encodable , Decodable ) ]
467+ #[ derive( Encodable , Decodable , HashStable_Generic ) ]
464468pub enum FloatTy {
465469 F32 ,
466470 F64 ,
@@ -597,7 +601,7 @@ impl UnifyKey for FloatVid {
597601 }
598602}
599603
600- #[ derive( Copy , Clone , PartialEq , Decodable , Encodable , Hash ) ]
604+ #[ derive( Copy , Clone , PartialEq , Decodable , Encodable , Hash , HashStable_Generic ) ]
601605#[ rustc_pass_by_value]
602606pub enum Variance {
603607 Covariant , // T<A> <: T<B> iff A <: B -- e.g., function return type
@@ -666,30 +670,6 @@ impl Variance {
666670 }
667671}
668672
669- impl < CTX > HashStable < CTX > for DebruijnIndex {
670- fn hash_stable ( & self , ctx : & mut CTX , hasher : & mut StableHasher ) {
671- self . as_u32 ( ) . hash_stable ( ctx, hasher) ;
672- }
673- }
674-
675- impl < CTX > HashStable < CTX > for IntTy {
676- fn hash_stable ( & self , ctx : & mut CTX , hasher : & mut StableHasher ) {
677- discriminant ( self ) . hash_stable ( ctx, hasher) ;
678- }
679- }
680-
681- impl < CTX > HashStable < CTX > for UintTy {
682- fn hash_stable ( & self , ctx : & mut CTX , hasher : & mut StableHasher ) {
683- discriminant ( self ) . hash_stable ( ctx, hasher) ;
684- }
685- }
686-
687- impl < CTX > HashStable < CTX > for FloatTy {
688- fn hash_stable ( & self , ctx : & mut CTX , hasher : & mut StableHasher ) {
689- discriminant ( self ) . hash_stable ( ctx, hasher) ;
690- }
691- }
692-
693673impl < CTX > HashStable < CTX > for InferTy {
694674 fn hash_stable ( & self , ctx : & mut CTX , hasher : & mut StableHasher ) {
695675 use InferTy :: * ;
@@ -703,12 +683,6 @@ impl<CTX> HashStable<CTX> for InferTy {
703683 }
704684}
705685
706- impl < CTX > HashStable < CTX > for Variance {
707- fn hash_stable ( & self , ctx : & mut CTX , hasher : & mut StableHasher ) {
708- discriminant ( self ) . hash_stable ( ctx, hasher) ;
709- }
710- }
711-
712686impl fmt:: Debug for IntVarValue {
713687 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
714688 match * self {
@@ -811,6 +785,7 @@ rustc_index::newtype_index! {
811785 /// declared, but a type name in a non-zero universe is a placeholder
812786 /// type -- an idealized representative of "types in general" that we
813787 /// use for checking generic functions.
788+ #[ derive( HashStable_Generic ) ]
814789 pub struct UniverseIndex {
815790 DEBUG_FORMAT = "U{}" ,
816791 }
@@ -850,9 +825,3 @@ impl UniverseIndex {
850825 self . private < other. private
851826 }
852827}
853-
854- impl < CTX > HashStable < CTX > for UniverseIndex {
855- fn hash_stable ( & self , ctx : & mut CTX , hasher : & mut StableHasher ) {
856- self . private . hash_stable ( ctx, hasher) ;
857- }
858- }
0 commit comments