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!(struct ty::SubtypePredicate<'tcx> { a_is_expected, a, b });
249 impl<'gcx, A, B> HashStable<StableHashingContext<'gcx>>
250 for ty::OutlivesPredicate<A, B>
251 where A: HashStable<StableHashingContext<'gcx>>,
252 B: HashStable<StableHashingContext<'gcx>>,
254 fn hash_stable<W: StableHasherResult>(&self,
255 hcx: &mut StableHashingContext<'gcx>,
256 hasher: &mut StableHasher<W>) {
257 let ty::OutlivesPredicate(ref a, ref b) = *self;
258 a.hash_stable(hcx, hasher);
259 b.hash_stable(hcx, hasher);
263 impl_stable_hash_for!(struct ty::ProjectionPredicate<'tcx> { projection_ty, ty });
264 impl_stable_hash_for!(struct ty::ProjectionTy<'tcx> { substs, item_def_id });
267 impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::Predicate<'gcx> {
268 fn hash_stable<W: StableHasherResult>(&self,
269 hcx: &mut StableHashingContext<'gcx>,
270 hasher: &mut StableHasher<W>) {
271 mem::discriminant(self).hash_stable(hcx, hasher);
273 ty::Predicate::Trait(ref pred) => {
274 pred.hash_stable(hcx, hasher);
276 ty::Predicate::Subtype(ref pred) => {
277 pred.hash_stable(hcx, hasher);
279 ty::Predicate::RegionOutlives(ref pred) => {
280 pred.hash_stable(hcx, hasher);
282 ty::Predicate::TypeOutlives(ref pred) => {
283 pred.hash_stable(hcx, hasher);
285 ty::Predicate::Projection(ref pred) => {
286 pred.hash_stable(hcx, hasher);
288 ty::Predicate::WellFormed(ty) => {
289 ty.hash_stable(hcx, hasher);
291 ty::Predicate::ObjectSafe(def_id) => {
292 def_id.hash_stable(hcx, hasher);
294 ty::Predicate::ClosureKind(def_id, closure_substs, closure_kind) => {
295 def_id.hash_stable(hcx, hasher);
296 closure_substs.hash_stable(hcx, hasher);
297 closure_kind.hash_stable(hcx, hasher);
299 ty::Predicate::ConstEvaluatable(def_id, substs) => {
300 def_id.hash_stable(hcx, hasher);
301 substs.hash_stable(hcx, hasher);
307 impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::AdtFlags {
308 fn hash_stable<W: StableHasherResult>(&self,
309 _: &mut StableHashingContext<'gcx>,
310 hasher: &mut StableHasher<W>) {
311 std_hash::Hash::hash(self, hasher);
315 impl_stable_hash_for!(struct ty::VariantDef {
323 impl_stable_hash_for!(enum ty::VariantDiscr {
328 impl_stable_hash_for!(struct ty::FieldDef {
334 impl<'gcx> HashStable<StableHashingContext<'gcx>>
335 for ::middle::const_val::ConstVal<'gcx> {
336 fn hash_stable<W: StableHasherResult>(&self,
337 hcx: &mut StableHashingContext<'gcx>,
338 hasher: &mut StableHasher<W>) {
339 use middle::const_val::ConstVal::*;
340 use middle::const_val::ConstAggregate::*;
342 mem::discriminant(self).hash_stable(hcx, hasher);
345 Integral(ref value) => {
346 value.hash_stable(hcx, hasher);
348 Float(ref value) => {
349 value.hash_stable(hcx, hasher);
352 value.hash_stable(hcx, hasher);
354 ByteStr(ref value) => {
355 value.hash_stable(hcx, hasher);
358 value.hash_stable(hcx, hasher);
361 value.hash_stable(hcx, hasher);
364 def_id.hash_stable(hcx, hasher);
366 Function(def_id, substs) => {
367 def_id.hash_stable(hcx, hasher);
368 hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
369 substs.hash_stable(hcx, hasher);
372 Aggregate(Struct(ref name_values)) => {
373 let mut values = name_values.to_vec();
374 values.sort_unstable_by_key(|&(ref name, _)| name.clone());
375 values.hash_stable(hcx, hasher);
377 Aggregate(Tuple(ref value)) => {
378 value.hash_stable(hcx, hasher);
380 Aggregate(Array(ref value)) => {
381 value.hash_stable(hcx, hasher);
383 Aggregate(Repeat(ref value, times)) => {
384 value.hash_stable(hcx, hasher);
385 times.hash_stable(hcx, hasher);
387 Unevaluated(def_id, substs) => {
388 def_id.hash_stable(hcx, hasher);
389 substs.hash_stable(hcx, hasher);
395 impl_stable_hash_for!(struct ::middle::const_val::ByteArray<'tcx> {
399 impl_stable_hash_for!(struct ty::Const<'tcx> {
404 impl_stable_hash_for!(struct ::middle::const_val::ConstEvalErr<'tcx> {
409 impl<'gcx> HashStable<StableHashingContext<'gcx>>
410 for ::middle::const_val::ErrKind<'gcx> {
411 fn hash_stable<W: StableHasherResult>(&self,
412 hcx: &mut StableHashingContext<'gcx>,
413 hasher: &mut StableHasher<W>) {
414 use middle::const_val::ErrKind::*;
416 mem::discriminant(self).hash_stable(hcx, hasher);
423 ExpectedConstStruct |
428 IndexOpFeatureGated |
433 UnimplementedConstVal(s) => {
434 s.hash_stable(hcx, hasher);
436 IndexOutOfBounds { len, index } => {
437 len.hash_stable(hcx, hasher);
438 index.hash_stable(hcx, hasher);
440 Math(ref const_math_err) => {
441 const_math_err.hash_stable(hcx, hasher);
443 LayoutError(ref layout_error) => {
444 layout_error.hash_stable(hcx, hasher);
446 ErroneousReferencedConstant(ref const_val) => {
447 const_val.hash_stable(hcx, hasher);
453 impl_stable_hash_for!(struct ty::ClosureSubsts<'tcx> { substs });
455 impl_stable_hash_for!(struct ty::GeneratorInterior<'tcx> { witness, movable });
457 impl_stable_hash_for!(struct ty::GenericPredicates<'tcx> {
462 impl_stable_hash_for!(enum ty::Variance {
469 impl_stable_hash_for!(enum ty::adjustment::CustomCoerceUnsized {
473 impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::Generics {
474 fn hash_stable<W: StableHasherResult>(&self,
475 hcx: &mut StableHashingContext<'gcx>,
476 hasher: &mut StableHasher<W>) {
484 // Reverse map to each `TypeParameterDef`'s `index` field, from
485 // `def_id.index` (`def_id.krate` is the same as the item's).
486 type_param_to_index: _, // Don't hash this
488 has_late_bound_regions,
491 parent.hash_stable(hcx, hasher);
492 parent_regions.hash_stable(hcx, hasher);
493 parent_types.hash_stable(hcx, hasher);
494 regions.hash_stable(hcx, hasher);
495 types.hash_stable(hcx, hasher);
496 has_self.hash_stable(hcx, hasher);
497 has_late_bound_regions.hash_stable(hcx, hasher);
501 impl<'gcx> HashStable<StableHashingContext<'gcx>>
502 for ty::RegionParameterDef {
503 fn hash_stable<W: StableHasherResult>(&self,
504 hcx: &mut StableHashingContext<'gcx>,
505 hasher: &mut StableHasher<W>) {
506 let ty::RegionParameterDef {
513 name.hash_stable(hcx, hasher);
514 def_id.hash_stable(hcx, hasher);
515 index.hash_stable(hcx, hasher);
516 pure_wrt_drop.hash_stable(hcx, hasher);
520 impl_stable_hash_for!(struct ty::TypeParameterDef {
525 object_lifetime_default,
530 impl<'gcx, T> HashStable<StableHashingContext<'gcx>>
531 for ::middle::resolve_lifetime::Set1<T>
532 where T: HashStable<StableHashingContext<'gcx>>
534 fn hash_stable<W: StableHasherResult>(&self,
535 hcx: &mut StableHashingContext<'gcx>,
536 hasher: &mut StableHasher<W>) {
537 use middle::resolve_lifetime::Set1;
539 mem::discriminant(self).hash_stable(hcx, hasher);
545 Set1::One(ref value) => {
546 value.hash_stable(hcx, hasher);
552 impl_stable_hash_for!(enum ::middle::resolve_lifetime::LifetimeDefOrigin {
557 impl_stable_hash_for!(enum ::middle::resolve_lifetime::Region {
559 EarlyBound(index, decl, is_in_band),
560 LateBound(db_index, decl, is_in_band),
561 LateBoundAnon(db_index, anon_index),
562 Free(call_site_scope_data, decl)
565 impl_stable_hash_for!(struct ty::DebruijnIndex {
569 impl_stable_hash_for!(enum ty::cast::CastKind {
583 impl_stable_hash_for!(tuple_struct ::middle::region::FirstStatementIndex { idx });
584 impl_stable_hash_for!(struct ::middle::region::Scope { id, code });
586 impl<'gcx> ToStableHashKey<StableHashingContext<'gcx>> for region::Scope {
587 type KeyType = region::Scope;
590 fn to_stable_hash_key(&self, _: &StableHashingContext<'gcx>) -> region::Scope {
595 impl_stable_hash_for!(struct ::middle::region::BlockRemainder {
597 first_statement_index
600 impl_stable_hash_for!(struct ty::adjustment::CoerceUnsizedInfo {
604 impl_stable_hash_for!(struct ty::FreeRegion {
609 impl_stable_hash_for!(enum ty::BoundRegion {
611 BrNamed(def_id, name),
616 impl<'gcx> HashStable<StableHashingContext<'gcx>>
617 for ty::TypeVariants<'gcx>
619 fn hash_stable<W: StableHasherResult>(&self,
620 hcx: &mut StableHashingContext<'gcx>,
621 hasher: &mut StableHasher<W>) {
622 use ty::TypeVariants::*;
624 mem::discriminant(self).hash_stable(hcx, hasher);
631 // Nothing more to hash.
634 int_ty.hash_stable(hcx, hasher);
637 uint_ty.hash_stable(hcx, hasher);
639 TyFloat(float_ty) => {
640 float_ty.hash_stable(hcx, hasher);
642 TyAdt(adt_def, substs) => {
643 adt_def.hash_stable(hcx, hasher);
644 substs.hash_stable(hcx, hasher);
646 TyArray(inner_ty, len) => {
647 inner_ty.hash_stable(hcx, hasher);
648 len.hash_stable(hcx, hasher);
650 TySlice(inner_ty) => {
651 inner_ty.hash_stable(hcx, hasher);
653 TyRawPtr(pointee_ty) => {
654 pointee_ty.hash_stable(hcx, hasher);
656 TyRef(region, pointee_ty) => {
657 region.hash_stable(hcx, hasher);
658 pointee_ty.hash_stable(hcx, hasher);
660 TyFnDef(def_id, substs) => {
661 def_id.hash_stable(hcx, hasher);
662 substs.hash_stable(hcx, hasher);
664 TyFnPtr(ref sig) => {
665 sig.hash_stable(hcx, hasher);
667 TyDynamic(ref existential_predicates, region) => {
668 existential_predicates.hash_stable(hcx, hasher);
669 region.hash_stable(hcx, hasher);
671 TyClosure(def_id, closure_substs) => {
672 def_id.hash_stable(hcx, hasher);
673 closure_substs.hash_stable(hcx, hasher);
675 TyGenerator(def_id, closure_substs, interior) => {
676 def_id.hash_stable(hcx, hasher);
677 closure_substs.hash_stable(hcx, hasher);
678 interior.hash_stable(hcx, hasher);
680 TyGeneratorWitness(types) => {
681 types.hash_stable(hcx, hasher)
683 TyTuple(inner_tys, from_diverging_type_var) => {
684 inner_tys.hash_stable(hcx, hasher);
685 from_diverging_type_var.hash_stable(hcx, hasher);
687 TyProjection(ref projection_ty) => {
688 projection_ty.hash_stable(hcx, hasher);
690 TyAnon(def_id, substs) => {
691 def_id.hash_stable(hcx, hasher);
692 substs.hash_stable(hcx, hasher);
694 TyParam(param_ty) => {
695 param_ty.hash_stable(hcx, hasher);
697 TyForeign(def_id) => {
698 def_id.hash_stable(hcx, hasher);
701 bug!("ty::TypeVariants::hash_stable() - Unexpected variant {:?}.", *self)
707 impl_stable_hash_for!(struct ty::ParamTy {
712 impl_stable_hash_for!(struct ty::TypeAndMut<'tcx> {
717 impl<'gcx> HashStable<StableHashingContext<'gcx>>
718 for ty::ExistentialPredicate<'gcx>
720 fn hash_stable<W: StableHasherResult>(&self,
721 hcx: &mut StableHashingContext<'gcx>,
722 hasher: &mut StableHasher<W>) {
723 mem::discriminant(self).hash_stable(hcx, hasher);
725 ty::ExistentialPredicate::Trait(ref trait_ref) => {
726 trait_ref.hash_stable(hcx, hasher);
728 ty::ExistentialPredicate::Projection(ref projection) => {
729 projection.hash_stable(hcx, hasher);
731 ty::ExistentialPredicate::AutoTrait(def_id) => {
732 def_id.hash_stable(hcx, hasher);
738 impl_stable_hash_for!(struct ty::ExistentialTraitRef<'tcx> {
743 impl_stable_hash_for!(struct ty::ExistentialProjection<'tcx> {
749 impl_stable_hash_for!(struct ty::Instance<'tcx> {
754 impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::InstanceDef<'gcx> {
755 fn hash_stable<W: StableHasherResult>(&self,
756 hcx: &mut StableHashingContext<'gcx>,
757 hasher: &mut StableHasher<W>) {
758 mem::discriminant(self).hash_stable(hcx, hasher);
761 ty::InstanceDef::Item(def_id) => {
762 def_id.hash_stable(hcx, hasher);
764 ty::InstanceDef::Intrinsic(def_id) => {
765 def_id.hash_stable(hcx, hasher);
767 ty::InstanceDef::FnPtrShim(def_id, ty) => {
768 def_id.hash_stable(hcx, hasher);
769 ty.hash_stable(hcx, hasher);
771 ty::InstanceDef::Virtual(def_id, n) => {
772 def_id.hash_stable(hcx, hasher);
773 n.hash_stable(hcx, hasher);
775 ty::InstanceDef::ClosureOnceShim { call_once } => {
776 call_once.hash_stable(hcx, hasher);
778 ty::InstanceDef::DropGlue(def_id, t) => {
779 def_id.hash_stable(hcx, hasher);
780 t.hash_stable(hcx, hasher);
782 ty::InstanceDef::CloneShim(def_id, t) => {
783 def_id.hash_stable(hcx, hasher);
784 t.hash_stable(hcx, hasher);
790 impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::TraitDef {
791 fn hash_stable<W: StableHasherResult>(&self,
792 hcx: &mut StableHashingContext<'gcx>,
793 hasher: &mut StableHasher<W>) {
795 // We already have the def_path_hash below, no need to hash it twice
803 unsafety.hash_stable(hcx, hasher);
804 paren_sugar.hash_stable(hcx, hasher);
805 has_auto_impl.hash_stable(hcx, hasher);
806 def_path_hash.hash_stable(hcx, hasher);
810 impl_stable_hash_for!(struct ty::Destructor {
814 impl_stable_hash_for!(struct ty::DtorckConstraint<'tcx> {
820 impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::CrateVariancesMap {
821 fn hash_stable<W: StableHasherResult>(&self,
822 hcx: &mut StableHashingContext<'gcx>,
823 hasher: &mut StableHasher<W>) {
824 let ty::CrateVariancesMap {
826 // This is just an irrelevant helper value.
830 variances.hash_stable(hcx, hasher);
834 impl_stable_hash_for!(struct ty::AssociatedItem {
841 method_has_self_argument
844 impl_stable_hash_for!(enum ty::AssociatedKind {
850 impl_stable_hash_for!(enum ty::AssociatedItemContainer {
851 TraitContainer(def_id),
852 ImplContainer(def_id)
856 impl<'gcx, T> HashStable<StableHashingContext<'gcx>>
857 for ty::steal::Steal<T>
858 where T: HashStable<StableHashingContext<'gcx>>
860 fn hash_stable<W: StableHasherResult>(&self,
861 hcx: &mut StableHashingContext<'gcx>,
862 hasher: &mut StableHasher<W>) {
863 self.borrow().hash_stable(hcx, hasher);
867 impl_stable_hash_for!(struct ty::ParamEnv<'tcx> {
873 impl_stable_hash_for!(enum traits::Reveal {
878 impl_stable_hash_for!(enum ::middle::privacy::AccessLevel {
884 impl<'gcx> HashStable<StableHashingContext<'gcx>>
885 for ::middle::privacy::AccessLevels {
886 fn hash_stable<W: StableHasherResult>(&self,
887 hcx: &mut StableHashingContext<'gcx>,
888 hasher: &mut StableHasher<W>) {
889 hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
890 let ::middle::privacy::AccessLevels {
894 map.hash_stable(hcx, hasher);
899 impl_stable_hash_for!(struct ty::CrateInherentImpls {
903 impl_stable_hash_for!(enum ::session::CompileIncomplete {
905 Errored(error_reported)
908 impl_stable_hash_for!(struct ::util::common::ErrorReported {});
910 impl_stable_hash_for!(tuple_struct ::middle::reachable::ReachableSet {
914 impl<'gcx, N> HashStable<StableHashingContext<'gcx>>
915 for traits::Vtable<'gcx, N> where N: HashStable<StableHashingContext<'gcx>> {
916 fn hash_stable<W: StableHasherResult>(&self,
917 hcx: &mut StableHashingContext<'gcx>,
918 hasher: &mut StableHasher<W>) {
919 use traits::Vtable::*;
921 mem::discriminant(self).hash_stable(hcx, hasher);
924 &VtableImpl(ref table_impl) => table_impl.hash_stable(hcx, hasher),
925 &VtableAutoImpl(ref table_def_impl) => table_def_impl.hash_stable(hcx, hasher),
926 &VtableParam(ref table_param) => table_param.hash_stable(hcx, hasher),
927 &VtableObject(ref table_obj) => table_obj.hash_stable(hcx, hasher),
928 &VtableBuiltin(ref table_builtin) => table_builtin.hash_stable(hcx, hasher),
929 &VtableClosure(ref table_closure) => table_closure.hash_stable(hcx, hasher),
930 &VtableFnPointer(ref table_fn_pointer) => table_fn_pointer.hash_stable(hcx, hasher),
931 &VtableGenerator(ref table_generator) => table_generator.hash_stable(hcx, hasher),
936 impl<'gcx, N> HashStable<StableHashingContext<'gcx>>
937 for traits::VtableImplData<'gcx, N> where N: HashStable<StableHashingContext<'gcx>> {
938 fn hash_stable<W: StableHasherResult>(&self,
939 hcx: &mut StableHashingContext<'gcx>,
940 hasher: &mut StableHasher<W>) {
941 let traits::VtableImplData {
946 impl_def_id.hash_stable(hcx, hasher);
947 substs.hash_stable(hcx, hasher);
948 nested.hash_stable(hcx, hasher);
952 impl<'gcx, N> HashStable<StableHashingContext<'gcx>>
953 for traits::VtableAutoImplData<N> where N: HashStable<StableHashingContext<'gcx>> {
954 fn hash_stable<W: StableHasherResult>(&self,
955 hcx: &mut StableHashingContext<'gcx>,
956 hasher: &mut StableHasher<W>) {
957 let traits::VtableAutoImplData {
961 trait_def_id.hash_stable(hcx, hasher);
962 nested.hash_stable(hcx, hasher);
966 impl<'gcx, N> HashStable<StableHashingContext<'gcx>>
967 for traits::VtableObjectData<'gcx, N> where N: HashStable<StableHashingContext<'gcx>> {
968 fn hash_stable<W: StableHasherResult>(&self,
969 hcx: &mut StableHashingContext<'gcx>,
970 hasher: &mut StableHasher<W>) {
971 let traits::VtableObjectData {
976 upcast_trait_ref.hash_stable(hcx, hasher);
977 vtable_base.hash_stable(hcx, hasher);
978 nested.hash_stable(hcx, hasher);
982 impl<'gcx, N> HashStable<StableHashingContext<'gcx>>
983 for traits::VtableBuiltinData<N> where N: HashStable<StableHashingContext<'gcx>> {
984 fn hash_stable<W: StableHasherResult>(&self,
985 hcx: &mut StableHashingContext<'gcx>,
986 hasher: &mut StableHasher<W>) {
987 let traits::VtableBuiltinData {
990 nested.hash_stable(hcx, hasher);
994 impl<'gcx, N> HashStable<StableHashingContext<'gcx>>
995 for traits::VtableClosureData<'gcx, N> where N: HashStable<StableHashingContext<'gcx>> {
996 fn hash_stable<W: StableHasherResult>(&self,
997 hcx: &mut StableHashingContext<'gcx>,
998 hasher: &mut StableHasher<W>) {
999 let traits::VtableClosureData {
1004 closure_def_id.hash_stable(hcx, hasher);
1005 substs.hash_stable(hcx, hasher);
1006 nested.hash_stable(hcx, hasher);
1010 impl<'gcx, N> HashStable<StableHashingContext<'gcx>>
1011 for traits::VtableFnPointerData<'gcx, N> where N: HashStable<StableHashingContext<'gcx>> {
1012 fn hash_stable<W: StableHasherResult>(&self,
1013 hcx: &mut StableHashingContext<'gcx>,
1014 hasher: &mut StableHasher<W>) {
1015 let traits::VtableFnPointerData {
1019 fn_ty.hash_stable(hcx, hasher);
1020 nested.hash_stable(hcx, hasher);
1024 impl<'gcx, N> HashStable<StableHashingContext<'gcx>>
1025 for traits::VtableGeneratorData<'gcx, N> where N: HashStable<StableHashingContext<'gcx>> {
1026 fn hash_stable<W: StableHasherResult>(&self,
1027 hcx: &mut StableHashingContext<'gcx>,
1028 hasher: &mut StableHasher<W>) {
1029 let traits::VtableGeneratorData {
1034 closure_def_id.hash_stable(hcx, hasher);
1035 substs.hash_stable(hcx, hasher);
1036 nested.hash_stable(hcx, hasher);
1040 impl<'gcx> HashStable<StableHashingContext<'gcx>>
1041 for ty::UniverseIndex {
1042 fn hash_stable<W: StableHasherResult>(&self,
1043 hcx: &mut StableHashingContext<'gcx>,
1044 hasher: &mut StableHasher<W>) {
1045 self.depth().hash_stable(hcx, hasher);