diff --git a/src/librustc_target/abi/mod.rs b/src/librustc_target/abi/mod.rs index ff13218831c0..ac781819cc35 100644 --- a/src/librustc_target/abi/mod.rs +++ b/src/librustc_target/abi/mod.rs @@ -6,7 +6,6 @@ use crate::spec::Target; use std::ops::{Add, Deref, Sub, Mul, AddAssign, Range, RangeInclusive}; use rustc_index::vec::{Idx, IndexVec}; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_macros::HashStable_Generic; use syntax_pos::Span; @@ -244,16 +243,11 @@ pub enum Endian { /// Size of a type in bytes. #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)] +#[derive(HashStable_Generic)] pub struct Size { raw: u64 } -impl HashStable for Size { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { - self.bytes().hash_stable(hcx, hasher); - } -} - impl Size { pub const ZERO: Size = Self::from_bytes(0); @@ -373,16 +367,11 @@ impl AddAssign for Size { /// Alignment of a type in bytes (always a power of two). #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)] +#[derive(HashStable_Generic)] pub struct Align { pow2: u8, } -impl HashStable for Align { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { - self.bytes().hash_stable(hcx, hasher); - } -} - impl Align { pub fn from_bits(bits: u64) -> Result { Align::from_bytes(Size::from_bits(bits).bytes()) @@ -436,8 +425,8 @@ impl Align { } /// A pair of aligments, ABI-mandated and preferred. -#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, - RustcEncodable, RustcDecodable, HashStable_Generic)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)] +#[derive(HashStable_Generic)] pub struct AbiAndPrefAlign { pub abi: Align, pub pref: Align, @@ -603,6 +592,7 @@ impl Primitive { /// Information about one scalar component of a Rust type. #[derive(Clone, PartialEq, Eq, Hash, Debug)] +#[derive(HashStable_Generic)] pub struct Scalar { pub value: Primitive, @@ -623,15 +613,6 @@ pub struct Scalar { pub valid_range: RangeInclusive, } -impl HashStable for Scalar { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { - let Scalar { value, ref valid_range } = *self; - value.hash_stable(hcx, hasher); - valid_range.start().hash_stable(hcx, hasher); - valid_range.end().hash_stable(hcx, hasher); - } -} - impl Scalar { pub fn is_bool(&self) -> bool { if let Int(I8, _) = self.value { @@ -824,12 +805,8 @@ impl Abi { } rustc_index::newtype_index! { - pub struct VariantIdx { .. } -} - -impl HashStable for VariantIdx { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { - self.as_u32().hash_stable(hcx, hasher) + pub struct VariantIdx { + derive [HashStable_Generic] } } @@ -851,7 +828,7 @@ pub enum Variants { }, } -#[derive(PartialEq, Eq, Hash, Debug)] +#[derive(PartialEq, Eq, Hash, Debug, HashStable_Generic)] pub enum DiscriminantKind { /// Integer tag holding the discriminant value itself. Tag, @@ -872,27 +849,6 @@ pub enum DiscriminantKind { }, } -impl HashStable for DiscriminantKind { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { - use DiscriminantKind::*; - std::mem::discriminant(self).hash_stable(hcx, hasher); - - match *self { - Tag => {} - Niche { - dataful_variant, - ref niche_variants, - niche_start, - } => { - dataful_variant.hash_stable(hcx, hasher); - niche_variants.start().hash_stable(hcx, hasher); - niche_variants.end().hash_stable(hcx, hasher); - niche_start.hash_stable(hcx, hasher); - } - } - } -} - #[derive(Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic)] pub struct Niche { pub offset: Size,