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;
27 impl<'a, 'gcx, T> HashStable<StableHashingContext<'a>>
29 where T: HashStable<StableHashingContext<'a>> {
30 fn hash_stable<W: StableHasherResult>(&self,
31 hcx: &mut StableHashingContext<'a>,
32 hasher: &mut StableHasher<W>) {
34 static CACHE: RefCell<FxHashMap<(usize, usize), Fingerprint>> =
35 RefCell::new(Default::default());
38 let hash = CACHE.with(|cache| {
39 let key = (self.as_ptr() as usize, self.len());
40 if let Some(&hash) = cache.borrow().get(&key) {
44 let mut hasher = StableHasher::new();
45 (&self[..]).hash_stable(hcx, &mut hasher);
47 let hash: Fingerprint = hasher.finish();
48 cache.borrow_mut().insert(key, hash);
52 hash.hash_stable(hcx, hasher);
56 impl<'a, 'gcx, T> ToStableHashKey<StableHashingContext<'a>> for &'gcx ty::List<T>
57 where T: HashStable<StableHashingContext<'a>>
59 type KeyType = Fingerprint;
62 fn to_stable_hash_key(&self, hcx: &StableHashingContext<'a>) -> Fingerprint {
63 let mut hasher = StableHasher::new();
64 let mut hcx: StableHashingContext<'a> = hcx.clone();
65 self.hash_stable(&mut hcx, &mut hasher);
70 impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for ty::subst::Kind<'gcx> {
71 fn hash_stable<W: StableHasherResult>(&self,
72 hcx: &mut StableHashingContext<'a>,
73 hasher: &mut StableHasher<W>) {
74 self.unpack().hash_stable(hcx, hasher);
78 impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
79 for ty::subst::UnpackedKind<'gcx> {
80 fn hash_stable<W: StableHasherResult>(&self,
81 hcx: &mut StableHashingContext<'a>,
82 hasher: &mut StableHasher<W>) {
83 mem::discriminant(self).hash_stable(hcx, hasher);
85 ty::subst::UnpackedKind::Lifetime(lt) => lt.hash_stable(hcx, hasher),
86 ty::subst::UnpackedKind::Type(ty) => ty.hash_stable(hcx, hasher),
91 impl<'a> HashStable<StableHashingContext<'a>>
93 fn hash_stable<W: StableHasherResult>(&self,
94 hcx: &mut StableHashingContext<'a>,
95 hasher: &mut StableHasher<W>) {
96 mem::discriminant(self).hash_stable(hcx, hasher);
101 // No variant fields to hash for these ...
103 ty::ReLateBound(db, ty::BrAnon(i)) => {
104 db.hash_stable(hcx, hasher);
105 i.hash_stable(hcx, hasher);
107 ty::ReLateBound(db, ty::BrNamed(def_id, name)) => {
108 db.hash_stable(hcx, hasher);
109 def_id.hash_stable(hcx, hasher);
110 name.hash_stable(hcx, hasher);
112 ty::ReLateBound(db, ty::BrEnv) => {
113 db.hash_stable(hcx, hasher);
115 ty::ReEarlyBound(ty::EarlyBoundRegion { def_id, index, name }) => {
116 def_id.hash_stable(hcx, hasher);
117 index.hash_stable(hcx, hasher);
118 name.hash_stable(hcx, hasher);
120 ty::ReScope(scope) => {
121 scope.hash_stable(hcx, hasher);
123 ty::ReFree(ref free_region) => {
124 free_region.hash_stable(hcx, hasher);
126 ty::ReClosureBound(vid) => {
127 vid.hash_stable(hcx, hasher);
129 ty::ReLateBound(..) |
131 ty::RePlaceholder(..) => {
132 bug!("StableHasher: unexpected region {:?}", *self)
138 impl<'a> HashStable<StableHashingContext<'a>> for ty::RegionVid {
140 fn hash_stable<W: StableHasherResult>(&self,
141 hcx: &mut StableHashingContext<'a>,
142 hasher: &mut StableHasher<W>) {
143 self.index().hash_stable(hcx, hasher);
147 impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::BoundVar {
149 fn hash_stable<W: StableHasherResult>(&self,
150 hcx: &mut StableHashingContext<'gcx>,
151 hasher: &mut StableHasher<W>) {
152 self.index().hash_stable(hcx, hasher);
156 impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
157 for ty::adjustment::AutoBorrow<'gcx> {
158 fn hash_stable<W: StableHasherResult>(&self,
159 hcx: &mut StableHashingContext<'a>,
160 hasher: &mut StableHasher<W>) {
161 mem::discriminant(self).hash_stable(hcx, hasher);
163 ty::adjustment::AutoBorrow::Ref(ref region, mutability) => {
164 region.hash_stable(hcx, hasher);
165 mutability.hash_stable(hcx, hasher);
167 ty::adjustment::AutoBorrow::RawPtr(mutability) => {
168 mutability.hash_stable(hcx, hasher);
174 impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
175 for ty::adjustment::Adjust<'gcx> {
176 fn hash_stable<W: StableHasherResult>(&self,
177 hcx: &mut StableHashingContext<'a>,
178 hasher: &mut StableHasher<W>) {
179 mem::discriminant(self).hash_stable(hcx, hasher);
181 ty::adjustment::Adjust::NeverToAny |
182 ty::adjustment::Adjust::ReifyFnPointer |
183 ty::adjustment::Adjust::UnsafeFnPointer |
184 ty::adjustment::Adjust::ClosureFnPointer |
185 ty::adjustment::Adjust::MutToConstPointer |
186 ty::adjustment::Adjust::Unsize => {}
187 ty::adjustment::Adjust::Deref(ref overloaded) => {
188 overloaded.hash_stable(hcx, hasher);
190 ty::adjustment::Adjust::Borrow(ref autoref) => {
191 autoref.hash_stable(hcx, hasher);
197 impl_stable_hash_for!(struct ty::adjustment::Adjustment<'tcx> { kind, target });
198 impl_stable_hash_for!(struct ty::adjustment::OverloadedDeref<'tcx> { region, mutbl });
199 impl_stable_hash_for!(struct ty::UpvarBorrow<'tcx> { kind, region });
200 impl_stable_hash_for!(enum ty::adjustment::AllowTwoPhase {
205 impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::adjustment::AutoBorrowMutability {
206 fn hash_stable<W: StableHasherResult>(&self,
207 hcx: &mut StableHashingContext<'gcx>,
208 hasher: &mut StableHasher<W>) {
209 mem::discriminant(self).hash_stable(hcx, hasher);
211 ty::adjustment::AutoBorrowMutability::Mutable { ref allow_two_phase_borrow } => {
212 allow_two_phase_borrow.hash_stable(hcx, hasher);
214 ty::adjustment::AutoBorrowMutability::Immutable => {}
219 impl_stable_hash_for!(struct ty::UpvarPath { hir_id });
221 impl_stable_hash_for!(struct ty::UpvarId { var_path, closure_expr_id });
223 impl_stable_hash_for!(enum ty::BorrowKind {
229 impl_stable_hash_for!(impl<'gcx> for enum ty::UpvarCapture<'gcx> [ ty::UpvarCapture ] {
231 ByRef(up_var_borrow),
234 impl_stable_hash_for!(struct ty::GenSig<'tcx> {
239 impl_stable_hash_for!(struct ty::FnSig<'tcx> {
246 impl<'a, 'gcx, T> HashStable<StableHashingContext<'a>> for ty::Binder<T>
247 where T: HashStable<StableHashingContext<'a>>
249 fn hash_stable<W: StableHasherResult>(&self,
250 hcx: &mut StableHashingContext<'a>,
251 hasher: &mut StableHasher<W>) {
252 self.skip_binder().hash_stable(hcx, hasher);
256 impl_stable_hash_for!(enum ty::ClosureKind { Fn, FnMut, FnOnce });
258 impl_stable_hash_for!(enum ty::Visibility {
264 impl_stable_hash_for!(struct ty::TraitRef<'tcx> { def_id, substs });
265 impl_stable_hash_for!(struct ty::TraitPredicate<'tcx> { trait_ref });
266 impl_stable_hash_for!(struct ty::SubtypePredicate<'tcx> { a_is_expected, a, b });
267 impl_stable_hash_for!(impl<A, B> for tuple_struct ty::OutlivesPredicate<A, B> { a, b });
268 impl_stable_hash_for!(struct ty::ProjectionPredicate<'tcx> { projection_ty, ty });
269 impl_stable_hash_for!(struct ty::ProjectionTy<'tcx> { substs, item_def_id });
271 impl_stable_hash_for!(
272 impl<'tcx> for enum ty::Predicate<'tcx> [ ty::Predicate ] {
275 RegionOutlives(pred),
280 ClosureKind(def_id, closure_substs, closure_kind),
281 ConstEvaluatable(def_id, substs),
285 impl<'a> HashStable<StableHashingContext<'a>> for ty::AdtFlags {
286 fn hash_stable<W: StableHasherResult>(&self,
287 _: &mut StableHashingContext<'a>,
288 hasher: &mut StableHasher<W>) {
289 std_hash::Hash::hash(self, hasher);
293 impl<'a> HashStable<StableHashingContext<'a>> for ty::VariantFlags {
294 fn hash_stable<W: StableHasherResult>(&self,
295 _: &mut StableHashingContext<'a>,
296 hasher: &mut StableHasher<W>) {
297 std_hash::Hash::hash(self, hasher);
301 impl_stable_hash_for!(enum ty::VariantDiscr {
306 impl_stable_hash_for!(struct ty::FieldDef {
308 ident -> (ident.name),
312 impl_stable_hash_for!(
313 impl<'tcx> for enum mir::interpret::ConstValue<'tcx> [ mir::interpret::ConstValue ] {
314 Unevaluated(def_id, substs),
317 ByRef(id, alloc, offset),
320 impl_stable_hash_for!(struct ::mir::interpret::RawConst<'tcx> {
325 impl_stable_hash_for! {
326 impl<Tag> for struct mir::interpret::Pointer<Tag> {
333 impl_stable_hash_for!(
334 impl<Tag> for enum mir::interpret::Scalar<Tag> [ mir::interpret::Scalar ] {
340 impl_stable_hash_for!(
341 impl<'tcx, M> for enum mir::interpret::AllocType<'tcx, M> [ mir::interpret::AllocType ] {
348 // AllocIds get resolved to whatever they point to (to be stable)
349 impl<'a> HashStable<StableHashingContext<'a>> for mir::interpret::AllocId {
350 fn hash_stable<W: StableHasherResult>(
352 hcx: &mut StableHashingContext<'a>,
353 hasher: &mut StableHasher<W>,
355 ty::tls::with_opt(|tcx| {
356 trace!("hashing {:?}", *self);
357 let tcx = tcx.expect("can't hash AllocIds during hir lowering");
358 let alloc_kind = tcx.alloc_map.lock().get(*self);
359 alloc_kind.hash_stable(hcx, hasher);
364 // Allocations treat their relocations specially
365 impl<'a> HashStable<StableHashingContext<'a>> for mir::interpret::Allocation {
366 fn hash_stable<W: StableHasherResult>(
368 hcx: &mut StableHashingContext<'a>,
369 hasher: &mut StableHasher<W>,
371 self.bytes.hash_stable(hcx, hasher);
372 for reloc in self.relocations.iter() {
373 reloc.hash_stable(hcx, hasher);
375 self.undef_mask.hash_stable(hcx, hasher);
376 self.align.hash_stable(hcx, hasher);
377 self.mutability.hash_stable(hcx, hasher);
381 impl_stable_hash_for!(enum ::syntax::ast::Mutability {
386 impl_stable_hash_for!(struct ty::Const<'tcx> {
391 impl_stable_hash_for!(enum mir::interpret::ErrorHandled {
396 impl_stable_hash_for!(struct mir::interpret::FrameInfo<'tcx> {
402 impl_stable_hash_for!(struct ty::ClosureSubsts<'tcx> { substs });
403 impl_stable_hash_for!(struct ty::GeneratorSubsts<'tcx> { substs });
405 impl_stable_hash_for!(struct ty::GenericPredicates<'tcx> {
410 impl_stable_hash_for!(
411 impl<'tcx, O> for enum mir::interpret::EvalErrorKind<'tcx, O>
412 [ mir::interpret::EvalErrorKind ]
414 FunctionArgCountMismatch,
415 DanglingPointerDeref,
418 InvalidFunctionPointer,
420 InvalidNullPointerUsage,
426 StackFrameLimitReached,
429 CalledClosureAsFunction,
430 VtableForArgumentlessMethod,
431 ModifiedConstantMemory,
435 ReallocateNonBasePtr,
436 DeallocateNonBasePtr,
439 ReadFromReturnPointer,
440 UnimplementedTraitSelection,
443 DerefFunctionPointer,
448 GeneratorResumedAfterReturn,
449 GeneratorResumedAfterPanic,
452 ReadUndefBytes(offset),
453 InvalidDiscriminant(val),
454 Panic { msg, file, line, col },
456 FunctionAbiMismatch(a, b),
457 FunctionArgMismatch(a, b),
458 FunctionRetMismatch(a, b),
460 UnterminatedCString(ptr),
461 PointerOutOfBounds { ptr, check, allocation_size },
464 BoundsCheck { len, index },
468 AlignmentCheckFailed { required, has },
469 ValidationFailure(s),
470 TypeNotPrimitive(ty),
471 ReallocatedWrongMemoryKind(a, b),
472 DeallocatedWrongMemoryKind(a, b),
473 IncorrectAllocationInformation(a, b, c, d),
475 HeapAllocNonPowerOfTwoAlignment(n),
481 impl_stable_hash_for!(enum mir::interpret::InboundsCheck {
486 impl_stable_hash_for!(enum mir::interpret::Lock {
492 impl_stable_hash_for!(struct mir::interpret::DynamicLifetime {
497 impl_stable_hash_for!(enum mir::interpret::AccessKind {
502 impl_stable_hash_for!(enum ty::Variance {
509 impl_stable_hash_for!(enum ty::adjustment::CustomCoerceUnsized {
513 impl_stable_hash_for!(struct ty::Generics {
517 // Reverse map to each param's `index` field, from its `def_id`.
518 param_def_id_to_index -> _, // Don't hash this
520 has_late_bound_regions,
523 impl_stable_hash_for!(struct ty::GenericParamDef {
531 impl_stable_hash_for!(enum ty::GenericParamDefKind {
533 Type { has_default, object_lifetime_default, synthetic },
536 impl_stable_hash_for!(
537 impl<T> for enum ::middle::resolve_lifetime::Set1<T> [ ::middle::resolve_lifetime::Set1 ] {
544 impl_stable_hash_for!(enum ::middle::resolve_lifetime::LifetimeDefOrigin {
550 impl_stable_hash_for!(enum ::middle::resolve_lifetime::Region {
552 EarlyBound(index, decl, is_in_band),
553 LateBound(db_index, decl, is_in_band),
554 LateBoundAnon(db_index, anon_index),
555 Free(call_site_scope_data, decl)
558 impl_stable_hash_for!(enum ty::cast::CastKind {
572 impl_stable_hash_for!(struct ::middle::region::Scope { id, data });
574 impl_stable_hash_for!(enum ::middle::region::ScopeData {
579 Remainder(first_statement_index)
582 impl<'a> ToStableHashKey<StableHashingContext<'a>> for region::Scope {
583 type KeyType = region::Scope;
586 fn to_stable_hash_key(&self, _: &StableHashingContext<'a>) -> region::Scope {
591 impl_stable_hash_for!(struct ty::adjustment::CoerceUnsizedInfo {
595 impl_stable_hash_for!(struct ty::FreeRegion {
600 impl_stable_hash_for!(enum ty::BoundRegion {
602 BrNamed(def_id, name),
607 impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
610 fn hash_stable<W: StableHasherResult>(&self,
611 hcx: &mut StableHashingContext<'a>,
612 hasher: &mut StableHasher<W>) {
615 mem::discriminant(self).hash_stable(hcx, hasher);
622 // Nothing more to hash.
625 int_ty.hash_stable(hcx, hasher);
628 uint_ty.hash_stable(hcx, hasher);
631 float_ty.hash_stable(hcx, hasher);
633 Adt(adt_def, substs) => {
634 adt_def.hash_stable(hcx, hasher);
635 substs.hash_stable(hcx, hasher);
637 Array(inner_ty, len) => {
638 inner_ty.hash_stable(hcx, hasher);
639 len.hash_stable(hcx, hasher);
642 inner_ty.hash_stable(hcx, hasher);
644 RawPtr(pointee_ty) => {
645 pointee_ty.hash_stable(hcx, hasher);
647 Ref(region, pointee_ty, mutbl) => {
648 region.hash_stable(hcx, hasher);
649 pointee_ty.hash_stable(hcx, hasher);
650 mutbl.hash_stable(hcx, hasher);
652 FnDef(def_id, substs) => {
653 def_id.hash_stable(hcx, hasher);
654 substs.hash_stable(hcx, hasher);
657 sig.hash_stable(hcx, hasher);
659 Dynamic(ref existential_predicates, region) => {
660 existential_predicates.hash_stable(hcx, hasher);
661 region.hash_stable(hcx, hasher);
663 Closure(def_id, closure_substs) => {
664 def_id.hash_stable(hcx, hasher);
665 closure_substs.hash_stable(hcx, hasher);
667 Generator(def_id, generator_substs, movability) => {
668 def_id.hash_stable(hcx, hasher);
669 generator_substs.hash_stable(hcx, hasher);
670 movability.hash_stable(hcx, hasher);
672 GeneratorWitness(types) => {
673 types.hash_stable(hcx, hasher)
675 Tuple(inner_tys) => {
676 inner_tys.hash_stable(hcx, hasher);
678 Projection(ref data) | UnnormalizedProjection(ref data) => {
679 data.hash_stable(hcx, hasher);
681 Opaque(def_id, substs) => {
682 def_id.hash_stable(hcx, hasher);
683 substs.hash_stable(hcx, hasher);
686 param_ty.hash_stable(hcx, hasher);
688 Bound(debruijn, bound_ty) => {
689 debruijn.hash_stable(hcx, hasher);
690 bound_ty.hash_stable(hcx, hasher);
692 ty::Placeholder(placeholder_ty) => {
693 placeholder_ty.hash_stable(hcx, hasher);
696 def_id.hash_stable(hcx, hasher);
699 infer_ty.hash_stable(hcx, hasher);
705 impl_stable_hash_for!(enum ty::InferTy {
714 impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
717 fn hash_stable<W: StableHasherResult>(&self,
718 _hcx: &mut StableHashingContext<'a>,
719 _hasher: &mut StableHasher<W>) {
720 // TyVid values are confined to an inference context and hence
721 // should not be hashed.
722 bug!("ty::TyKind::hash_stable() - can't hash a TyVid {:?}.", *self)
726 impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
729 fn hash_stable<W: StableHasherResult>(&self,
730 _hcx: &mut StableHashingContext<'a>,
731 _hasher: &mut StableHasher<W>) {
732 // IntVid values are confined to an inference context and hence
733 // should not be hashed.
734 bug!("ty::TyKind::hash_stable() - can't hash an IntVid {:?}.", *self)
738 impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
741 fn hash_stable<W: StableHasherResult>(&self,
742 _hcx: &mut StableHashingContext<'a>,
743 _hasher: &mut StableHasher<W>) {
744 // FloatVid values are confined to an inference context and hence
745 // should not be hashed.
746 bug!("ty::TyKind::hash_stable() - can't hash a FloatVid {:?}.", *self)
750 impl_stable_hash_for!(struct ty::ParamTy {
755 impl_stable_hash_for!(struct ty::TypeAndMut<'tcx> {
760 impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
761 for ty::ExistentialPredicate<'gcx>
763 fn hash_stable<W: StableHasherResult>(&self,
764 hcx: &mut StableHashingContext<'a>,
765 hasher: &mut StableHasher<W>) {
766 mem::discriminant(self).hash_stable(hcx, hasher);
768 ty::ExistentialPredicate::Trait(ref trait_ref) => {
769 trait_ref.hash_stable(hcx, hasher);
771 ty::ExistentialPredicate::Projection(ref projection) => {
772 projection.hash_stable(hcx, hasher);
774 ty::ExistentialPredicate::AutoTrait(def_id) => {
775 def_id.hash_stable(hcx, hasher);
781 impl_stable_hash_for!(struct ty::ExistentialTraitRef<'tcx> {
786 impl_stable_hash_for!(struct ty::ExistentialProjection<'tcx> {
792 impl_stable_hash_for!(struct ty::Instance<'tcx> {
797 impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for ty::InstanceDef<'gcx> {
798 fn hash_stable<W: StableHasherResult>(&self,
799 hcx: &mut StableHashingContext<'a>,
800 hasher: &mut StableHasher<W>) {
801 mem::discriminant(self).hash_stable(hcx, hasher);
804 ty::InstanceDef::Item(def_id) => {
805 def_id.hash_stable(hcx, hasher);
807 ty::InstanceDef::VtableShim(def_id) => {
808 def_id.hash_stable(hcx, hasher);
810 ty::InstanceDef::Intrinsic(def_id) => {
811 def_id.hash_stable(hcx, hasher);
813 ty::InstanceDef::FnPtrShim(def_id, ty) => {
814 def_id.hash_stable(hcx, hasher);
815 ty.hash_stable(hcx, hasher);
817 ty::InstanceDef::Virtual(def_id, n) => {
818 def_id.hash_stable(hcx, hasher);
819 n.hash_stable(hcx, hasher);
821 ty::InstanceDef::ClosureOnceShim { call_once } => {
822 call_once.hash_stable(hcx, hasher);
824 ty::InstanceDef::DropGlue(def_id, ty) => {
825 def_id.hash_stable(hcx, hasher);
826 ty.hash_stable(hcx, hasher);
828 ty::InstanceDef::CloneShim(def_id, ty) => {
829 def_id.hash_stable(hcx, hasher);
830 ty.hash_stable(hcx, hasher);
836 impl_stable_hash_for!(struct ty::TraitDef {
837 // We already have the def_path_hash below, no need to hash it twice
846 impl_stable_hash_for!(struct ty::Destructor {
850 impl_stable_hash_for!(struct ty::CrateVariancesMap {
852 // This is just an irrelevant helper value.
856 impl_stable_hash_for!(struct ty::CratePredicatesMap<'tcx> {
858 // This is just an irrelevant helper value.
859 empty_predicate -> _,
862 impl_stable_hash_for!(struct ty::AssociatedItem {
864 ident -> (ident.name),
869 method_has_self_argument
872 impl_stable_hash_for!(enum ty::AssociatedKind {
879 impl_stable_hash_for!(enum ty::AssociatedItemContainer {
880 TraitContainer(def_id),
881 ImplContainer(def_id)
885 impl<'a, 'gcx, T> HashStable<StableHashingContext<'a>>
886 for ty::steal::Steal<T>
887 where T: HashStable<StableHashingContext<'a>>
889 fn hash_stable<W: StableHasherResult>(&self,
890 hcx: &mut StableHashingContext<'a>,
891 hasher: &mut StableHasher<W>) {
892 self.borrow().hash_stable(hcx, hasher);
896 impl_stable_hash_for!(struct ty::ParamEnv<'tcx> {
901 impl_stable_hash_for!(enum traits::Reveal {
906 impl_stable_hash_for!(enum ::middle::privacy::AccessLevel {
907 ReachableFromImplTrait,
913 impl<'a> HashStable<StableHashingContext<'a>>
914 for ::middle::privacy::AccessLevels {
915 fn hash_stable<W: StableHasherResult>(&self,
916 hcx: &mut StableHashingContext<'a>,
917 hasher: &mut StableHasher<W>) {
918 hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
919 let ::middle::privacy::AccessLevels {
923 map.hash_stable(hcx, hasher);
928 impl_stable_hash_for!(struct ty::CrateInherentImpls {
932 impl_stable_hash_for!(enum ::session::CompileIncomplete {
934 Errored(error_reported)
937 impl_stable_hash_for!(struct ::util::common::ErrorReported {});
939 impl_stable_hash_for!(tuple_struct ::middle::reachable::ReachableSet {
943 impl<'a, 'gcx, N> HashStable<StableHashingContext<'a>>
944 for traits::Vtable<'gcx, N> where N: HashStable<StableHashingContext<'a>> {
945 fn hash_stable<W: StableHasherResult>(&self,
946 hcx: &mut StableHashingContext<'a>,
947 hasher: &mut StableHasher<W>) {
948 use traits::Vtable::*;
950 mem::discriminant(self).hash_stable(hcx, hasher);
953 &VtableImpl(ref table_impl) => table_impl.hash_stable(hcx, hasher),
954 &VtableAutoImpl(ref table_def_impl) => table_def_impl.hash_stable(hcx, hasher),
955 &VtableParam(ref table_param) => table_param.hash_stable(hcx, hasher),
956 &VtableObject(ref table_obj) => table_obj.hash_stable(hcx, hasher),
957 &VtableBuiltin(ref table_builtin) => table_builtin.hash_stable(hcx, hasher),
958 &VtableClosure(ref table_closure) => table_closure.hash_stable(hcx, hasher),
959 &VtableFnPointer(ref table_fn_pointer) => table_fn_pointer.hash_stable(hcx, hasher),
960 &VtableGenerator(ref table_generator) => table_generator.hash_stable(hcx, hasher),
961 &VtableTraitAlias(ref table_alias) => table_alias.hash_stable(hcx, hasher),
966 impl<'a, 'gcx, N> HashStable<StableHashingContext<'a>>
967 for traits::VtableImplData<'gcx, N> where N: HashStable<StableHashingContext<'a>> {
968 fn hash_stable<W: StableHasherResult>(&self,
969 hcx: &mut StableHashingContext<'a>,
970 hasher: &mut StableHasher<W>) {
971 let traits::VtableImplData {
976 impl_def_id.hash_stable(hcx, hasher);
977 substs.hash_stable(hcx, hasher);
978 nested.hash_stable(hcx, hasher);
982 impl<'a, 'gcx, N> HashStable<StableHashingContext<'a>>
983 for traits::VtableAutoImplData<N> where N: HashStable<StableHashingContext<'a>> {
984 fn hash_stable<W: StableHasherResult>(&self,
985 hcx: &mut StableHashingContext<'a>,
986 hasher: &mut StableHasher<W>) {
987 let traits::VtableAutoImplData {
991 trait_def_id.hash_stable(hcx, hasher);
992 nested.hash_stable(hcx, hasher);
996 impl<'a, 'gcx, N> HashStable<StableHashingContext<'a>>
997 for traits::VtableObjectData<'gcx, N> where N: HashStable<StableHashingContext<'a>> {
998 fn hash_stable<W: StableHasherResult>(&self,
999 hcx: &mut StableHashingContext<'a>,
1000 hasher: &mut StableHasher<W>) {
1001 let traits::VtableObjectData {
1006 upcast_trait_ref.hash_stable(hcx, hasher);
1007 vtable_base.hash_stable(hcx, hasher);
1008 nested.hash_stable(hcx, hasher);
1012 impl<'a, 'gcx, N> HashStable<StableHashingContext<'a>>
1013 for traits::VtableBuiltinData<N> where N: HashStable<StableHashingContext<'a>> {
1014 fn hash_stable<W: StableHasherResult>(&self,
1015 hcx: &mut StableHashingContext<'a>,
1016 hasher: &mut StableHasher<W>) {
1017 let traits::VtableBuiltinData {
1020 nested.hash_stable(hcx, hasher);
1024 impl<'a, 'gcx, N> HashStable<StableHashingContext<'a>>
1025 for traits::VtableClosureData<'gcx, N> where N: HashStable<StableHashingContext<'a>> {
1026 fn hash_stable<W: StableHasherResult>(&self,
1027 hcx: &mut StableHashingContext<'a>,
1028 hasher: &mut StableHasher<W>) {
1029 let traits::VtableClosureData {
1034 closure_def_id.hash_stable(hcx, hasher);
1035 substs.hash_stable(hcx, hasher);
1036 nested.hash_stable(hcx, hasher);
1040 impl<'a, 'gcx, N> HashStable<StableHashingContext<'a>>
1041 for traits::VtableFnPointerData<'gcx, N> where N: HashStable<StableHashingContext<'a>> {
1042 fn hash_stable<W: StableHasherResult>(&self,
1043 hcx: &mut StableHashingContext<'a>,
1044 hasher: &mut StableHasher<W>) {
1045 let traits::VtableFnPointerData {
1049 fn_ty.hash_stable(hcx, hasher);
1050 nested.hash_stable(hcx, hasher);
1054 impl<'a, 'gcx, N> HashStable<StableHashingContext<'a>>
1055 for traits::VtableGeneratorData<'gcx, N> where N: HashStable<StableHashingContext<'a>> {
1056 fn hash_stable<W: StableHasherResult>(&self,
1057 hcx: &mut StableHashingContext<'a>,
1058 hasher: &mut StableHasher<W>) {
1059 let traits::VtableGeneratorData {
1064 generator_def_id.hash_stable(hcx, hasher);
1065 substs.hash_stable(hcx, hasher);
1066 nested.hash_stable(hcx, hasher);
1070 impl<'a, 'gcx, N> HashStable<StableHashingContext<'a>>
1071 for traits::VtableTraitAliasData<'gcx, N> where N: HashStable<StableHashingContext<'a>> {
1072 fn hash_stable<W: StableHasherResult>(&self,
1073 hcx: &mut StableHashingContext<'a>,
1074 hasher: &mut StableHasher<W>) {
1075 let traits::VtableTraitAliasData {
1080 alias_def_id.hash_stable(hcx, hasher);
1081 substs.hash_stable(hcx, hasher);
1082 nested.hash_stable(hcx, hasher);
1086 impl_stable_hash_for!(
1087 impl<'tcx, V> for struct infer::canonical::Canonical<'tcx, V> {
1088 max_universe, variables, value
1092 impl_stable_hash_for!(
1093 struct infer::canonical::CanonicalVarValues<'tcx> {
1098 impl_stable_hash_for!(struct infer::canonical::CanonicalVarInfo {
1102 impl_stable_hash_for!(enum infer::canonical::CanonicalVarKind {
1104 PlaceholderTy(placeholder),
1106 PlaceholderRegion(placeholder),
1109 impl_stable_hash_for!(enum infer::canonical::CanonicalTyVarKind {
1115 impl_stable_hash_for!(
1116 impl<'tcx, R> for struct infer::canonical::QueryResponse<'tcx, R> {
1117 var_values, region_constraints, certainty, value
1121 impl_stable_hash_for!(enum infer::canonical::Certainty {
1125 impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for traits::WhereClause<'tcx> {
1126 fn hash_stable<W: StableHasherResult>(&self,
1127 hcx: &mut StableHashingContext<'a>,
1128 hasher: &mut StableHasher<W>) {
1129 use traits::WhereClause::*;
1131 mem::discriminant(self).hash_stable(hcx, hasher);
1133 Implemented(trait_ref) => trait_ref.hash_stable(hcx, hasher),
1134 ProjectionEq(projection) => projection.hash_stable(hcx, hasher),
1135 TypeOutlives(ty_outlives) => ty_outlives.hash_stable(hcx, hasher),
1136 RegionOutlives(region_outlives) => region_outlives.hash_stable(hcx, hasher),
1141 impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for traits::WellFormed<'tcx> {
1142 fn hash_stable<W: StableHasherResult>(&self,
1143 hcx: &mut StableHashingContext<'a>,
1144 hasher: &mut StableHasher<W>) {
1145 use traits::WellFormed::*;
1147 mem::discriminant(self).hash_stable(hcx, hasher);
1149 Trait(trait_ref) => trait_ref.hash_stable(hcx, hasher),
1150 Ty(ty) => ty.hash_stable(hcx, hasher),
1155 impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for traits::FromEnv<'tcx> {
1156 fn hash_stable<W: StableHasherResult>(&self,
1157 hcx: &mut StableHashingContext<'a>,
1158 hasher: &mut StableHasher<W>) {
1159 use traits::FromEnv::*;
1161 mem::discriminant(self).hash_stable(hcx, hasher);
1163 Trait(trait_ref) => trait_ref.hash_stable(hcx, hasher),
1164 Ty(ty) => ty.hash_stable(hcx, hasher),
1169 impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for traits::DomainGoal<'tcx> {
1170 fn hash_stable<W: StableHasherResult>(&self,
1171 hcx: &mut StableHashingContext<'a>,
1172 hasher: &mut StableHasher<W>) {
1173 use traits::DomainGoal::*;
1175 mem::discriminant(self).hash_stable(hcx, hasher);
1177 Holds(wc) => wc.hash_stable(hcx, hasher),
1178 WellFormed(wf) => wf.hash_stable(hcx, hasher),
1179 FromEnv(from_env) => from_env.hash_stable(hcx, hasher),
1180 Normalize(projection) => projection.hash_stable(hcx, hasher),
1185 impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for traits::Goal<'tcx> {
1186 fn hash_stable<W: StableHasherResult>(&self,
1187 hcx: &mut StableHashingContext<'a>,
1188 hasher: &mut StableHasher<W>) {
1189 use traits::GoalKind::*;
1191 mem::discriminant(self).hash_stable(hcx, hasher);
1193 Implies(hypotheses, goal) => {
1194 hypotheses.hash_stable(hcx, hasher);
1195 goal.hash_stable(hcx, hasher);
1197 And(goal1, goal2) => {
1198 goal1.hash_stable(hcx, hasher);
1199 goal2.hash_stable(hcx, hasher);
1201 Not(goal) => goal.hash_stable(hcx, hasher),
1202 DomainGoal(domain_goal) => domain_goal.hash_stable(hcx, hasher),
1203 Quantified(quantifier, goal) => {
1204 quantifier.hash_stable(hcx, hasher);
1205 goal.hash_stable(hcx, hasher);
1212 impl_stable_hash_for!(
1213 struct traits::ProgramClause<'tcx> {
1214 goal, hypotheses, category
1218 impl_stable_hash_for!(enum traits::ProgramClauseCategory {
1224 impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for traits::Clause<'tcx> {
1225 fn hash_stable<W: StableHasherResult>(&self,
1226 hcx: &mut StableHashingContext<'a>,
1227 hasher: &mut StableHasher<W>) {
1228 use traits::Clause::*;
1230 mem::discriminant(self).hash_stable(hcx, hasher);
1232 Implies(clause) => clause.hash_stable(hcx, hasher),
1233 ForAll(clause) => clause.hash_stable(hcx, hasher),
1238 impl_stable_hash_for!(enum traits::QuantifierKind {
1243 impl_stable_hash_for!(struct ty::subst::UserSubsts<'tcx> { substs, user_self_ty });
1245 impl_stable_hash_for!(struct ty::subst::UserSelfTy<'tcx> { impl_def_id, self_ty });
1247 impl_stable_hash_for!(
1248 struct traits::Environment<'tcx> {