@@ -23,6 +23,9 @@ pub mod sty;
23
23
pub use codec:: * ;
24
24
pub use sty:: * ;
25
25
26
+ /// Needed so we can use #[derive(HashStable_Generic)]
27
+ pub trait HashStableContext { }
28
+
26
29
pub trait Interner {
27
30
type AdtDef : Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord ;
28
31
type SubstsRef : Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord ;
@@ -295,6 +298,7 @@ rustc_index::newtype_index! {
295
298
/// is the outer fn.
296
299
///
297
300
/// [dbi]: https://en.wikipedia.org/wiki/De_Bruijn_index
301
+ #[ derive( HashStable_Generic ) ]
298
302
pub struct DebruijnIndex {
299
303
DEBUG_FORMAT = "DebruijnIndex({})" ,
300
304
const INNERMOST = 0 ,
@@ -366,7 +370,7 @@ impl DebruijnIndex {
366
370
}
367
371
368
372
#[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash , Debug ) ]
369
- #[ derive( Encodable , Decodable ) ]
373
+ #[ derive( Encodable , Decodable , HashStable_Generic ) ]
370
374
pub enum IntTy {
371
375
Isize ,
372
376
I8 ,
@@ -413,7 +417,7 @@ impl IntTy {
413
417
}
414
418
415
419
#[ derive( Clone , PartialEq , Eq , PartialOrd , Ord , Hash , Copy , Debug ) ]
416
- #[ derive( Encodable , Decodable ) ]
420
+ #[ derive( Encodable , Decodable , HashStable_Generic ) ]
417
421
pub enum UintTy {
418
422
Usize ,
419
423
U8 ,
@@ -460,7 +464,7 @@ impl UintTy {
460
464
}
461
465
462
466
#[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash , Debug ) ]
463
- #[ derive( Encodable , Decodable ) ]
467
+ #[ derive( Encodable , Decodable , HashStable_Generic ) ]
464
468
pub enum FloatTy {
465
469
F32 ,
466
470
F64 ,
@@ -597,7 +601,7 @@ impl UnifyKey for FloatVid {
597
601
}
598
602
}
599
603
600
- #[ derive( Copy , Clone , PartialEq , Decodable , Encodable , Hash ) ]
604
+ #[ derive( Copy , Clone , PartialEq , Decodable , Encodable , Hash , HashStable_Generic ) ]
601
605
#[ rustc_pass_by_value]
602
606
pub enum Variance {
603
607
Covariant , // T<A> <: T<B> iff A <: B -- e.g., function return type
@@ -666,30 +670,6 @@ impl Variance {
666
670
}
667
671
}
668
672
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
-
693
673
impl < CTX > HashStable < CTX > for InferTy {
694
674
fn hash_stable ( & self , ctx : & mut CTX , hasher : & mut StableHasher ) {
695
675
use InferTy :: * ;
@@ -703,12 +683,6 @@ impl<CTX> HashStable<CTX> for InferTy {
703
683
}
704
684
}
705
685
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
-
712
686
impl fmt:: Debug for IntVarValue {
713
687
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
714
688
match * self {
@@ -811,6 +785,7 @@ rustc_index::newtype_index! {
811
785
/// declared, but a type name in a non-zero universe is a placeholder
812
786
/// type -- an idealized representative of "types in general" that we
813
787
/// use for checking generic functions.
788
+ #[ derive( HashStable_Generic ) ]
814
789
pub struct UniverseIndex {
815
790
DEBUG_FORMAT = "U{}" ,
816
791
}
@@ -850,9 +825,3 @@ impl UniverseIndex {
850
825
self . private < other. private
851
826
}
852
827
}
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