1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 //! This module contains `HashStable` implementations for various data types
12 //! from rustc::ty in no particular order.
14 use ich::{Fingerprint, StableHashingContext, NodeIdHashingMode};
15 use rustc_data_structures::fx::FxHashMap;
16 use rustc_data_structures::stable_hasher::{HashStable, ToStableHashKey,
17 StableHasher, StableHasherResult};
18 use std::cell::RefCell;
19 use std::hash as std_hash;
25 impl<'gcx, T> HashStable<StableHashingContext<'gcx>>
26 for &'gcx ty::Slice<T>
27 where T: HashStable<StableHashingContext<'gcx>> {
28 fn hash_stable<W: StableHasherResult>(&self,
29 hcx: &mut StableHashingContext<'gcx>,
30 hasher: &mut StableHasher<W>) {
32 static CACHE: RefCell<FxHashMap<(usize, usize), Fingerprint>> =
33 RefCell::new(FxHashMap());
36 let hash = CACHE.with(|cache| {
37 let key = (self.as_ptr() as usize, self.len());
38 if let Some(&hash) = cache.borrow().get(&key) {
42 let mut hasher = StableHasher::new();
43 (&self[..]).hash_stable(hcx, &mut hasher);
45 let hash: Fingerprint = hasher.finish();
46 cache.borrow_mut().insert(key, hash);
50 hash.hash_stable(hcx, hasher);
54 impl<'gcx> HashStable<StableHashingContext<'gcx>>
55 for ty::subst::Kind<'gcx> {
56 fn hash_stable<W: StableHasherResult>(&self,
57 hcx: &mut StableHashingContext<'gcx>,
58 hasher: &mut StableHasher<W>) {
59 self.unpack().hash_stable(hcx, hasher);
63 impl<'gcx> HashStable<StableHashingContext<'gcx>>
64 for ty::subst::UnpackedKind<'gcx> {
65 fn hash_stable<W: StableHasherResult>(&self,
66 hcx: &mut StableHashingContext<'gcx>,
67 hasher: &mut StableHasher<W>) {
69 ty::subst::UnpackedKind::Lifetime(lt) => lt.hash_stable(hcx, hasher),
70 ty::subst::UnpackedKind::Type(ty) => ty.hash_stable(hcx, hasher),
75 impl<'gcx> HashStable<StableHashingContext<'gcx>>
77 fn hash_stable<W: StableHasherResult>(&self,
78 hcx: &mut StableHashingContext<'gcx>,
79 hasher: &mut StableHasher<W>) {
80 mem::discriminant(self).hash_stable(hcx, hasher);
85 // No variant fields to hash for these ...
87 ty::ReLateBound(db, ty::BrAnon(i)) => {
88 db.depth.hash_stable(hcx, hasher);
89 i.hash_stable(hcx, hasher);
91 ty::ReLateBound(db, ty::BrNamed(def_id, name)) => {
92 db.depth.hash_stable(hcx, hasher);
93 def_id.hash_stable(hcx, hasher);
94 name.hash_stable(hcx, hasher);
96 ty::ReLateBound(db, ty::BrEnv) => {
97 db.depth.hash_stable(hcx, hasher);
99 ty::ReEarlyBound(ty::EarlyBoundRegion { def_id, index, name }) => {
100 def_id.hash_stable(hcx, hasher);
101 index.hash_stable(hcx, hasher);
102 name.hash_stable(hcx, hasher);
104 ty::ReScope(scope) => {
105 scope.hash_stable(hcx, hasher);
107 ty::ReFree(ref free_region) => {
108 free_region.hash_stable(hcx, hasher);
110 ty::ReClosureBound(vid) => {
111 vid.hash_stable(hcx, hasher);
113 ty::ReLateBound(..) |
115 ty::ReSkolemized(..) => {
116 bug!("TypeIdHasher: unexpected region {:?}", *self)
122 impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::RegionVid {
124 fn hash_stable<W: StableHasherResult>(&self,
125 hcx: &mut StableHashingContext<'gcx>,
126 hasher: &mut StableHasher<W>) {
127 use rustc_data_structures::indexed_vec::Idx;
128 self.index().hash_stable(hcx, hasher);
132 impl<'gcx> HashStable<StableHashingContext<'gcx>>
133 for ty::adjustment::AutoBorrow<'gcx> {
134 fn hash_stable<W: StableHasherResult>(&self,
135 hcx: &mut StableHashingContext<'gcx>,
136 hasher: &mut StableHasher<W>) {
137 mem::discriminant(self).hash_stable(hcx, hasher);
139 ty::adjustment::AutoBorrow::Ref(ref region, mutability) => {
140 region.hash_stable(hcx, hasher);
141 mutability.hash_stable(hcx, hasher);
143 ty::adjustment::AutoBorrow::RawPtr(mutability) => {
144 mutability.hash_stable(hcx, hasher);
150 impl<'gcx> HashStable<StableHashingContext<'gcx>>
151 for ty::adjustment::Adjust<'gcx> {
152 fn hash_stable<W: StableHasherResult>(&self,
153 hcx: &mut StableHashingContext<'gcx>,
154 hasher: &mut StableHasher<W>) {
155 mem::discriminant(self).hash_stable(hcx, hasher);
157 ty::adjustment::Adjust::NeverToAny |
158 ty::adjustment::Adjust::ReifyFnPointer |
159 ty::adjustment::Adjust::UnsafeFnPointer |
160 ty::adjustment::Adjust::ClosureFnPointer |
161 ty::adjustment::Adjust::MutToConstPointer |
162 ty::adjustment::Adjust::Unsize => {}
163 ty::adjustment::Adjust::Deref(ref overloaded) => {
164 overloaded.hash_stable(hcx, hasher);
166 ty::adjustment::Adjust::Borrow(ref autoref) => {
167 autoref.hash_stable(hcx, hasher);
173 impl_stable_hash_for!(struct ty::adjustment::Adjustment<'tcx> { kind, target });
174 impl_stable_hash_for!(struct ty::adjustment::OverloadedDeref<'tcx> { region, mutbl });
175 impl_stable_hash_for!(struct ty::UpvarBorrow<'tcx> { kind, region });
177 impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::adjustment::AutoBorrowMutability {
178 fn hash_stable<W: StableHasherResult>(&self,
179 hcx: &mut StableHashingContext<'gcx>,
180 hasher: &mut StableHasher<W>) {
181 mem::discriminant(self).hash_stable(hcx, hasher);
183 ty::adjustment::AutoBorrowMutability::Mutable { ref allow_two_phase_borrow } => {
184 allow_two_phase_borrow.hash_stable(hcx, hasher);
186 ty::adjustment::AutoBorrowMutability::Immutable => {}
191 impl_stable_hash_for!(struct ty::UpvarId { var_id, closure_expr_id });
193 impl_stable_hash_for!(enum ty::BorrowKind {
199 impl<'gcx> HashStable<StableHashingContext<'gcx>>
200 for ty::UpvarCapture<'gcx> {
201 fn hash_stable<W: StableHasherResult>(&self,
202 hcx: &mut StableHashingContext<'gcx>,
203 hasher: &mut StableHasher<W>) {
204 mem::discriminant(self).hash_stable(hcx, hasher);
206 ty::UpvarCapture::ByValue => {}
207 ty::UpvarCapture::ByRef(ref up_var_borrow) => {
208 up_var_borrow.hash_stable(hcx, hasher);
214 impl_stable_hash_for!(struct ty::GenSig<'tcx> {
219 impl_stable_hash_for!(struct ty::FnSig<'tcx> {
226 impl<'gcx, T> HashStable<StableHashingContext<'gcx>> for ty::Binder<T>
227 where T: HashStable<StableHashingContext<'gcx>>
229 fn hash_stable<W: StableHasherResult>(&self,
230 hcx: &mut StableHashingContext<'gcx>,
231 hasher: &mut StableHasher<W>) {
232 let ty::Binder(ref inner) = *self;
233 inner.hash_stable(hcx, hasher);
237 impl_stable_hash_for!(enum ty::ClosureKind { Fn, FnMut, FnOnce });
239 impl_stable_hash_for!(enum ty::Visibility {
245 impl_stable_hash_for!(struct ty::TraitRef<'tcx> { def_id, substs });
246 impl_stable_hash_for!(struct ty::TraitPredicate<'tcx> { trait_ref });
247 impl_stable_hash_for!(tuple_struct ty::EquatePredicate<'tcx> { t1, t2 });
248 impl_stable_hash_for!(struct ty::SubtypePredicate<'tcx> { a_is_expected, a, b });
250 impl<'gcx, A, B> HashStable<StableHashingContext<'gcx>>
251 for ty::OutlivesPredicate<A, B>
252 where A: HashStable<StableHashingContext<'gcx>>,
253 B: HashStable<StableHashingContext<'gcx>>,
255 fn hash_stable<W: StableHasherResult>(&self,
256 hcx: &mut StableHashingContext<'gcx>,
257 hasher: &mut StableHasher<W>) {
258 let ty::OutlivesPredicate(ref a, ref b) = *self;
259 a.hash_stable(hcx, hasher);
260 b.hash_stable(hcx, hasher);
264 impl_stable_hash_for!(struct ty::ProjectionPredicate<'tcx> { projection_ty, ty });
265 impl_stable_hash_for!(struct ty::ProjectionTy<'tcx> { substs, item_def_id });
268 impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::Predicate<'gcx> {
269 fn hash_stable<W: StableHasherResult>(&self,
270 hcx: &mut StableHashingContext<'gcx>,
271 hasher: &mut StableHasher<W>) {
272 mem::discriminant(self).hash_stable(hcx, hasher);
274 ty::Predicate::Trait(ref pred) => {
275 pred.hash_stable(hcx, hasher);
277 ty::Predicate::Equate(ref pred) => {
278 pred.hash_stable(hcx, hasher);
280 ty::Predicate::Subtype(ref pred) => {
281 pred.hash_stable(hcx, hasher);
283 ty::Predicate::RegionOutlives(ref pred) => {
284 pred.hash_stable(hcx, hasher);
286 ty::Predicate::TypeOutlives(ref pred) => {
287 pred.hash_stable(hcx, hasher);
289 ty::Predicate::Projection(ref pred) => {
290 pred.hash_stable(hcx, hasher);
292 ty::Predicate::WellFormed(ty) => {
293 ty.hash_stable(hcx, hasher);
295 ty::Predicate::ObjectSafe(def_id) => {
296 def_id.hash_stable(hcx, hasher);
298 ty::Predicate::ClosureKind(def_id, closure_substs, closure_kind) => {
299 def_id.hash_stable(hcx, hasher);
300 closure_substs.hash_stable(hcx, hasher);
301 closure_kind.hash_stable(hcx, hasher);
303 ty::Predicate::ConstEvaluatable(def_id, substs) => {
304 def_id.hash_stable(hcx, hasher);
305 substs.hash_stable(hcx, hasher);
311 impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::AdtFlags {
312 fn hash_stable<W: StableHasherResult>(&self,
313 _: &mut StableHashingContext<'gcx>,
314 hasher: &mut StableHasher<W>) {
315 std_hash::Hash::hash(self, hasher);
319 impl_stable_hash_for!(struct ty::VariantDef {
327 impl_stable_hash_for!(enum ty::VariantDiscr {
332 impl_stable_hash_for!(struct ty::FieldDef {
338 impl<'gcx> HashStable<StableHashingContext<'gcx>>
339 for ::middle::const_val::ConstVal<'gcx> {
340 fn hash_stable<W: StableHasherResult>(&self,
341 hcx: &mut StableHashingContext<'gcx>,
342 hasher: &mut StableHasher<W>) {
343 use middle::const_val::ConstVal::*;
344 use middle::const_val::ConstAggregate::*;
346 mem::discriminant(self).hash_stable(hcx, hasher);
349 Integral(ref value) => {
350 value.hash_stable(hcx, hasher);
352 Float(ref value) => {
353 value.hash_stable(hcx, hasher);
356 value.hash_stable(hcx, hasher);
358 ByteStr(ref value) => {
359 value.hash_stable(hcx, hasher);
362 value.hash_stable(hcx, hasher);
365 value.hash_stable(hcx, hasher);
368 def_id.hash_stable(hcx, hasher);
370 Function(def_id, substs) => {
371 def_id.hash_stable(hcx, hasher);
372 hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
373 substs.hash_stable(hcx, hasher);
376 Aggregate(Struct(ref name_values)) => {
377 let mut values = name_values.to_vec();
378 values.sort_unstable_by_key(|&(ref name, _)| name.clone());
379 values.hash_stable(hcx, hasher);
381 Aggregate(Tuple(ref value)) => {
382 value.hash_stable(hcx, hasher);
384 Aggregate(Array(ref value)) => {
385 value.hash_stable(hcx, hasher);
387 Aggregate(Repeat(ref value, times)) => {
388 value.hash_stable(hcx, hasher);
389 times.hash_stable(hcx, hasher);
391 Unevaluated(def_id, substs) => {
392 def_id.hash_stable(hcx, hasher);
393 substs.hash_stable(hcx, hasher);
399 impl_stable_hash_for!(struct ::middle::const_val::ByteArray<'tcx> {
403 impl_stable_hash_for!(struct ty::Const<'tcx> {
408 impl_stable_hash_for!(struct ::middle::const_val::ConstEvalErr<'tcx> {
413 impl<'gcx> HashStable<StableHashingContext<'gcx>>
414 for ::middle::const_val::ErrKind<'gcx> {
415 fn hash_stable<W: StableHasherResult>(&self,
416 hcx: &mut StableHashingContext<'gcx>,
417 hasher: &mut StableHasher<W>) {
418 use middle::const_val::ErrKind::*;
420 mem::discriminant(self).hash_stable(hcx, hasher);
427 ExpectedConstStruct |
432 IndexOpFeatureGated |
437 UnimplementedConstVal(s) => {
438 s.hash_stable(hcx, hasher);
440 IndexOutOfBounds { len, index } => {
441 len.hash_stable(hcx, hasher);
442 index.hash_stable(hcx, hasher);
444 Math(ref const_math_err) => {
445 const_math_err.hash_stable(hcx, hasher);
447 LayoutError(ref layout_error) => {
448 layout_error.hash_stable(hcx, hasher);
450 ErroneousReferencedConstant(ref const_val) => {
451 const_val.hash_stable(hcx, hasher);
457 impl_stable_hash_for!(struct ty::ClosureSubsts<'tcx> { substs });
459 impl_stable_hash_for!(struct ty::GeneratorInterior<'tcx> { witness, movable });
461 impl_stable_hash_for!(struct ty::GenericPredicates<'tcx> {
466 impl_stable_hash_for!(enum ty::Variance {
473 impl_stable_hash_for!(enum ty::adjustment::CustomCoerceUnsized {
477 impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::Generics {
478 fn hash_stable<W: StableHasherResult>(&self,
479 hcx: &mut StableHashingContext<'gcx>,
480 hasher: &mut StableHasher<W>) {
488 // Reverse map to each `TypeParameterDef`'s `index` field, from
489 // `def_id.index` (`def_id.krate` is the same as the item's).
490 type_param_to_index: _, // Don't hash this
492 has_late_bound_regions,
495 parent.hash_stable(hcx, hasher);
496 parent_regions.hash_stable(hcx, hasher);
497 parent_types.hash_stable(hcx, hasher);
498 regions.hash_stable(hcx, hasher);
499 types.hash_stable(hcx, hasher);
500 has_self.hash_stable(hcx, hasher);
501 has_late_bound_regions.hash_stable(hcx, hasher);
505 impl<'gcx> HashStable<StableHashingContext<'gcx>>
506 for ty::RegionParameterDef {
507 fn hash_stable<W: StableHasherResult>(&self,
508 hcx: &mut StableHashingContext<'gcx>,
509 hasher: &mut StableHasher<W>) {
510 let ty::RegionParameterDef {
517 name.hash_stable(hcx, hasher);
518 def_id.hash_stable(hcx, hasher);
519 index.hash_stable(hcx, hasher);
520 pure_wrt_drop.hash_stable(hcx, hasher);
524 impl_stable_hash_for!(struct ty::TypeParameterDef {
529 object_lifetime_default,
534 impl<'gcx, T> HashStable<StableHashingContext<'gcx>>
535 for ::middle::resolve_lifetime::Set1<T>
536 where T: HashStable<StableHashingContext<'gcx>>
538 fn hash_stable<W: StableHasherResult>(&self,
539 hcx: &mut StableHashingContext<'gcx>,
540 hasher: &mut StableHasher<W>) {
541 use middle::resolve_lifetime::Set1;
543 mem::discriminant(self).hash_stable(hcx, hasher);
549 Set1::One(ref value) => {
550 value.hash_stable(hcx, hasher);
556 impl_stable_hash_for!(enum ::middle::resolve_lifetime::LifetimeDefOrigin {
561 impl_stable_hash_for!(enum ::middle::resolve_lifetime::Region {
563 EarlyBound(index, decl, is_in_band),
564 LateBound(db_index, decl, is_in_band),
565 LateBoundAnon(db_index, anon_index),
566 Free(call_site_scope_data, decl)
569 impl_stable_hash_for!(struct ty::DebruijnIndex {
573 impl_stable_hash_for!(enum ty::cast::CastKind {
587 impl_stable_hash_for!(tuple_struct ::middle::region::FirstStatementIndex { idx });
588 impl_stable_hash_for!(struct ::middle::region::Scope { id, code });
590 impl<'gcx> ToStableHashKey<StableHashingContext<'gcx>> for region::Scope {
591 type KeyType = region::Scope;
594 fn to_stable_hash_key(&self, _: &StableHashingContext<'gcx>) -> region::Scope {
599 impl_stable_hash_for!(struct ::middle::region::BlockRemainder {
601 first_statement_index
604 impl_stable_hash_for!(struct ty::adjustment::CoerceUnsizedInfo {
608 impl_stable_hash_for!(struct ty::FreeRegion {
613 impl_stable_hash_for!(enum ty::BoundRegion {
615 BrNamed(def_id, name),
620 impl<'gcx> HashStable<StableHashingContext<'gcx>>
621 for ty::TypeVariants<'gcx>
623 fn hash_stable<W: StableHasherResult>(&self,
624 hcx: &mut StableHashingContext<'gcx>,
625 hasher: &mut StableHasher<W>) {
626 use ty::TypeVariants::*;
628 mem::discriminant(self).hash_stable(hcx, hasher);
635 // Nothing more to hash.
638 int_ty.hash_stable(hcx, hasher);
641 uint_ty.hash_stable(hcx, hasher);
643 TyFloat(float_ty) => {
644 float_ty.hash_stable(hcx, hasher);
646 TyAdt(adt_def, substs) => {
647 adt_def.hash_stable(hcx, hasher);
648 substs.hash_stable(hcx, hasher);
650 TyArray(inner_ty, len) => {
651 inner_ty.hash_stable(hcx, hasher);
652 len.hash_stable(hcx, hasher);
654 TySlice(inner_ty) => {
655 inner_ty.hash_stable(hcx, hasher);
657 TyRawPtr(pointee_ty) => {
658 pointee_ty.hash_stable(hcx, hasher);
660 TyRef(region, pointee_ty) => {
661 region.hash_stable(hcx, hasher);
662 pointee_ty.hash_stable(hcx, hasher);
664 TyFnDef(def_id, substs) => {
665 def_id.hash_stable(hcx, hasher);
666 substs.hash_stable(hcx, hasher);
668 TyFnPtr(ref sig) => {
669 sig.hash_stable(hcx, hasher);
671 TyDynamic(ref existential_predicates, region) => {
672 existential_predicates.hash_stable(hcx, hasher);
673 region.hash_stable(hcx, hasher);
675 TyClosure(def_id, closure_substs) => {
676 def_id.hash_stable(hcx, hasher);
677 closure_substs.hash_stable(hcx, hasher);
679 TyGenerator(def_id, closure_substs, interior) => {
680 def_id.hash_stable(hcx, hasher);
681 closure_substs.hash_stable(hcx, hasher);
682 interior.hash_stable(hcx, hasher);
684 TyGeneratorWitness(types) => {
685 types.hash_stable(hcx, hasher)
687 TyTuple(inner_tys, from_diverging_type_var) => {
688 inner_tys.hash_stable(hcx, hasher);
689 from_diverging_type_var.hash_stable(hcx, hasher);
691 TyProjection(ref projection_ty) => {
692 projection_ty.hash_stable(hcx, hasher);
694 TyAnon(def_id, substs) => {
695 def_id.hash_stable(hcx, hasher);
696 substs.hash_stable(hcx, hasher);
698 TyParam(param_ty) => {
699 param_ty.hash_stable(hcx, hasher);
701 TyForeign(def_id) => {
702 def_id.hash_stable(hcx, hasher);
705 bug!("ty::TypeVariants::hash_stable() - Unexpected variant {:?}.", *self)
711 impl_stable_hash_for!(struct ty::ParamTy {
716 impl_stable_hash_for!(struct ty::TypeAndMut<'tcx> {
721 impl<'gcx> HashStable<StableHashingContext<'gcx>>
722 for ty::ExistentialPredicate<'gcx>
724 fn hash_stable<W: StableHasherResult>(&self,
725 hcx: &mut StableHashingContext<'gcx>,
726 hasher: &mut StableHasher<W>) {
727 mem::discriminant(self).hash_stable(hcx, hasher);
729 ty::ExistentialPredicate::Trait(ref trait_ref) => {
730 trait_ref.hash_stable(hcx, hasher);
732 ty::ExistentialPredicate::Projection(ref projection) => {
733 projection.hash_stable(hcx, hasher);
735 ty::ExistentialPredicate::AutoTrait(def_id) => {
736 def_id.hash_stable(hcx, hasher);
742 impl_stable_hash_for!(struct ty::ExistentialTraitRef<'tcx> {
747 impl_stable_hash_for!(struct ty::ExistentialProjection<'tcx> {
753 impl_stable_hash_for!(struct ty::Instance<'tcx> {
758 impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::InstanceDef<'gcx> {
759 fn hash_stable<W: StableHasherResult>(&self,
760 hcx: &mut StableHashingContext<'gcx>,
761 hasher: &mut StableHasher<W>) {
762 mem::discriminant(self).hash_stable(hcx, hasher);
765 ty::InstanceDef::Item(def_id) => {
766 def_id.hash_stable(hcx, hasher);
768 ty::InstanceDef::Intrinsic(def_id) => {
769 def_id.hash_stable(hcx, hasher);
771 ty::InstanceDef::FnPtrShim(def_id, ty) => {
772 def_id.hash_stable(hcx, hasher);
773 ty.hash_stable(hcx, hasher);
775 ty::InstanceDef::Virtual(def_id, n) => {
776 def_id.hash_stable(hcx, hasher);
777 n.hash_stable(hcx, hasher);
779 ty::InstanceDef::ClosureOnceShim { call_once } => {
780 call_once.hash_stable(hcx, hasher);
782 ty::InstanceDef::DropGlue(def_id, t) => {
783 def_id.hash_stable(hcx, hasher);
784 t.hash_stable(hcx, hasher);
786 ty::InstanceDef::CloneShim(def_id, t) => {
787 def_id.hash_stable(hcx, hasher);
788 t.hash_stable(hcx, hasher);
794 impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::TraitDef {
795 fn hash_stable<W: StableHasherResult>(&self,
796 hcx: &mut StableHashingContext<'gcx>,
797 hasher: &mut StableHasher<W>) {
799 // We already have the def_path_hash below, no need to hash it twice
807 unsafety.hash_stable(hcx, hasher);
808 paren_sugar.hash_stable(hcx, hasher);
809 has_auto_impl.hash_stable(hcx, hasher);
810 def_path_hash.hash_stable(hcx, hasher);
814 impl_stable_hash_for!(struct ty::Destructor {
818 impl_stable_hash_for!(struct ty::DtorckConstraint<'tcx> {
824 impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::CrateVariancesMap {
825 fn hash_stable<W: StableHasherResult>(&self,
826 hcx: &mut StableHashingContext<'gcx>,
827 hasher: &mut StableHasher<W>) {
828 let ty::CrateVariancesMap {
830 // This is just an irrelevant helper value.
834 variances.hash_stable(hcx, hasher);
838 impl_stable_hash_for!(struct ty::AssociatedItem {
845 method_has_self_argument
848 impl_stable_hash_for!(enum ty::AssociatedKind {
854 impl_stable_hash_for!(enum ty::AssociatedItemContainer {
855 TraitContainer(def_id),
856 ImplContainer(def_id)
860 impl<'gcx, T> HashStable<StableHashingContext<'gcx>>
861 for ty::steal::Steal<T>
862 where T: HashStable<StableHashingContext<'gcx>>
864 fn hash_stable<W: StableHasherResult>(&self,
865 hcx: &mut StableHashingContext<'gcx>,
866 hasher: &mut StableHasher<W>) {
867 self.borrow().hash_stable(hcx, hasher);
871 impl_stable_hash_for!(struct ty::ParamEnv<'tcx> {
877 impl_stable_hash_for!(enum traits::Reveal {
882 impl_stable_hash_for!(enum ::middle::privacy::AccessLevel {
888 impl<'gcx> HashStable<StableHashingContext<'gcx>>
889 for ::middle::privacy::AccessLevels {
890 fn hash_stable<W: StableHasherResult>(&self,
891 hcx: &mut StableHashingContext<'gcx>,
892 hasher: &mut StableHasher<W>) {
893 hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
894 let ::middle::privacy::AccessLevels {
898 map.hash_stable(hcx, hasher);
903 impl_stable_hash_for!(struct ty::CrateInherentImpls {
907 impl_stable_hash_for!(enum ::session::CompileIncomplete {
909 Errored(error_reported)
912 impl_stable_hash_for!(struct ::util::common::ErrorReported {});
914 impl_stable_hash_for!(tuple_struct ::middle::reachable::ReachableSet {
918 impl<'gcx, N> HashStable<StableHashingContext<'gcx>>
919 for traits::Vtable<'gcx, N> where N: HashStable<StableHashingContext<'gcx>> {
920 fn hash_stable<W: StableHasherResult>(&self,
921 hcx: &mut StableHashingContext<'gcx>,
922 hasher: &mut StableHasher<W>) {
923 use traits::Vtable::*;
925 mem::discriminant(self).hash_stable(hcx, hasher);
928 &VtableImpl(ref table_impl) => table_impl.hash_stable(hcx, hasher),
929 &VtableAutoImpl(ref table_def_impl) => table_def_impl.hash_stable(hcx, hasher),
930 &VtableParam(ref table_param) => table_param.hash_stable(hcx, hasher),
931 &VtableObject(ref table_obj) => table_obj.hash_stable(hcx, hasher),
932 &VtableBuiltin(ref table_builtin) => table_builtin.hash_stable(hcx, hasher),
933 &VtableClosure(ref table_closure) => table_closure.hash_stable(hcx, hasher),
934 &VtableFnPointer(ref table_fn_pointer) => table_fn_pointer.hash_stable(hcx, hasher),
935 &VtableGenerator(ref table_generator) => table_generator.hash_stable(hcx, hasher),
940 impl<'gcx, N> HashStable<StableHashingContext<'gcx>>
941 for traits::VtableImplData<'gcx, N> where N: HashStable<StableHashingContext<'gcx>> {
942 fn hash_stable<W: StableHasherResult>(&self,
943 hcx: &mut StableHashingContext<'gcx>,
944 hasher: &mut StableHasher<W>) {
945 let traits::VtableImplData {
950 impl_def_id.hash_stable(hcx, hasher);
951 substs.hash_stable(hcx, hasher);
952 nested.hash_stable(hcx, hasher);
956 impl<'gcx, N> HashStable<StableHashingContext<'gcx>>
957 for traits::VtableAutoImplData<N> where N: HashStable<StableHashingContext<'gcx>> {
958 fn hash_stable<W: StableHasherResult>(&self,
959 hcx: &mut StableHashingContext<'gcx>,
960 hasher: &mut StableHasher<W>) {
961 let traits::VtableAutoImplData {
965 trait_def_id.hash_stable(hcx, hasher);
966 nested.hash_stable(hcx, hasher);
970 impl<'gcx, N> HashStable<StableHashingContext<'gcx>>
971 for traits::VtableObjectData<'gcx, N> where N: HashStable<StableHashingContext<'gcx>> {
972 fn hash_stable<W: StableHasherResult>(&self,
973 hcx: &mut StableHashingContext<'gcx>,
974 hasher: &mut StableHasher<W>) {
975 let traits::VtableObjectData {
980 upcast_trait_ref.hash_stable(hcx, hasher);
981 vtable_base.hash_stable(hcx, hasher);
982 nested.hash_stable(hcx, hasher);
986 impl<'gcx, N> HashStable<StableHashingContext<'gcx>>
987 for traits::VtableBuiltinData<N> where N: HashStable<StableHashingContext<'gcx>> {
988 fn hash_stable<W: StableHasherResult>(&self,
989 hcx: &mut StableHashingContext<'gcx>,
990 hasher: &mut StableHasher<W>) {
991 let traits::VtableBuiltinData {
994 nested.hash_stable(hcx, hasher);
998 impl<'gcx, N> HashStable<StableHashingContext<'gcx>>
999 for traits::VtableClosureData<'gcx, N> where N: HashStable<StableHashingContext<'gcx>> {
1000 fn hash_stable<W: StableHasherResult>(&self,
1001 hcx: &mut StableHashingContext<'gcx>,
1002 hasher: &mut StableHasher<W>) {
1003 let traits::VtableClosureData {
1008 closure_def_id.hash_stable(hcx, hasher);
1009 substs.hash_stable(hcx, hasher);
1010 nested.hash_stable(hcx, hasher);
1014 impl<'gcx, N> HashStable<StableHashingContext<'gcx>>
1015 for traits::VtableFnPointerData<'gcx, N> where N: HashStable<StableHashingContext<'gcx>> {
1016 fn hash_stable<W: StableHasherResult>(&self,
1017 hcx: &mut StableHashingContext<'gcx>,
1018 hasher: &mut StableHasher<W>) {
1019 let traits::VtableFnPointerData {
1023 fn_ty.hash_stable(hcx, hasher);
1024 nested.hash_stable(hcx, hasher);
1028 impl<'gcx, N> HashStable<StableHashingContext<'gcx>>
1029 for traits::VtableGeneratorData<'gcx, N> where N: HashStable<StableHashingContext<'gcx>> {
1030 fn hash_stable<W: StableHasherResult>(&self,
1031 hcx: &mut StableHashingContext<'gcx>,
1032 hasher: &mut StableHasher<W>) {
1033 let traits::VtableGeneratorData {
1038 closure_def_id.hash_stable(hcx, hasher);
1039 substs.hash_stable(hcx, hasher);
1040 nested.hash_stable(hcx, hasher);
1044 impl<'gcx> HashStable<StableHashingContext<'gcx>>
1045 for ty::UniverseIndex {
1046 fn hash_stable<W: StableHasherResult>(&self,
1047 hcx: &mut StableHashingContext<'gcx>,
1048 hasher: &mut StableHasher<W>) {
1049 self.depth().hash_stable(hcx, hasher);