@@ -6,7 +6,6 @@ use crate::spec::Target;
6
6
use std:: ops:: { Add , Deref , Sub , Mul , AddAssign , Range , RangeInclusive } ;
7
7
8
8
use rustc_index:: vec:: { Idx , IndexVec } ;
9
- use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
10
9
use rustc_macros:: HashStable_Generic ;
11
10
use syntax_pos:: Span ;
12
11
@@ -244,16 +243,11 @@ pub enum Endian {
244
243
245
244
/// Size of a type in bytes.
246
245
#[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash , Debug , RustcEncodable , RustcDecodable ) ]
246
+ #[ derive( HashStable_Generic ) ]
247
247
pub struct Size {
248
248
raw : u64
249
249
}
250
250
251
- impl < CTX > HashStable < CTX > for Size {
252
- fn hash_stable ( & self , hcx : & mut CTX , hasher : & mut StableHasher ) {
253
- self . bytes ( ) . hash_stable ( hcx, hasher) ;
254
- }
255
- }
256
-
257
251
impl Size {
258
252
pub const ZERO : Size = Self :: from_bytes ( 0 ) ;
259
253
@@ -373,16 +367,11 @@ impl AddAssign for Size {
373
367
374
368
/// Alignment of a type in bytes (always a power of two).
375
369
#[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash , Debug , RustcEncodable , RustcDecodable ) ]
370
+ #[ derive( HashStable_Generic ) ]
376
371
pub struct Align {
377
372
pow2 : u8 ,
378
373
}
379
374
380
- impl < CTX > HashStable < CTX > for Align {
381
- fn hash_stable ( & self , hcx : & mut CTX , hasher : & mut StableHasher ) {
382
- self . bytes ( ) . hash_stable ( hcx, hasher) ;
383
- }
384
- }
385
-
386
375
impl Align {
387
376
pub fn from_bits ( bits : u64 ) -> Result < Align , String > {
388
377
Align :: from_bytes ( Size :: from_bits ( bits) . bytes ( ) )
@@ -436,8 +425,8 @@ impl Align {
436
425
}
437
426
438
427
/// A pair of aligments, ABI-mandated and preferred.
439
- #[ derive( Copy , Clone , PartialEq , Eq , Hash , Debug ,
440
- RustcEncodable , RustcDecodable , HashStable_Generic ) ]
428
+ #[ derive( Copy , Clone , PartialEq , Eq , Hash , Debug , RustcEncodable , RustcDecodable ) ]
429
+ # [ derive ( HashStable_Generic ) ]
441
430
pub struct AbiAndPrefAlign {
442
431
pub abi : Align ,
443
432
pub pref : Align ,
@@ -603,6 +592,7 @@ impl Primitive {
603
592
604
593
/// Information about one scalar component of a Rust type.
605
594
#[ derive( Clone , PartialEq , Eq , Hash , Debug ) ]
595
+ #[ derive( HashStable_Generic ) ]
606
596
pub struct Scalar {
607
597
pub value : Primitive ,
608
598
@@ -623,15 +613,6 @@ pub struct Scalar {
623
613
pub valid_range : RangeInclusive < u128 > ,
624
614
}
625
615
626
- impl < CTX > HashStable < CTX > for Scalar {
627
- fn hash_stable ( & self , hcx : & mut CTX , hasher : & mut StableHasher ) {
628
- let Scalar { value, ref valid_range } = * self ;
629
- value. hash_stable ( hcx, hasher) ;
630
- valid_range. start ( ) . hash_stable ( hcx, hasher) ;
631
- valid_range. end ( ) . hash_stable ( hcx, hasher) ;
632
- }
633
- }
634
-
635
616
impl Scalar {
636
617
pub fn is_bool ( & self ) -> bool {
637
618
if let Int ( I8 , _) = self . value {
@@ -824,12 +805,8 @@ impl Abi {
824
805
}
825
806
826
807
rustc_index:: newtype_index! {
827
- pub struct VariantIdx { .. }
828
- }
829
-
830
- impl < CTX > HashStable < CTX > for VariantIdx {
831
- fn hash_stable ( & self , hcx : & mut CTX , hasher : & mut StableHasher ) {
832
- self . as_u32 ( ) . hash_stable ( hcx, hasher)
808
+ pub struct VariantIdx {
809
+ derive [ HashStable_Generic ]
833
810
}
834
811
}
835
812
@@ -851,7 +828,7 @@ pub enum Variants {
851
828
} ,
852
829
}
853
830
854
- #[ derive( PartialEq , Eq , Hash , Debug ) ]
831
+ #[ derive( PartialEq , Eq , Hash , Debug , HashStable_Generic ) ]
855
832
pub enum DiscriminantKind {
856
833
/// Integer tag holding the discriminant value itself.
857
834
Tag ,
@@ -872,27 +849,6 @@ pub enum DiscriminantKind {
872
849
} ,
873
850
}
874
851
875
- impl < CTX > HashStable < CTX > for DiscriminantKind {
876
- fn hash_stable ( & self , hcx : & mut CTX , hasher : & mut StableHasher ) {
877
- use DiscriminantKind :: * ;
878
- std:: mem:: discriminant ( self ) . hash_stable ( hcx, hasher) ;
879
-
880
- match * self {
881
- Tag => { }
882
- Niche {
883
- dataful_variant,
884
- ref niche_variants,
885
- niche_start,
886
- } => {
887
- dataful_variant. hash_stable ( hcx, hasher) ;
888
- niche_variants. start ( ) . hash_stable ( hcx, hasher) ;
889
- niche_variants. end ( ) . hash_stable ( hcx, hasher) ;
890
- niche_start. hash_stable ( hcx, hasher) ;
891
- }
892
- }
893
- }
894
- }
895
-
896
852
#[ derive( Clone , PartialEq , Eq , Hash , Debug , HashStable_Generic ) ]
897
853
pub struct Niche {
898
854
pub offset : Size ,
0 commit comments