More HashStable.

This commit is contained in:
Camille GILLOT 2019-11-09 23:17:42 +01:00
parent e00ebd725f
commit c4bc3f05f5
12 changed files with 25 additions and 144 deletions

View File

@ -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<Fingerprint> for DefPathHash {
#[inline]
fn borrow(&self) -> &Fingerprint {

View File

@ -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<FreeRegionMap<'tcx>> {

View File

@ -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;

View File

@ -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

View File

@ -207,7 +207,7 @@ struct NamedRegionMap {
}
/// See [`NamedRegionMap`].
#[derive(Default)]
#[derive(Default, HashStable)]
pub struct ResolveLifetimes {
defs: FxHashMap<LocalDefId, FxHashMap<ItemLocalId, Region>>,
late_bound: FxHashMap<LocalDefId, FxHashSet<ItemLocalId>>,
@ -215,12 +215,6 @@ pub struct ResolveLifetimes {
FxHashMap<LocalDefId, FxHashMap<ItemLocalId, Vec<ObjectLifetimeDefault>>>,
}
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,

View File

@ -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<HirId>,
}
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<Symbol>,
}
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>,

View File

@ -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<Block>,
len: Size,
}
impl_stable_hash_for!(struct mir::interpret::UndefMask{blocks, len});
impl UndefMask {
pub const BLOCK_SIZE: u64 = 64;

View File

@ -458,7 +458,7 @@ impl<Tag> From<Pointer<Tag>> for Scalar<Tag> {
}
}
#[derive(Clone, Copy, Eq, PartialEq, RustcEncodable, RustcDecodable)]
#[derive(Clone, Copy, Eq, PartialEq, RustcEncodable, RustcDecodable, HashStable)]
pub enum ScalarMaybeUndef<Tag = (), Id = AllocId> {
Scalar(Scalar<Tag, Id>),
Undef,
@ -583,11 +583,6 @@ impl<'tcx, Tag> ScalarMaybeUndef<Tag> {
}
}
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 {

View File

@ -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<BasicBlock> 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<V, T> {

View File

@ -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<GenericArg<'tcx>>,
pub overflows: Vec<Ty<'tcx>>,
@ -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<DtorckConstraint<'tcx>> 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

View File

@ -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<Vec<CandidateStep<'tcx>>>,
@ -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
});

View File

@ -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
});