2017-03-30 15:27:27 +02:00
|
|
|
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
//! This module contains `HashStable` implementations for various data types
|
|
|
|
//! from rustc::ty in no particular order.
|
|
|
|
|
2018-01-11 23:01:27 -05:00
|
|
|
use ich::{Fingerprint, StableHashingContext, NodeIdHashingMode};
|
|
|
|
use rustc_data_structures::fx::FxHashMap;
|
2017-09-13 18:20:27 +02:00
|
|
|
use rustc_data_structures::stable_hasher::{HashStable, ToStableHashKey,
|
|
|
|
StableHasher, StableHasherResult};
|
2018-01-11 23:01:27 -05:00
|
|
|
use std::cell::RefCell;
|
2017-03-30 15:27:27 +02:00
|
|
|
use std::hash as std_hash;
|
|
|
|
use std::mem;
|
2017-08-31 21:37:38 +03:00
|
|
|
use middle::region;
|
2017-08-14 18:19:42 +02:00
|
|
|
use traits;
|
2017-03-30 15:27:27 +02:00
|
|
|
use ty;
|
|
|
|
|
2017-09-14 15:10:24 +02:00
|
|
|
impl<'gcx, T> HashStable<StableHashingContext<'gcx>>
|
2017-08-08 17:56:28 +02:00
|
|
|
for &'gcx ty::Slice<T>
|
2017-09-14 15:10:24 +02:00
|
|
|
where T: HashStable<StableHashingContext<'gcx>> {
|
2017-03-30 15:27:27 +02:00
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
2017-09-14 15:10:24 +02:00
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
2017-03-30 15:27:27 +02:00
|
|
|
hasher: &mut StableHasher<W>) {
|
2018-01-11 23:01:27 -05:00
|
|
|
thread_local! {
|
|
|
|
static CACHE: RefCell<FxHashMap<(usize, usize), Fingerprint>> =
|
|
|
|
RefCell::new(FxHashMap());
|
|
|
|
}
|
|
|
|
|
|
|
|
let hash = CACHE.with(|cache| {
|
|
|
|
let key = (self.as_ptr() as usize, self.len());
|
|
|
|
if let Some(&hash) = cache.borrow().get(&key) {
|
|
|
|
return hash;
|
|
|
|
}
|
|
|
|
|
|
|
|
let mut hasher = StableHasher::new();
|
|
|
|
(&self[..]).hash_stable(hcx, &mut hasher);
|
|
|
|
|
|
|
|
let hash: Fingerprint = hasher.finish();
|
|
|
|
cache.borrow_mut().insert(key, hash);
|
|
|
|
hash
|
|
|
|
});
|
|
|
|
|
|
|
|
hash.hash_stable(hcx, hasher);
|
2017-03-30 15:27:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-14 15:10:24 +02:00
|
|
|
impl<'gcx> HashStable<StableHashingContext<'gcx>>
|
2017-08-08 17:56:28 +02:00
|
|
|
for ty::subst::Kind<'gcx> {
|
2017-03-30 15:27:27 +02:00
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
2017-09-14 15:10:24 +02:00
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
2017-03-30 15:27:27 +02:00
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
self.as_type().hash_stable(hcx, hasher);
|
|
|
|
self.as_region().hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-14 15:10:24 +02:00
|
|
|
impl<'gcx> HashStable<StableHashingContext<'gcx>>
|
2017-06-02 15:45:56 +02:00
|
|
|
for ty::RegionKind {
|
2017-03-30 15:27:27 +02:00
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
2017-09-14 15:10:24 +02:00
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
2017-03-30 15:27:27 +02:00
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
mem::discriminant(self).hash_stable(hcx, hasher);
|
|
|
|
match *self {
|
|
|
|
ty::ReErased |
|
|
|
|
ty::ReStatic |
|
|
|
|
ty::ReEmpty => {
|
|
|
|
// No variant fields to hash for these ...
|
|
|
|
}
|
|
|
|
ty::ReLateBound(db, ty::BrAnon(i)) => {
|
|
|
|
db.depth.hash_stable(hcx, hasher);
|
|
|
|
i.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-08-08 17:56:28 +02:00
|
|
|
ty::ReLateBound(db, ty::BrNamed(def_id, name)) => {
|
|
|
|
db.depth.hash_stable(hcx, hasher);
|
|
|
|
def_id.hash_stable(hcx, hasher);
|
|
|
|
name.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-10-10 17:08:29 +02:00
|
|
|
ty::ReLateBound(db, ty::BrEnv) => {
|
|
|
|
db.depth.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-05-11 15:05:00 +03:00
|
|
|
ty::ReEarlyBound(ty::EarlyBoundRegion { def_id, index, name }) => {
|
|
|
|
def_id.hash_stable(hcx, hasher);
|
2017-03-30 15:27:27 +02:00
|
|
|
index.hash_stable(hcx, hasher);
|
|
|
|
name.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-08-31 21:37:38 +03:00
|
|
|
ty::ReScope(scope) => {
|
|
|
|
scope.hash_stable(hcx, hasher);
|
2017-04-05 13:00:17 +02:00
|
|
|
}
|
|
|
|
ty::ReFree(ref free_region) => {
|
|
|
|
free_region.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-12-05 05:18:58 -05:00
|
|
|
ty::ReClosureBound(vid) => {
|
|
|
|
vid.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-03-30 15:27:27 +02:00
|
|
|
ty::ReLateBound(..) |
|
|
|
|
ty::ReVar(..) |
|
|
|
|
ty::ReSkolemized(..) => {
|
|
|
|
bug!("TypeIdHasher: unexpected region {:?}", *self)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-22 17:38:51 -05:00
|
|
|
impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::RegionVid {
|
|
|
|
#[inline]
|
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
use rustc_data_structures::indexed_vec::Idx;
|
|
|
|
self.index().hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-14 15:10:24 +02:00
|
|
|
impl<'gcx> HashStable<StableHashingContext<'gcx>>
|
2017-08-08 17:56:28 +02:00
|
|
|
for ty::adjustment::AutoBorrow<'gcx> {
|
2017-03-30 15:27:27 +02:00
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
2017-09-14 15:10:24 +02:00
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
2017-03-30 15:27:27 +02:00
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
mem::discriminant(self).hash_stable(hcx, hasher);
|
|
|
|
match *self {
|
|
|
|
ty::adjustment::AutoBorrow::Ref(ref region, mutability) => {
|
|
|
|
region.hash_stable(hcx, hasher);
|
|
|
|
mutability.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
ty::adjustment::AutoBorrow::RawPtr(mutability) => {
|
|
|
|
mutability.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-14 15:10:24 +02:00
|
|
|
impl<'gcx> HashStable<StableHashingContext<'gcx>>
|
2017-08-08 17:56:28 +02:00
|
|
|
for ty::adjustment::Adjust<'gcx> {
|
2017-03-30 15:27:27 +02:00
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
2017-09-14 15:10:24 +02:00
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
2017-03-30 15:27:27 +02:00
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
mem::discriminant(self).hash_stable(hcx, hasher);
|
|
|
|
match *self {
|
|
|
|
ty::adjustment::Adjust::NeverToAny |
|
|
|
|
ty::adjustment::Adjust::ReifyFnPointer |
|
|
|
|
ty::adjustment::Adjust::UnsafeFnPointer |
|
|
|
|
ty::adjustment::Adjust::ClosureFnPointer |
|
2017-05-27 10:29:24 +03:00
|
|
|
ty::adjustment::Adjust::MutToConstPointer |
|
|
|
|
ty::adjustment::Adjust::Unsize => {}
|
|
|
|
ty::adjustment::Adjust::Deref(ref overloaded) => {
|
|
|
|
overloaded.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
ty::adjustment::Adjust::Borrow(ref autoref) => {
|
2017-03-30 15:27:27 +02:00
|
|
|
autoref.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl_stable_hash_for!(struct ty::adjustment::Adjustment<'tcx> { kind, target });
|
2017-05-27 10:29:24 +03:00
|
|
|
impl_stable_hash_for!(struct ty::adjustment::OverloadedDeref<'tcx> { region, mutbl });
|
2017-03-30 15:27:27 +02:00
|
|
|
impl_stable_hash_for!(struct ty::UpvarBorrow<'tcx> { kind, region });
|
|
|
|
|
2018-01-23 13:31:11 +01:00
|
|
|
impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::adjustment::AutoBorrowMutability {
|
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
mem::discriminant(self).hash_stable(hcx, hasher);
|
|
|
|
match *self {
|
|
|
|
ty::adjustment::AutoBorrowMutability::Mutable { ref allow_two_phase_borrow } => {
|
|
|
|
allow_two_phase_borrow.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
ty::adjustment::AutoBorrowMutability::Immutable => {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-13 18:20:27 +02:00
|
|
|
impl_stable_hash_for!(struct ty::UpvarId { var_id, closure_expr_id });
|
|
|
|
|
2017-03-30 15:27:27 +02:00
|
|
|
impl_stable_hash_for!(enum ty::BorrowKind {
|
|
|
|
ImmBorrow,
|
|
|
|
UniqueImmBorrow,
|
|
|
|
MutBorrow
|
|
|
|
});
|
|
|
|
|
2017-09-14 15:10:24 +02:00
|
|
|
impl<'gcx> HashStable<StableHashingContext<'gcx>>
|
2017-08-08 17:56:28 +02:00
|
|
|
for ty::UpvarCapture<'gcx> {
|
2017-03-30 15:27:27 +02:00
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
2017-09-14 15:10:24 +02:00
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
2017-03-30 15:27:27 +02:00
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
mem::discriminant(self).hash_stable(hcx, hasher);
|
|
|
|
match *self {
|
|
|
|
ty::UpvarCapture::ByValue => {}
|
|
|
|
ty::UpvarCapture::ByRef(ref up_var_borrow) => {
|
|
|
|
up_var_borrow.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-26 14:34:03 +01:00
|
|
|
impl_stable_hash_for!(struct ty::GenSig<'tcx> {
|
2017-07-10 21:11:31 +02:00
|
|
|
yield_ty,
|
2016-12-26 14:34:03 +01:00
|
|
|
return_ty
|
|
|
|
});
|
|
|
|
|
2017-03-30 15:27:27 +02:00
|
|
|
impl_stable_hash_for!(struct ty::FnSig<'tcx> {
|
|
|
|
inputs_and_output,
|
|
|
|
variadic,
|
|
|
|
unsafety,
|
|
|
|
abi
|
|
|
|
});
|
|
|
|
|
2017-09-14 15:10:24 +02:00
|
|
|
impl<'gcx, T> HashStable<StableHashingContext<'gcx>> for ty::Binder<T>
|
|
|
|
where T: HashStable<StableHashingContext<'gcx>>
|
2017-03-30 15:27:27 +02:00
|
|
|
{
|
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
2017-09-14 15:10:24 +02:00
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
2017-03-30 15:27:27 +02:00
|
|
|
hasher: &mut StableHasher<W>) {
|
2017-08-08 17:56:28 +02:00
|
|
|
let ty::Binder(ref inner) = *self;
|
|
|
|
inner.hash_stable(hcx, hasher);
|
2017-03-30 15:27:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl_stable_hash_for!(enum ty::ClosureKind { Fn, FnMut, FnOnce });
|
|
|
|
|
|
|
|
impl_stable_hash_for!(enum ty::Visibility {
|
|
|
|
Public,
|
|
|
|
Restricted(def_id),
|
|
|
|
Invisible
|
|
|
|
});
|
|
|
|
|
|
|
|
impl_stable_hash_for!(struct ty::TraitRef<'tcx> { def_id, substs });
|
|
|
|
impl_stable_hash_for!(struct ty::TraitPredicate<'tcx> { trait_ref });
|
|
|
|
impl_stable_hash_for!(tuple_struct ty::EquatePredicate<'tcx> { t1, t2 });
|
2017-03-09 21:47:09 -05:00
|
|
|
impl_stable_hash_for!(struct ty::SubtypePredicate<'tcx> { a_is_expected, a, b });
|
2017-03-30 15:27:27 +02:00
|
|
|
|
2017-09-14 15:10:24 +02:00
|
|
|
impl<'gcx, A, B> HashStable<StableHashingContext<'gcx>>
|
2017-06-02 15:45:56 +02:00
|
|
|
for ty::OutlivesPredicate<A, B>
|
2017-09-14 15:10:24 +02:00
|
|
|
where A: HashStable<StableHashingContext<'gcx>>,
|
|
|
|
B: HashStable<StableHashingContext<'gcx>>,
|
2017-03-30 15:27:27 +02:00
|
|
|
{
|
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
2017-09-14 15:10:24 +02:00
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
2017-03-30 15:27:27 +02:00
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
let ty::OutlivesPredicate(ref a, ref b) = *self;
|
|
|
|
a.hash_stable(hcx, hasher);
|
|
|
|
b.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl_stable_hash_for!(struct ty::ProjectionPredicate<'tcx> { projection_ty, ty });
|
2017-07-11 10:33:09 -04:00
|
|
|
impl_stable_hash_for!(struct ty::ProjectionTy<'tcx> { substs, item_def_id });
|
2017-03-30 15:27:27 +02:00
|
|
|
|
|
|
|
|
2017-09-14 15:10:24 +02:00
|
|
|
impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::Predicate<'gcx> {
|
2017-03-30 15:27:27 +02:00
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
2017-09-14 15:10:24 +02:00
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
2017-03-30 15:27:27 +02:00
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
mem::discriminant(self).hash_stable(hcx, hasher);
|
|
|
|
match *self {
|
|
|
|
ty::Predicate::Trait(ref pred) => {
|
|
|
|
pred.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
ty::Predicate::Equate(ref pred) => {
|
|
|
|
pred.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-03-09 21:47:09 -05:00
|
|
|
ty::Predicate::Subtype(ref pred) => {
|
|
|
|
pred.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-03-30 15:27:27 +02:00
|
|
|
ty::Predicate::RegionOutlives(ref pred) => {
|
|
|
|
pred.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
ty::Predicate::TypeOutlives(ref pred) => {
|
|
|
|
pred.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
ty::Predicate::Projection(ref pred) => {
|
|
|
|
pred.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
ty::Predicate::WellFormed(ty) => {
|
|
|
|
ty.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
ty::Predicate::ObjectSafe(def_id) => {
|
|
|
|
def_id.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-11-08 08:50:59 -05:00
|
|
|
ty::Predicate::ClosureKind(def_id, closure_substs, closure_kind) => {
|
2017-03-30 15:27:27 +02:00
|
|
|
def_id.hash_stable(hcx, hasher);
|
2017-11-08 08:50:59 -05:00
|
|
|
closure_substs.hash_stable(hcx, hasher);
|
2017-03-30 15:27:27 +02:00
|
|
|
closure_kind.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-08-07 08:08:53 +03:00
|
|
|
ty::Predicate::ConstEvaluatable(def_id, substs) => {
|
|
|
|
def_id.hash_stable(hcx, hasher);
|
|
|
|
substs.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-03-30 15:27:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-14 15:10:24 +02:00
|
|
|
impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::AdtFlags {
|
2017-03-30 15:27:27 +02:00
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
2017-09-14 15:10:24 +02:00
|
|
|
_: &mut StableHashingContext<'gcx>,
|
2017-03-30 15:27:27 +02:00
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
std_hash::Hash::hash(self, hasher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl_stable_hash_for!(struct ty::VariantDef {
|
|
|
|
did,
|
|
|
|
name,
|
|
|
|
discr,
|
|
|
|
fields,
|
|
|
|
ctor_kind
|
|
|
|
});
|
|
|
|
|
|
|
|
impl_stable_hash_for!(enum ty::VariantDiscr {
|
|
|
|
Explicit(def_id),
|
|
|
|
Relative(distance)
|
|
|
|
});
|
|
|
|
|
|
|
|
impl_stable_hash_for!(struct ty::FieldDef {
|
|
|
|
did,
|
|
|
|
name,
|
|
|
|
vis
|
|
|
|
});
|
|
|
|
|
2017-09-14 15:10:24 +02:00
|
|
|
impl<'gcx> HashStable<StableHashingContext<'gcx>>
|
2017-08-08 17:56:28 +02:00
|
|
|
for ::middle::const_val::ConstVal<'gcx> {
|
2017-03-30 15:27:27 +02:00
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
2017-09-14 15:10:24 +02:00
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
2017-03-30 15:27:27 +02:00
|
|
|
hasher: &mut StableHasher<W>) {
|
2017-08-04 00:41:44 +03:00
|
|
|
use middle::const_val::ConstVal::*;
|
|
|
|
use middle::const_val::ConstAggregate::*;
|
2017-03-30 15:27:27 +02:00
|
|
|
|
|
|
|
mem::discriminant(self).hash_stable(hcx, hasher);
|
|
|
|
|
|
|
|
match *self {
|
2017-08-04 11:25:13 +03:00
|
|
|
Integral(ref value) => {
|
2017-03-30 15:27:27 +02:00
|
|
|
value.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-08-04 11:25:13 +03:00
|
|
|
Float(ref value) => {
|
2017-03-30 15:27:27 +02:00
|
|
|
value.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-08-04 00:41:44 +03:00
|
|
|
Str(ref value) => {
|
2017-03-30 15:27:27 +02:00
|
|
|
value.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-08-04 00:41:44 +03:00
|
|
|
ByteStr(ref value) => {
|
2017-03-30 15:27:27 +02:00
|
|
|
value.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-08-04 00:41:44 +03:00
|
|
|
Bool(value) => {
|
2017-03-30 15:27:27 +02:00
|
|
|
value.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-08-04 00:41:44 +03:00
|
|
|
Char(value) => {
|
2017-04-19 15:16:19 +03:00
|
|
|
value.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-08-04 00:41:44 +03:00
|
|
|
Variant(def_id) => {
|
2017-04-19 15:16:19 +03:00
|
|
|
def_id.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-08-04 00:41:44 +03:00
|
|
|
Function(def_id, substs) => {
|
2017-03-30 15:27:27 +02:00
|
|
|
def_id.hash_stable(hcx, hasher);
|
2017-08-14 18:19:42 +02:00
|
|
|
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
|
|
|
|
substs.hash_stable(hcx, hasher);
|
|
|
|
});
|
2017-03-30 15:27:27 +02:00
|
|
|
}
|
2017-08-04 00:41:44 +03:00
|
|
|
Aggregate(Struct(ref name_values)) => {
|
|
|
|
let mut values = name_values.to_vec();
|
2017-04-05 23:39:02 +02:00
|
|
|
values.sort_unstable_by_key(|&(ref name, _)| name.clone());
|
|
|
|
values.hash_stable(hcx, hasher);
|
2017-03-30 15:27:27 +02:00
|
|
|
}
|
2017-08-04 00:41:44 +03:00
|
|
|
Aggregate(Tuple(ref value)) => {
|
2017-03-30 15:27:27 +02:00
|
|
|
value.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-08-04 00:41:44 +03:00
|
|
|
Aggregate(Array(ref value)) => {
|
2017-03-30 15:27:27 +02:00
|
|
|
value.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-08-04 00:41:44 +03:00
|
|
|
Aggregate(Repeat(ref value, times)) => {
|
2017-03-30 15:27:27 +02:00
|
|
|
value.hash_stable(hcx, hasher);
|
|
|
|
times.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-08-07 08:08:53 +03:00
|
|
|
Unevaluated(def_id, substs) => {
|
|
|
|
def_id.hash_stable(hcx, hasher);
|
|
|
|
substs.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-03-30 15:27:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-04 00:41:44 +03:00
|
|
|
impl_stable_hash_for!(struct ::middle::const_val::ByteArray<'tcx> {
|
|
|
|
data
|
|
|
|
});
|
|
|
|
|
2017-08-04 11:25:13 +03:00
|
|
|
impl_stable_hash_for!(struct ty::Const<'tcx> {
|
|
|
|
ty,
|
|
|
|
val
|
|
|
|
});
|
|
|
|
|
2017-08-14 18:19:42 +02:00
|
|
|
impl_stable_hash_for!(struct ::middle::const_val::ConstEvalErr<'tcx> {
|
|
|
|
span,
|
|
|
|
kind
|
|
|
|
});
|
|
|
|
|
2017-09-14 15:10:24 +02:00
|
|
|
impl<'gcx> HashStable<StableHashingContext<'gcx>>
|
2017-08-14 18:19:42 +02:00
|
|
|
for ::middle::const_val::ErrKind<'gcx> {
|
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
2017-09-14 15:10:24 +02:00
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
2017-08-14 18:19:42 +02:00
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
use middle::const_val::ErrKind::*;
|
|
|
|
|
|
|
|
mem::discriminant(self).hash_stable(hcx, hasher);
|
|
|
|
|
|
|
|
match *self {
|
|
|
|
CannotCast |
|
|
|
|
MissingStructField |
|
|
|
|
NonConstPath |
|
|
|
|
ExpectedConstTuple |
|
|
|
|
ExpectedConstStruct |
|
|
|
|
IndexedNonVec |
|
|
|
|
IndexNotUsize |
|
|
|
|
MiscBinaryOp |
|
|
|
|
MiscCatchAll |
|
|
|
|
IndexOpFeatureGated |
|
2017-11-16 21:11:28 +09:00
|
|
|
TypeckError |
|
2017-11-24 18:50:17 +09:00
|
|
|
CheckMatchError => {
|
2017-08-14 18:19:42 +02:00
|
|
|
// nothing to do
|
|
|
|
}
|
|
|
|
UnimplementedConstVal(s) => {
|
|
|
|
s.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
IndexOutOfBounds { len, index } => {
|
|
|
|
len.hash_stable(hcx, hasher);
|
|
|
|
index.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
Math(ref const_math_err) => {
|
|
|
|
const_math_err.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
LayoutError(ref layout_error) => {
|
|
|
|
layout_error.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
ErroneousReferencedConstant(ref const_val) => {
|
|
|
|
const_val.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-30 15:27:27 +02:00
|
|
|
impl_stable_hash_for!(struct ty::ClosureSubsts<'tcx> { substs });
|
|
|
|
|
2017-10-07 16:36:28 +02:00
|
|
|
impl_stable_hash_for!(struct ty::GeneratorInterior<'tcx> { witness, movable });
|
2016-12-26 14:34:03 +01:00
|
|
|
|
2017-03-30 15:27:27 +02:00
|
|
|
impl_stable_hash_for!(struct ty::GenericPredicates<'tcx> {
|
|
|
|
parent,
|
|
|
|
predicates
|
|
|
|
});
|
|
|
|
|
|
|
|
impl_stable_hash_for!(enum ty::Variance {
|
|
|
|
Covariant,
|
|
|
|
Invariant,
|
|
|
|
Contravariant,
|
|
|
|
Bivariant
|
|
|
|
});
|
|
|
|
|
|
|
|
impl_stable_hash_for!(enum ty::adjustment::CustomCoerceUnsized {
|
|
|
|
Struct(index)
|
|
|
|
});
|
|
|
|
|
2017-09-14 15:10:24 +02:00
|
|
|
impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::Generics {
|
2017-03-30 15:27:27 +02:00
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
2017-09-14 15:10:24 +02:00
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
2017-03-30 15:27:27 +02:00
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
let ty::Generics {
|
|
|
|
parent,
|
|
|
|
parent_regions,
|
|
|
|
parent_types,
|
|
|
|
ref regions,
|
|
|
|
ref types,
|
|
|
|
|
|
|
|
// Reverse map to each `TypeParameterDef`'s `index` field, from
|
|
|
|
// `def_id.index` (`def_id.krate` is the same as the item's).
|
|
|
|
type_param_to_index: _, // Don't hash this
|
|
|
|
has_self,
|
2017-06-24 00:56:25 +03:00
|
|
|
has_late_bound_regions,
|
2017-03-30 15:27:27 +02:00
|
|
|
} = *self;
|
|
|
|
|
|
|
|
parent.hash_stable(hcx, hasher);
|
|
|
|
parent_regions.hash_stable(hcx, hasher);
|
|
|
|
parent_types.hash_stable(hcx, hasher);
|
|
|
|
regions.hash_stable(hcx, hasher);
|
|
|
|
types.hash_stable(hcx, hasher);
|
|
|
|
has_self.hash_stable(hcx, hasher);
|
2017-06-24 00:56:25 +03:00
|
|
|
has_late_bound_regions.hash_stable(hcx, hasher);
|
2017-03-30 15:27:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-14 15:10:24 +02:00
|
|
|
impl<'gcx> HashStable<StableHashingContext<'gcx>>
|
2017-06-02 15:45:56 +02:00
|
|
|
for ty::RegionParameterDef {
|
2017-03-30 15:27:27 +02:00
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
2017-09-14 15:10:24 +02:00
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
2017-03-30 15:27:27 +02:00
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
let ty::RegionParameterDef {
|
|
|
|
name,
|
|
|
|
def_id,
|
|
|
|
index,
|
|
|
|
pure_wrt_drop
|
|
|
|
} = *self;
|
|
|
|
|
|
|
|
name.hash_stable(hcx, hasher);
|
|
|
|
def_id.hash_stable(hcx, hasher);
|
|
|
|
index.hash_stable(hcx, hasher);
|
|
|
|
pure_wrt_drop.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl_stable_hash_for!(struct ty::TypeParameterDef {
|
|
|
|
name,
|
|
|
|
def_id,
|
|
|
|
index,
|
|
|
|
has_default,
|
|
|
|
object_lifetime_default,
|
2017-09-26 11:43:33 +02:00
|
|
|
pure_wrt_drop,
|
|
|
|
synthetic
|
2017-03-30 15:27:27 +02:00
|
|
|
});
|
|
|
|
|
2017-09-14 15:10:24 +02:00
|
|
|
impl<'gcx, T> HashStable<StableHashingContext<'gcx>>
|
2017-03-30 15:27:27 +02:00
|
|
|
for ::middle::resolve_lifetime::Set1<T>
|
2017-09-14 15:10:24 +02:00
|
|
|
where T: HashStable<StableHashingContext<'gcx>>
|
2017-03-30 15:27:27 +02:00
|
|
|
{
|
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
2017-09-14 15:10:24 +02:00
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
2017-03-30 15:27:27 +02:00
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
use middle::resolve_lifetime::Set1;
|
|
|
|
|
|
|
|
mem::discriminant(self).hash_stable(hcx, hasher);
|
|
|
|
match *self {
|
|
|
|
Set1::Empty |
|
|
|
|
Set1::Many => {
|
|
|
|
// Nothing to do.
|
|
|
|
}
|
|
|
|
Set1::One(ref value) => {
|
|
|
|
value.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-16 22:59:45 -08:00
|
|
|
impl_stable_hash_for!(enum ::middle::resolve_lifetime::LifetimeDefOrigin {
|
|
|
|
Explicit,
|
|
|
|
InBand
|
|
|
|
});
|
|
|
|
|
2017-03-30 15:27:27 +02:00
|
|
|
impl_stable_hash_for!(enum ::middle::resolve_lifetime::Region {
|
|
|
|
Static,
|
2017-11-16 22:59:45 -08:00
|
|
|
EarlyBound(index, decl, is_in_band),
|
|
|
|
LateBound(db_index, decl, is_in_band),
|
2017-03-30 15:27:27 +02:00
|
|
|
LateBoundAnon(db_index, anon_index),
|
|
|
|
Free(call_site_scope_data, decl)
|
|
|
|
});
|
|
|
|
|
|
|
|
impl_stable_hash_for!(struct ty::DebruijnIndex {
|
|
|
|
depth
|
|
|
|
});
|
2017-04-05 13:00:17 +02:00
|
|
|
|
|
|
|
impl_stable_hash_for!(enum ty::cast::CastKind {
|
|
|
|
CoercionCast,
|
|
|
|
PtrPtrCast,
|
|
|
|
PtrAddrCast,
|
|
|
|
AddrPtrCast,
|
|
|
|
NumericCast,
|
|
|
|
EnumCast,
|
|
|
|
PrimIntCast,
|
|
|
|
U8CharCast,
|
|
|
|
ArrayPtrCast,
|
|
|
|
FnPtrPtrCast,
|
|
|
|
FnPtrAddrCast
|
|
|
|
});
|
|
|
|
|
2017-10-16 10:45:23 -03:00
|
|
|
impl_stable_hash_for!(tuple_struct ::middle::region::FirstStatementIndex { idx });
|
2017-09-24 17:20:37 +03:00
|
|
|
impl_stable_hash_for!(struct ::middle::region::Scope { id, code });
|
2017-09-13 18:20:27 +02:00
|
|
|
|
2017-09-14 15:10:24 +02:00
|
|
|
impl<'gcx> ToStableHashKey<StableHashingContext<'gcx>> for region::Scope {
|
2017-09-13 18:20:27 +02:00
|
|
|
type KeyType = region::Scope;
|
|
|
|
|
|
|
|
#[inline]
|
2017-09-14 15:10:24 +02:00
|
|
|
fn to_stable_hash_key(&self, _: &StableHashingContext<'gcx>) -> region::Scope {
|
2017-09-13 18:20:27 +02:00
|
|
|
*self
|
2017-04-05 13:00:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl_stable_hash_for!(struct ::middle::region::BlockRemainder {
|
|
|
|
block,
|
|
|
|
first_statement_index
|
|
|
|
});
|
|
|
|
|
|
|
|
impl_stable_hash_for!(struct ty::adjustment::CoerceUnsizedInfo {
|
|
|
|
custom_kind
|
|
|
|
});
|
|
|
|
|
2017-05-07 19:57:51 +03:00
|
|
|
impl_stable_hash_for!(struct ty::FreeRegion {
|
2017-04-05 13:00:17 +02:00
|
|
|
scope,
|
|
|
|
bound_region
|
|
|
|
});
|
|
|
|
|
|
|
|
impl_stable_hash_for!(enum ty::BoundRegion {
|
|
|
|
BrAnon(index),
|
|
|
|
BrNamed(def_id, name),
|
|
|
|
BrFresh(index),
|
|
|
|
BrEnv
|
|
|
|
});
|
|
|
|
|
2017-09-14 15:10:24 +02:00
|
|
|
impl<'gcx> HashStable<StableHashingContext<'gcx>>
|
2017-08-08 17:56:28 +02:00
|
|
|
for ty::TypeVariants<'gcx>
|
2017-04-05 13:00:17 +02:00
|
|
|
{
|
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
2017-09-14 15:10:24 +02:00
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
2017-04-05 13:00:17 +02:00
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
use ty::TypeVariants::*;
|
|
|
|
|
|
|
|
mem::discriminant(self).hash_stable(hcx, hasher);
|
|
|
|
match *self {
|
|
|
|
TyBool |
|
|
|
|
TyChar |
|
|
|
|
TyStr |
|
2017-08-14 18:19:42 +02:00
|
|
|
TyError |
|
2017-04-05 13:00:17 +02:00
|
|
|
TyNever => {
|
|
|
|
// Nothing more to hash.
|
|
|
|
}
|
|
|
|
TyInt(int_ty) => {
|
|
|
|
int_ty.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
TyUint(uint_ty) => {
|
|
|
|
uint_ty.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
TyFloat(float_ty) => {
|
|
|
|
float_ty.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
TyAdt(adt_def, substs) => {
|
|
|
|
adt_def.hash_stable(hcx, hasher);
|
|
|
|
substs.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
TyArray(inner_ty, len) => {
|
|
|
|
inner_ty.hash_stable(hcx, hasher);
|
|
|
|
len.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
TySlice(inner_ty) => {
|
|
|
|
inner_ty.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
TyRawPtr(pointee_ty) => {
|
|
|
|
pointee_ty.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
TyRef(region, pointee_ty) => {
|
|
|
|
region.hash_stable(hcx, hasher);
|
|
|
|
pointee_ty.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-05-13 17:11:52 +03:00
|
|
|
TyFnDef(def_id, substs) => {
|
2017-04-05 13:00:17 +02:00
|
|
|
def_id.hash_stable(hcx, hasher);
|
|
|
|
substs.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
TyFnPtr(ref sig) => {
|
|
|
|
sig.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
TyDynamic(ref existential_predicates, region) => {
|
|
|
|
existential_predicates.hash_stable(hcx, hasher);
|
|
|
|
region.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
TyClosure(def_id, closure_substs) => {
|
|
|
|
def_id.hash_stable(hcx, hasher);
|
|
|
|
closure_substs.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-09-03 19:53:58 +01:00
|
|
|
TyGenerator(def_id, closure_substs, interior) => {
|
2016-12-26 14:34:03 +01:00
|
|
|
def_id.hash_stable(hcx, hasher);
|
|
|
|
closure_substs.hash_stable(hcx, hasher);
|
|
|
|
interior.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-10-07 16:36:28 +02:00
|
|
|
TyGeneratorWitness(types) => {
|
|
|
|
types.hash_stable(hcx, hasher)
|
|
|
|
}
|
2017-04-05 13:00:17 +02:00
|
|
|
TyTuple(inner_tys, from_diverging_type_var) => {
|
|
|
|
inner_tys.hash_stable(hcx, hasher);
|
|
|
|
from_diverging_type_var.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
TyProjection(ref projection_ty) => {
|
|
|
|
projection_ty.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
TyAnon(def_id, substs) => {
|
|
|
|
def_id.hash_stable(hcx, hasher);
|
|
|
|
substs.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
TyParam(param_ty) => {
|
|
|
|
param_ty.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-09-03 19:53:58 +01:00
|
|
|
TyForeign(def_id) => {
|
|
|
|
def_id.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-04-05 13:00:17 +02:00
|
|
|
TyInfer(..) => {
|
2017-08-14 18:19:42 +02:00
|
|
|
bug!("ty::TypeVariants::hash_stable() - Unexpected variant {:?}.", *self)
|
2017-04-05 13:00:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl_stable_hash_for!(struct ty::ParamTy {
|
|
|
|
idx,
|
|
|
|
name
|
|
|
|
});
|
|
|
|
|
|
|
|
impl_stable_hash_for!(struct ty::TypeAndMut<'tcx> {
|
|
|
|
ty,
|
|
|
|
mutbl
|
|
|
|
});
|
|
|
|
|
2017-09-14 15:10:24 +02:00
|
|
|
impl<'gcx> HashStable<StableHashingContext<'gcx>>
|
2017-08-08 17:56:28 +02:00
|
|
|
for ty::ExistentialPredicate<'gcx>
|
2017-04-05 13:00:17 +02:00
|
|
|
{
|
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
2017-09-14 15:10:24 +02:00
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
2017-04-05 13:00:17 +02:00
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
mem::discriminant(self).hash_stable(hcx, hasher);
|
|
|
|
match *self {
|
|
|
|
ty::ExistentialPredicate::Trait(ref trait_ref) => {
|
|
|
|
trait_ref.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
ty::ExistentialPredicate::Projection(ref projection) => {
|
|
|
|
projection.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
ty::ExistentialPredicate::AutoTrait(def_id) => {
|
|
|
|
def_id.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl_stable_hash_for!(struct ty::ExistentialTraitRef<'tcx> {
|
|
|
|
def_id,
|
|
|
|
substs
|
|
|
|
});
|
|
|
|
|
|
|
|
impl_stable_hash_for!(struct ty::ExistentialProjection<'tcx> {
|
2017-07-11 10:33:09 -04:00
|
|
|
item_def_id,
|
|
|
|
substs,
|
2017-04-05 13:00:17 +02:00
|
|
|
ty
|
|
|
|
});
|
|
|
|
|
2017-06-30 14:51:03 -07:00
|
|
|
impl_stable_hash_for!(struct ty::Instance<'tcx> {
|
|
|
|
def,
|
|
|
|
substs
|
|
|
|
});
|
|
|
|
|
2017-09-14 15:10:24 +02:00
|
|
|
impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::InstanceDef<'gcx> {
|
2017-06-30 14:51:03 -07:00
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
2017-09-14 15:10:24 +02:00
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
2017-06-30 14:51:03 -07:00
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
mem::discriminant(self).hash_stable(hcx, hasher);
|
|
|
|
|
|
|
|
match *self {
|
|
|
|
ty::InstanceDef::Item(def_id) => {
|
|
|
|
def_id.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
ty::InstanceDef::Intrinsic(def_id) => {
|
|
|
|
def_id.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
ty::InstanceDef::FnPtrShim(def_id, ty) => {
|
|
|
|
def_id.hash_stable(hcx, hasher);
|
|
|
|
ty.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
ty::InstanceDef::Virtual(def_id, n) => {
|
|
|
|
def_id.hash_stable(hcx, hasher);
|
|
|
|
n.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
ty::InstanceDef::ClosureOnceShim { call_once } => {
|
|
|
|
call_once.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
ty::InstanceDef::DropGlue(def_id, t) => {
|
|
|
|
def_id.hash_stable(hcx, hasher);
|
|
|
|
t.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-08-07 16:21:08 +02:00
|
|
|
ty::InstanceDef::CloneShim(def_id, t) => {
|
2017-08-04 14:44:12 +02:00
|
|
|
def_id.hash_stable(hcx, hasher);
|
|
|
|
t.hash_stable(hcx, hasher);
|
|
|
|
}
|
2017-06-30 14:51:03 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-14 15:10:24 +02:00
|
|
|
impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::TraitDef {
|
2017-08-14 18:19:42 +02:00
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
2017-09-14 15:10:24 +02:00
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
2017-08-14 18:19:42 +02:00
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
let ty::TraitDef {
|
|
|
|
// We already have the def_path_hash below, no need to hash it twice
|
|
|
|
def_id: _,
|
|
|
|
unsafety,
|
|
|
|
paren_sugar,
|
2017-10-09 13:59:20 -03:00
|
|
|
has_auto_impl,
|
2017-08-14 18:19:42 +02:00
|
|
|
def_path_hash,
|
|
|
|
} = *self;
|
|
|
|
|
|
|
|
unsafety.hash_stable(hcx, hasher);
|
|
|
|
paren_sugar.hash_stable(hcx, hasher);
|
2017-10-09 13:59:20 -03:00
|
|
|
has_auto_impl.hash_stable(hcx, hasher);
|
2017-08-14 18:19:42 +02:00
|
|
|
def_path_hash.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl_stable_hash_for!(struct ty::Destructor {
|
|
|
|
did
|
|
|
|
});
|
|
|
|
|
|
|
|
impl_stable_hash_for!(struct ty::DtorckConstraint<'tcx> {
|
|
|
|
outlives,
|
|
|
|
dtorck_types
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2017-09-14 15:10:24 +02:00
|
|
|
impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::CrateVariancesMap {
|
2017-08-14 18:19:42 +02:00
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
2017-09-14 15:10:24 +02:00
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
2017-08-14 18:19:42 +02:00
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
let ty::CrateVariancesMap {
|
|
|
|
ref variances,
|
|
|
|
// This is just an irrelevant helper value.
|
|
|
|
empty_variance: _,
|
|
|
|
} = *self;
|
|
|
|
|
2017-09-13 18:20:27 +02:00
|
|
|
variances.hash_stable(hcx, hasher);
|
2017-08-14 18:19:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl_stable_hash_for!(struct ty::AssociatedItem {
|
|
|
|
def_id,
|
|
|
|
name,
|
|
|
|
kind,
|
|
|
|
vis,
|
|
|
|
defaultness,
|
|
|
|
container,
|
|
|
|
method_has_self_argument
|
|
|
|
});
|
|
|
|
|
|
|
|
impl_stable_hash_for!(enum ty::AssociatedKind {
|
|
|
|
Const,
|
|
|
|
Method,
|
|
|
|
Type
|
|
|
|
});
|
|
|
|
|
|
|
|
impl_stable_hash_for!(enum ty::AssociatedItemContainer {
|
|
|
|
TraitContainer(def_id),
|
|
|
|
ImplContainer(def_id)
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2017-09-14 15:10:24 +02:00
|
|
|
impl<'gcx, T> HashStable<StableHashingContext<'gcx>>
|
2017-08-14 18:19:42 +02:00
|
|
|
for ty::steal::Steal<T>
|
2017-09-14 15:10:24 +02:00
|
|
|
where T: HashStable<StableHashingContext<'gcx>>
|
2017-08-14 18:19:42 +02:00
|
|
|
{
|
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
2017-09-14 15:10:24 +02:00
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
2017-08-14 18:19:42 +02:00
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
self.borrow().hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl_stable_hash_for!(struct ty::ParamEnv<'tcx> {
|
|
|
|
caller_bounds,
|
|
|
|
reveal
|
|
|
|
});
|
|
|
|
|
|
|
|
impl_stable_hash_for!(enum traits::Reveal {
|
|
|
|
UserFacing,
|
|
|
|
All
|
|
|
|
});
|
|
|
|
|
|
|
|
impl_stable_hash_for!(enum ::middle::privacy::AccessLevel {
|
|
|
|
Reachable,
|
|
|
|
Exported,
|
|
|
|
Public
|
|
|
|
});
|
|
|
|
|
2017-09-14 15:10:24 +02:00
|
|
|
impl<'gcx> HashStable<StableHashingContext<'gcx>>
|
2017-08-14 18:19:42 +02:00
|
|
|
for ::middle::privacy::AccessLevels {
|
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
2017-09-14 15:10:24 +02:00
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
2017-08-14 18:19:42 +02:00
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
|
|
|
|
let ::middle::privacy::AccessLevels {
|
|
|
|
ref map
|
|
|
|
} = *self;
|
|
|
|
|
2017-09-13 18:20:27 +02:00
|
|
|
map.hash_stable(hcx, hasher);
|
2017-08-14 18:19:42 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-13 18:20:27 +02:00
|
|
|
impl_stable_hash_for!(struct ty::CrateInherentImpls {
|
|
|
|
inherent_impls
|
|
|
|
});
|
2017-08-14 18:19:42 +02:00
|
|
|
|
|
|
|
impl_stable_hash_for!(enum ::session::CompileIncomplete {
|
|
|
|
Stopped,
|
|
|
|
Errored(error_reported)
|
|
|
|
});
|
|
|
|
|
|
|
|
impl_stable_hash_for!(struct ::util::common::ErrorReported {});
|
|
|
|
|
2017-09-13 18:20:27 +02:00
|
|
|
impl_stable_hash_for!(tuple_struct ::middle::reachable::ReachableSet {
|
|
|
|
reachable_set
|
|
|
|
});
|
2017-09-28 23:13:43 -04:00
|
|
|
|
|
|
|
impl<'gcx, N> HashStable<StableHashingContext<'gcx>>
|
|
|
|
for traits::Vtable<'gcx, N> where N: HashStable<StableHashingContext<'gcx>> {
|
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
use traits::Vtable::*;
|
|
|
|
|
|
|
|
mem::discriminant(self).hash_stable(hcx, hasher);
|
|
|
|
|
|
|
|
match self {
|
|
|
|
&VtableImpl(ref table_impl) => table_impl.hash_stable(hcx, hasher),
|
2017-10-13 13:58:46 -03:00
|
|
|
&VtableAutoImpl(ref table_def_impl) => table_def_impl.hash_stable(hcx, hasher),
|
2017-09-28 23:13:43 -04:00
|
|
|
&VtableParam(ref table_param) => table_param.hash_stable(hcx, hasher),
|
|
|
|
&VtableObject(ref table_obj) => table_obj.hash_stable(hcx, hasher),
|
|
|
|
&VtableBuiltin(ref table_builtin) => table_builtin.hash_stable(hcx, hasher),
|
|
|
|
&VtableClosure(ref table_closure) => table_closure.hash_stable(hcx, hasher),
|
|
|
|
&VtableFnPointer(ref table_fn_pointer) => table_fn_pointer.hash_stable(hcx, hasher),
|
|
|
|
&VtableGenerator(ref table_generator) => table_generator.hash_stable(hcx, hasher),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'gcx, N> HashStable<StableHashingContext<'gcx>>
|
|
|
|
for traits::VtableImplData<'gcx, N> where N: HashStable<StableHashingContext<'gcx>> {
|
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
let traits::VtableImplData {
|
|
|
|
impl_def_id,
|
|
|
|
substs,
|
|
|
|
ref nested,
|
|
|
|
} = *self;
|
|
|
|
impl_def_id.hash_stable(hcx, hasher);
|
|
|
|
substs.hash_stable(hcx, hasher);
|
|
|
|
nested.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'gcx, N> HashStable<StableHashingContext<'gcx>>
|
2017-10-13 13:58:46 -03:00
|
|
|
for traits::VtableAutoImplData<N> where N: HashStable<StableHashingContext<'gcx>> {
|
2017-09-28 23:13:43 -04:00
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
|
|
|
hasher: &mut StableHasher<W>) {
|
2017-10-13 13:58:46 -03:00
|
|
|
let traits::VtableAutoImplData {
|
2017-09-28 23:13:43 -04:00
|
|
|
trait_def_id,
|
|
|
|
ref nested,
|
|
|
|
} = *self;
|
|
|
|
trait_def_id.hash_stable(hcx, hasher);
|
|
|
|
nested.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'gcx, N> HashStable<StableHashingContext<'gcx>>
|
|
|
|
for traits::VtableObjectData<'gcx, N> where N: HashStable<StableHashingContext<'gcx>> {
|
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
let traits::VtableObjectData {
|
|
|
|
upcast_trait_ref,
|
|
|
|
vtable_base,
|
|
|
|
ref nested,
|
|
|
|
} = *self;
|
|
|
|
upcast_trait_ref.hash_stable(hcx, hasher);
|
|
|
|
vtable_base.hash_stable(hcx, hasher);
|
|
|
|
nested.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'gcx, N> HashStable<StableHashingContext<'gcx>>
|
|
|
|
for traits::VtableBuiltinData<N> where N: HashStable<StableHashingContext<'gcx>> {
|
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
let traits::VtableBuiltinData {
|
|
|
|
ref nested,
|
|
|
|
} = *self;
|
|
|
|
nested.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'gcx, N> HashStable<StableHashingContext<'gcx>>
|
|
|
|
for traits::VtableClosureData<'gcx, N> where N: HashStable<StableHashingContext<'gcx>> {
|
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
let traits::VtableClosureData {
|
|
|
|
closure_def_id,
|
|
|
|
substs,
|
|
|
|
ref nested,
|
|
|
|
} = *self;
|
|
|
|
closure_def_id.hash_stable(hcx, hasher);
|
|
|
|
substs.hash_stable(hcx, hasher);
|
|
|
|
nested.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'gcx, N> HashStable<StableHashingContext<'gcx>>
|
|
|
|
for traits::VtableFnPointerData<'gcx, N> where N: HashStable<StableHashingContext<'gcx>> {
|
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
let traits::VtableFnPointerData {
|
|
|
|
fn_ty,
|
|
|
|
ref nested,
|
|
|
|
} = *self;
|
|
|
|
fn_ty.hash_stable(hcx, hasher);
|
|
|
|
nested.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'gcx, N> HashStable<StableHashingContext<'gcx>>
|
|
|
|
for traits::VtableGeneratorData<'gcx, N> where N: HashStable<StableHashingContext<'gcx>> {
|
|
|
|
fn hash_stable<W: StableHasherResult>(&self,
|
|
|
|
hcx: &mut StableHashingContext<'gcx>,
|
|
|
|
hasher: &mut StableHasher<W>) {
|
|
|
|
let traits::VtableGeneratorData {
|
|
|
|
closure_def_id,
|
|
|
|
substs,
|
|
|
|
ref nested,
|
|
|
|
} = *self;
|
|
|
|
closure_def_id.hash_stable(hcx, hasher);
|
|
|
|
substs.hash_stable(hcx, hasher);
|
|
|
|
nested.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
}
|