diff --git a/src/librustc/hir/map/definitions.rs b/src/librustc/hir/map/definitions.rs index 1e444e8a5b8..2b3bc37c87c 100644 --- a/src/librustc/hir/map/definitions.rs +++ b/src/librustc/hir/map/definitions.rs @@ -313,11 +313,9 @@ pub enum DefPathData { } #[derive(Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord, Debug, - RustcEncodable, RustcDecodable)] + RustcEncodable, RustcDecodable, HashStable)] pub struct DefPathHash(pub Fingerprint); -impl_stable_hash_for!(tuple_struct DefPathHash { fingerprint }); - impl Borrow for DefPathHash { #[inline] fn borrow(&self) -> &Fingerprint { diff --git a/src/librustc/infer/outlives/free_region_map.rs b/src/librustc/infer/outlives/free_region_map.rs index c085df6a6e7..fd8ccce6833 100644 --- a/src/librustc/infer/outlives/free_region_map.rs +++ b/src/librustc/infer/outlives/free_region_map.rs @@ -1,7 +1,7 @@ use crate::ty::{self, Lift, TyCtxt, Region}; use rustc_data_structures::transitive_relation::TransitiveRelation; -#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Default)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Default, HashStable)] pub struct FreeRegionMap<'tcx> { // Stores the relation `a < b`, where `a` and `b` are regions. // @@ -89,10 +89,6 @@ fn is_free_or_static(r: Region<'_>) -> bool { } } -impl_stable_hash_for!(struct FreeRegionMap<'tcx> { - relation -}); - impl<'a, 'tcx> Lift<'tcx> for FreeRegionMap<'a> { type Lifted = FreeRegionMap<'tcx>; fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option> { diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index 11d0d0d90fa..d84102ff3c5 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -543,18 +543,11 @@ impl LintId { } /// Setting for how to handle a lint. -#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] +#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash, HashStable)] pub enum Level { Allow, Warn, Deny, Forbid, } -impl_stable_hash_for!(enum self::Level { - Allow, - Warn, - Deny, - Forbid -}); - impl Level { /// Converts a level to a lower-case string. pub fn as_str(self) -> &'static str { @@ -590,7 +583,7 @@ impl Level { } /// How a lint level was set. -#[derive(Clone, Copy, PartialEq, Eq)] +#[derive(Clone, Copy, PartialEq, Eq, HashStable)] pub enum LintSource { /// Lint is at the default level as declared /// in rustc or a plugin. @@ -603,12 +596,6 @@ pub enum LintSource { CommandLine(Symbol), } -impl_stable_hash_for!(enum self::LintSource { - Default, - Node(name, span, reason), - CommandLine(text) -}); - pub type LevelSource = (Level, LintSource); pub mod builtin; diff --git a/src/librustc/middle/exported_symbols.rs b/src/librustc/middle/exported_symbols.rs index 4d14299751c..7182f031824 100644 --- a/src/librustc/middle/exported_symbols.rs +++ b/src/librustc/middle/exported_symbols.rs @@ -11,17 +11,12 @@ use crate::ty::subst::SubstsRef; /// kind of crate, including cdylibs which export very few things. /// `Rust` will only be exported if the crate produced is a Rust /// dylib. -#[derive(Eq, PartialEq, Debug, Copy, Clone, RustcEncodable, RustcDecodable)] +#[derive(Eq, PartialEq, Debug, Copy, Clone, RustcEncodable, RustcDecodable, HashStable)] pub enum SymbolExportLevel { C, Rust, } -impl_stable_hash_for!(enum self::SymbolExportLevel { - C, - Rust -}); - impl SymbolExportLevel { pub fn is_below_threshold(self, threshold: SymbolExportLevel) -> bool { threshold == SymbolExportLevel::Rust // export everything from Rust dylibs diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index a70fe2be96c..c13c44c413d 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -207,7 +207,7 @@ struct NamedRegionMap { } /// See [`NamedRegionMap`]. -#[derive(Default)] +#[derive(Default, HashStable)] pub struct ResolveLifetimes { defs: FxHashMap>, late_bound: FxHashMap>, @@ -215,12 +215,6 @@ pub struct ResolveLifetimes { FxHashMap>>, } -impl_stable_hash_for!(struct crate::middle::resolve_lifetime::ResolveLifetimes { - defs, - late_bound, - object_lifetime_defaults -}); - struct LifetimeContext<'a, 'tcx> { tcx: TyCtxt<'tcx>, map: &'a mut NamedRegionMap, diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 8f8b4ed98bd..411a47423c5 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -52,7 +52,7 @@ enum AnnotationKind { } /// An entry in the `depr_map`. -#[derive(Clone)] +#[derive(Clone, HashStable)] pub struct DeprecationEntry { /// The metadata of the attribute associated with this entry. pub attr: Deprecation, @@ -61,11 +61,6 @@ pub struct DeprecationEntry { origin: Option, } -impl_stable_hash_for!(struct self::DeprecationEntry { - attr, - origin -}); - impl DeprecationEntry { fn local(attr: Deprecation, id: HirId) -> DeprecationEntry { DeprecationEntry { @@ -90,6 +85,7 @@ impl DeprecationEntry { } /// A stability index, giving the stability level for items and methods. +#[derive(HashStable)] pub struct Index<'tcx> { /// This is mostly a cache, except the stabilities of local items /// are filled by the annotator. @@ -103,13 +99,6 @@ pub struct Index<'tcx> { active_features: FxHashSet, } -impl_stable_hash_for!(struct self::Index<'tcx> { - stab_map, - depr_map, - staged_api, - active_features -}); - // A private tree-walker for producing an Index. struct Annotator<'a, 'tcx> { tcx: TyCtxt<'tcx>, diff --git a/src/librustc/mir/interpret/allocation.rs b/src/librustc/mir/interpret/allocation.rs index aa8ac4902a8..f849361e08b 100644 --- a/src/librustc/mir/interpret/allocation.rs +++ b/src/librustc/mir/interpret/allocation.rs @@ -4,7 +4,6 @@ use super::{ Pointer, InterpResult, AllocId, ScalarMaybeUndef, write_target_uint, read_target_uint, Scalar, }; -use crate::mir; use crate::ty::layout::{Size, Align}; use rustc_data_structures::sorted_map::SortedMap; @@ -787,14 +786,13 @@ type Block = u64; /// A bitmask where each bit refers to the byte with the same index. If the bit is `true`, the byte /// is defined. If it is `false` the byte is undefined. -#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)] +#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, + RustcEncodable, RustcDecodable, HashStable)] pub struct UndefMask { blocks: Vec, len: Size, } -impl_stable_hash_for!(struct mir::interpret::UndefMask{blocks, len}); - impl UndefMask { pub const BLOCK_SIZE: u64 = 64; diff --git a/src/librustc/mir/interpret/value.rs b/src/librustc/mir/interpret/value.rs index a0367154b75..52c72de7579 100644 --- a/src/librustc/mir/interpret/value.rs +++ b/src/librustc/mir/interpret/value.rs @@ -458,7 +458,7 @@ impl From> for Scalar { } } -#[derive(Clone, Copy, Eq, PartialEq, RustcEncodable, RustcDecodable)] +#[derive(Clone, Copy, Eq, PartialEq, RustcEncodable, RustcDecodable, HashStable)] pub enum ScalarMaybeUndef { Scalar(Scalar), Undef, @@ -583,11 +583,6 @@ impl<'tcx, Tag> ScalarMaybeUndef { } } -impl_stable_hash_for!(enum crate::mir::interpret::ScalarMaybeUndef { - Scalar(v), - Undef -}); - /// Gets the bytes of a constant slice value. pub fn get_slice_bytes<'tcx>(cx: &impl HasDataLayout, val: ConstValue<'tcx>) -> &'tcx [u8] { if let ConstValue::Slice { data, start, end } = val { diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 5997e4367bf..79468b68055 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -70,7 +70,8 @@ impl<'tcx> HasLocalDecls<'tcx> for Body<'tcx> { /// The various "big phases" that MIR goes through. /// /// Warning: ordering of variants is significant. -#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Copy, Clone, RustcEncodable, RustcDecodable, HashStable, + Debug, PartialEq, Eq, PartialOrd, Ord)] pub enum MirPhase { Build = 0, Const = 1, @@ -86,7 +87,7 @@ impl MirPhase { } /// The lowered representation of a single function. -#[derive(Clone, RustcEncodable, RustcDecodable, Debug, TypeFoldable)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable, TypeFoldable)] pub struct Body<'tcx> { /// A list of basic blocks. References to basic block use a newtyped index type `BasicBlock` /// that indexes into this vector. @@ -412,24 +413,6 @@ pub enum Safety { ExplicitUnsafe(hir::HirId), } -impl_stable_hash_for!(struct Body<'tcx> { - phase, - basic_blocks, - source_scopes, - source_scope_local_data, - yield_ty, - generator_drop, - generator_layout, - local_decls, - user_type_annotations, - arg_count, - __upvar_debuginfo_codegen_only_do_not_use, - spread_arg, - control_flow_destroyed, - span, - cache -}); - impl<'tcx> Index for Body<'tcx> { type Output = BasicBlockData<'tcx>; @@ -609,7 +592,7 @@ pub enum LocalKind { ReturnPointer, } -#[derive(Clone, Debug, RustcEncodable, RustcDecodable)] +#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)] pub struct VarBindingForm<'tcx> { /// Is variable bound via `x`, `mut x`, `ref x`, or `ref mut x`? pub binding_mode: ty::BindingMode, @@ -642,7 +625,7 @@ pub enum BindingForm<'tcx> { } /// Represents what type of implicit self a function has, if any. -#[derive(Clone, Copy, PartialEq, Debug, RustcEncodable, RustcDecodable)] +#[derive(Clone, Copy, PartialEq, Debug, RustcEncodable, RustcDecodable, HashStable)] pub enum ImplicitSelfKind { /// Represents a `fn x(self);`. Imm, @@ -659,28 +642,6 @@ pub enum ImplicitSelfKind { CloneTypeFoldableAndLiftImpls! { BindingForm<'tcx>, } -impl_stable_hash_for!(struct self::VarBindingForm<'tcx> { - binding_mode, - opt_ty_info, - opt_match_place, - pat_span -}); - -impl_stable_hash_for!(enum self::ImplicitSelfKind { - Imm, - Mut, - ImmRef, - MutRef, - None -}); - -impl_stable_hash_for!(enum self::MirPhase { - Build, - Const, - Validated, - Optimized, -}); - mod binding_form_impl { use crate::ich::StableHashingContext; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; @@ -707,7 +668,7 @@ mod binding_form_impl { /// involved in borrow_check errors, e.g., explanations of where the /// temporaries come from, when their destructors are run, and/or how /// one might revise the code to satisfy the borrow checker's rules. -#[derive(Clone, Debug, RustcEncodable, RustcDecodable)] +#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)] pub struct BlockTailInfo { /// If `true`, then the value resulting from evaluating this tail /// expression is ignored by the block's expression context. @@ -717,8 +678,6 @@ pub struct BlockTailInfo { pub tail_result_is_ignored: bool, } -impl_stable_hash_for!(struct BlockTailInfo { tail_result_is_ignored }); - /// A MIR local. /// /// This can be a binding declared by the user, a temporary inserted by the compiler, a function @@ -1746,7 +1705,8 @@ pub enum PlaceBase<'tcx> { } /// We store the normalized type to avoid requiring normalization when reading MIR -#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)] +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, + RustcEncodable, RustcDecodable, HashStable)] pub struct Static<'tcx> { pub ty: Ty<'tcx>, pub kind: StaticKind<'tcx>, @@ -1768,12 +1728,6 @@ pub enum StaticKind<'tcx> { Static, } -impl_stable_hash_for!(struct Static<'tcx> { - ty, - kind, - def_id -}); - #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[derive(RustcEncodable, RustcDecodable, HashStable)] pub enum ProjectionElem { diff --git a/src/librustc/traits/query/dropck_outlives.rs b/src/librustc/traits/query/dropck_outlives.rs index 93f56804a9f..785b4122d08 100644 --- a/src/librustc/traits/query/dropck_outlives.rs +++ b/src/librustc/traits/query/dropck_outlives.rs @@ -79,7 +79,7 @@ impl<'cx, 'tcx> At<'cx, 'tcx> { } } -#[derive(Clone, Debug, Default, TypeFoldable, Lift)] +#[derive(Clone, Debug, Default, HashStable, TypeFoldable, Lift)] pub struct DropckOutlivesResult<'tcx> { pub kinds: Vec>, pub overflows: Vec>, @@ -114,7 +114,7 @@ impl<'tcx> DropckOutlivesResult<'tcx> { /// A set of constraints that need to be satisfied in order for /// a type to be valid for destruction. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, HashStable)] pub struct DtorckConstraint<'tcx> { /// Types that are required to be alive in order for this /// type to be valid for destruction. @@ -152,15 +152,6 @@ impl<'tcx> FromIterator> for DtorckConstraint<'tcx> { result } } -impl_stable_hash_for!(struct DropckOutlivesResult<'tcx> { - kinds, overflows -}); - -impl_stable_hash_for!(struct DtorckConstraint<'tcx> { - outlives, - dtorck_types, - overflows -}); /// This returns true if the type `ty` is "trivial" for /// dropck-outlives -- that is, if it doesn't require any types to diff --git a/src/librustc/traits/query/method_autoderef.rs b/src/librustc/traits/query/method_autoderef.rs index 039dea1ffcd..be846287e29 100644 --- a/src/librustc/traits/query/method_autoderef.rs +++ b/src/librustc/traits/query/method_autoderef.rs @@ -2,7 +2,7 @@ use rustc_data_structures::sync::Lrc; use crate::infer::canonical::{Canonical, QueryResponse}; use crate::ty::Ty; -#[derive(Debug)] +#[derive(Debug, HashStable)] pub struct CandidateStep<'tcx> { pub self_ty: Canonical<'tcx, QueryResponse<'tcx, Ty<'tcx>>>, pub autoderefs: usize, @@ -15,7 +15,7 @@ pub struct CandidateStep<'tcx> { pub unsize: bool, } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, HashStable)] pub struct MethodAutoderefStepsResult<'tcx> { /// The valid autoderef steps that could be find. pub steps: Lrc>>, @@ -26,20 +26,8 @@ pub struct MethodAutoderefStepsResult<'tcx> { pub reached_recursion_limit: bool, } -#[derive(Debug)] +#[derive(Debug, HashStable)] pub struct MethodAutoderefBadTy<'tcx> { pub reached_raw_pointer: bool, pub ty: Canonical<'tcx, QueryResponse<'tcx, Ty<'tcx>>>, } - -impl_stable_hash_for!(struct MethodAutoderefBadTy<'tcx> { - reached_raw_pointer, ty -}); - -impl_stable_hash_for!(struct MethodAutoderefStepsResult<'tcx> { - reached_recursion_limit, steps, opt_bad_ty -}); - -impl_stable_hash_for!(struct CandidateStep<'tcx> { - self_ty, autoderefs, from_unsafe_deref, unsize -}); diff --git a/src/librustc/traits/query/normalize.rs b/src/librustc/traits/query/normalize.rs index 30528dcebda..09c7f45c22b 100644 --- a/src/librustc/traits/query/normalize.rs +++ b/src/librustc/traits/query/normalize.rs @@ -66,7 +66,7 @@ impl<'cx, 'tcx> At<'cx, 'tcx> { } /// Result from the `normalize_projection_ty` query. -#[derive(Clone, Debug, TypeFoldable, Lift)] +#[derive(Clone, Debug, HashStable, TypeFoldable, Lift)] pub struct NormalizationResult<'tcx> { /// Result of normalization. pub normalized_ty: Ty<'tcx>, @@ -193,7 +193,3 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> { constant.eval(self.infcx.tcx, self.param_env) } } - -impl_stable_hash_for!(struct NormalizationResult<'tcx> { - normalized_ty -});