]> git.lizzy.rs Git - rust.git/blob - src/librustc/ich/impls_ty.rs
d68a62e50303110be09daaafc234d539d3520cc3
[rust.git] / src / librustc / ich / impls_ty.rs
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.
4 //
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.
10
11 //! This module contains `HashStable` implementations for various data types
12 //! from rustc::ty in no particular order.
13
14 use ich::{self, StableHashingContext, NodeIdHashingMode};
15 use rustc_data_structures::stable_hasher::{HashStable, StableHasher,
16                                            StableHasherResult};
17 use std::hash as std_hash;
18 use std::mem;
19 use syntax_pos::symbol::InternedString;
20 use ty;
21
22 impl_stable_hash_for!(struct ty::ItemSubsts<'tcx> { substs });
23
24 impl<'a, 'tcx, T> HashStable<StableHashingContext<'a, 'tcx>> for &'tcx ty::Slice<T>
25     where T: HashStable<StableHashingContext<'a, 'tcx>> {
26     fn hash_stable<W: StableHasherResult>(&self,
27                                           hcx: &mut StableHashingContext<'a, 'tcx>,
28                                           hasher: &mut StableHasher<W>) {
29         (&self[..]).hash_stable(hcx, hasher);
30     }
31 }
32
33 impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ty::subst::Kind<'tcx> {
34     fn hash_stable<W: StableHasherResult>(&self,
35                                           hcx: &mut StableHashingContext<'a, 'tcx>,
36                                           hasher: &mut StableHasher<W>) {
37         self.as_type().hash_stable(hcx, hasher);
38         self.as_region().hash_stable(hcx, hasher);
39     }
40 }
41
42 impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ty::Region {
43     fn hash_stable<W: StableHasherResult>(&self,
44                                           hcx: &mut StableHashingContext<'a, 'tcx>,
45                                           hasher: &mut StableHasher<W>) {
46         mem::discriminant(self).hash_stable(hcx, hasher);
47         match *self {
48             ty::ReErased |
49             ty::ReStatic |
50             ty::ReEmpty => {
51                 // No variant fields to hash for these ...
52             }
53             ty::ReLateBound(db, ty::BrAnon(i)) => {
54                 db.depth.hash_stable(hcx, hasher);
55                 i.hash_stable(hcx, hasher);
56             }
57             ty::ReEarlyBound(ty::EarlyBoundRegion { index, name }) => {
58                 index.hash_stable(hcx, hasher);
59                 name.hash_stable(hcx, hasher);
60             }
61             ty::ReScope(code_extent) => {
62                 code_extent.hash_stable(hcx, hasher);
63             }
64             ty::ReFree(ref free_region) => {
65                 free_region.hash_stable(hcx, hasher);
66             }
67             ty::ReLateBound(..) |
68             ty::ReVar(..) |
69             ty::ReSkolemized(..) => {
70                 bug!("TypeIdHasher: unexpected region {:?}", *self)
71             }
72         }
73     }
74 }
75
76 impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ty::adjustment::AutoBorrow<'tcx> {
77     fn hash_stable<W: StableHasherResult>(&self,
78                                           hcx: &mut StableHashingContext<'a, 'tcx>,
79                                           hasher: &mut StableHasher<W>) {
80         mem::discriminant(self).hash_stable(hcx, hasher);
81         match *self {
82             ty::adjustment::AutoBorrow::Ref(ref region, mutability) => {
83                 region.hash_stable(hcx, hasher);
84                 mutability.hash_stable(hcx, hasher);
85             }
86             ty::adjustment::AutoBorrow::RawPtr(mutability) => {
87                 mutability.hash_stable(hcx, hasher);
88             }
89         }
90     }
91 }
92
93 impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ty::adjustment::Adjust<'tcx> {
94     fn hash_stable<W: StableHasherResult>(&self,
95                                           hcx: &mut StableHashingContext<'a, 'tcx>,
96                                           hasher: &mut StableHasher<W>) {
97         mem::discriminant(self).hash_stable(hcx, hasher);
98         match *self {
99             ty::adjustment::Adjust::NeverToAny |
100             ty::adjustment::Adjust::ReifyFnPointer |
101             ty::adjustment::Adjust::UnsafeFnPointer |
102             ty::adjustment::Adjust::ClosureFnPointer |
103             ty::adjustment::Adjust::MutToConstPointer => {}
104             ty::adjustment::Adjust::DerefRef { autoderefs, ref autoref, unsize } => {
105                 autoderefs.hash_stable(hcx, hasher);
106                 autoref.hash_stable(hcx, hasher);
107                 unsize.hash_stable(hcx, hasher);
108             }
109         }
110     }
111 }
112
113 impl_stable_hash_for!(struct ty::adjustment::Adjustment<'tcx> { kind, target });
114 impl_stable_hash_for!(struct ty::MethodCall { expr_id, autoderef });
115 impl_stable_hash_for!(struct ty::MethodCallee<'tcx> { def_id, ty, substs });
116 impl_stable_hash_for!(struct ty::UpvarId { var_id, closure_expr_id });
117 impl_stable_hash_for!(struct ty::UpvarBorrow<'tcx> { kind, region });
118
119 impl_stable_hash_for!(enum ty::BorrowKind {
120     ImmBorrow,
121     UniqueImmBorrow,
122     MutBorrow
123 });
124
125 impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ty::UpvarCapture<'tcx> {
126     fn hash_stable<W: StableHasherResult>(&self,
127                                           hcx: &mut StableHashingContext<'a, 'tcx>,
128                                           hasher: &mut StableHasher<W>) {
129         mem::discriminant(self).hash_stable(hcx, hasher);
130         match *self {
131             ty::UpvarCapture::ByValue => {}
132             ty::UpvarCapture::ByRef(ref up_var_borrow) => {
133                 up_var_borrow.hash_stable(hcx, hasher);
134             }
135         }
136     }
137 }
138
139 impl_stable_hash_for!(struct ty::FnSig<'tcx> {
140     inputs_and_output,
141     variadic,
142     unsafety,
143     abi
144 });
145
146 impl<'a, 'tcx, T> HashStable<StableHashingContext<'a, 'tcx>> for ty::Binder<T>
147     where T: HashStable<StableHashingContext<'a, 'tcx>> + ty::fold::TypeFoldable<'tcx>
148 {
149     fn hash_stable<W: StableHasherResult>(&self,
150                                           hcx: &mut StableHashingContext<'a, 'tcx>,
151                                           hasher: &mut StableHasher<W>) {
152         hcx.tcx().anonymize_late_bound_regions(self).0.hash_stable(hcx, hasher);
153     }
154 }
155
156 impl_stable_hash_for!(enum ty::ClosureKind { Fn, FnMut, FnOnce });
157
158 impl_stable_hash_for!(enum ty::Visibility {
159     Public,
160     Restricted(def_id),
161     Invisible
162 });
163
164 impl_stable_hash_for!(struct ty::TraitRef<'tcx> { def_id, substs });
165 impl_stable_hash_for!(struct ty::TraitPredicate<'tcx> { trait_ref });
166 impl_stable_hash_for!(tuple_struct ty::EquatePredicate<'tcx> { t1, t2 });
167 impl_stable_hash_for!(struct ty::SubtypePredicate<'tcx> { a_is_expected, a, b });
168
169 impl<'a, 'tcx, A, B> HashStable<StableHashingContext<'a, 'tcx>> for ty::OutlivesPredicate<A, B>
170     where A: HashStable<StableHashingContext<'a, 'tcx>>,
171           B: HashStable<StableHashingContext<'a, 'tcx>>,
172 {
173     fn hash_stable<W: StableHasherResult>(&self,
174                                           hcx: &mut StableHashingContext<'a, 'tcx>,
175                                           hasher: &mut StableHasher<W>) {
176         let ty::OutlivesPredicate(ref a, ref b) = *self;
177         a.hash_stable(hcx, hasher);
178         b.hash_stable(hcx, hasher);
179     }
180 }
181
182 impl_stable_hash_for!(struct ty::ProjectionPredicate<'tcx> { projection_ty, ty });
183 impl_stable_hash_for!(struct ty::ProjectionTy<'tcx> { trait_ref, item_name });
184
185
186 impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ty::Predicate<'tcx> {
187     fn hash_stable<W: StableHasherResult>(&self,
188                                           hcx: &mut StableHashingContext<'a, 'tcx>,
189                                           hasher: &mut StableHasher<W>) {
190         mem::discriminant(self).hash_stable(hcx, hasher);
191         match *self {
192             ty::Predicate::Trait(ref pred) => {
193                 pred.hash_stable(hcx, hasher);
194             }
195             ty::Predicate::Equate(ref pred) => {
196                 pred.hash_stable(hcx, hasher);
197             }
198             ty::Predicate::Subtype(ref pred) => {
199                 pred.hash_stable(hcx, hasher);
200             }
201             ty::Predicate::RegionOutlives(ref pred) => {
202                 pred.hash_stable(hcx, hasher);
203             }
204             ty::Predicate::TypeOutlives(ref pred) => {
205                 pred.hash_stable(hcx, hasher);
206             }
207             ty::Predicate::Projection(ref pred) => {
208                 pred.hash_stable(hcx, hasher);
209             }
210             ty::Predicate::WellFormed(ty) => {
211                 ty.hash_stable(hcx, hasher);
212             }
213             ty::Predicate::ObjectSafe(def_id) => {
214                 def_id.hash_stable(hcx, hasher);
215             }
216             ty::Predicate::ClosureKind(def_id, closure_kind) => {
217                 def_id.hash_stable(hcx, hasher);
218                 closure_kind.hash_stable(hcx, hasher);
219             }
220         }
221     }
222 }
223
224 impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ty::AdtFlags {
225     fn hash_stable<W: StableHasherResult>(&self,
226                                           _: &mut StableHashingContext<'a, 'tcx>,
227                                           hasher: &mut StableHasher<W>) {
228         std_hash::Hash::hash(self, hasher);
229     }
230 }
231
232 impl_stable_hash_for!(struct ty::VariantDef {
233     did,
234     name,
235     discr,
236     fields,
237     ctor_kind
238 });
239
240 impl_stable_hash_for!(enum ty::VariantDiscr {
241     Explicit(def_id),
242     Relative(distance)
243 });
244
245 impl_stable_hash_for!(struct ty::FieldDef {
246     did,
247     name,
248     vis
249 });
250
251 impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>>
252 for ::middle::const_val::ConstVal<'tcx> {
253     fn hash_stable<W: StableHasherResult>(&self,
254                                           hcx: &mut StableHashingContext<'a, 'tcx>,
255                                           hasher: &mut StableHasher<W>) {
256         use middle::const_val::ConstVal;
257
258         mem::discriminant(self).hash_stable(hcx, hasher);
259
260         match *self {
261             ConstVal::Float(ref value) => {
262                 value.hash_stable(hcx, hasher);
263             }
264             ConstVal::Integral(ref value) => {
265                 value.hash_stable(hcx, hasher);
266             }
267             ConstVal::Str(ref value) => {
268                 value.hash_stable(hcx, hasher);
269             }
270             ConstVal::ByteStr(ref value) => {
271                 value.hash_stable(hcx, hasher);
272             }
273             ConstVal::Bool(value) => {
274                 value.hash_stable(hcx, hasher);
275             }
276             ConstVal::Char(value) => {
277                 value.hash_stable(hcx, hasher);
278             }
279             ConstVal::Variant(def_id) => {
280                 def_id.hash_stable(hcx, hasher);
281             }
282             ConstVal::Function(def_id, substs) => {
283                 def_id.hash_stable(hcx, hasher);
284                 substs.hash_stable(hcx, hasher);
285             }
286             ConstVal::Struct(ref name_value_map) => {
287                 let mut values: Vec<(InternedString, &ConstVal)> =
288                     name_value_map.iter()
289                                   .map(|(name, val)| (name.as_str(), val))
290                                   .collect();
291
292                 values.sort_unstable_by_key(|&(ref name, _)| name.clone());
293                 values.hash_stable(hcx, hasher);
294             }
295             ConstVal::Tuple(ref value) => {
296                 value.hash_stable(hcx, hasher);
297             }
298             ConstVal::Array(ref value) => {
299                 value.hash_stable(hcx, hasher);
300             }
301             ConstVal::Repeat(ref value, times) => {
302                 value.hash_stable(hcx, hasher);
303                 times.hash_stable(hcx, hasher);
304             }
305         }
306     }
307 }
308
309 impl_stable_hash_for!(struct ty::ClosureSubsts<'tcx> { substs });
310
311 impl_stable_hash_for!(struct ty::GenericPredicates<'tcx> {
312     parent,
313     predicates
314 });
315
316 impl_stable_hash_for!(enum ty::Variance {
317     Covariant,
318     Invariant,
319     Contravariant,
320     Bivariant
321 });
322
323 impl_stable_hash_for!(enum ty::adjustment::CustomCoerceUnsized {
324     Struct(index)
325 });
326
327 impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ty::Generics {
328     fn hash_stable<W: StableHasherResult>(&self,
329                                           hcx: &mut StableHashingContext<'a, 'tcx>,
330                                           hasher: &mut StableHasher<W>) {
331         let ty::Generics {
332             parent,
333             parent_regions,
334             parent_types,
335             ref regions,
336             ref types,
337
338             // Reverse map to each `TypeParameterDef`'s `index` field, from
339             // `def_id.index` (`def_id.krate` is the same as the item's).
340             type_param_to_index: _, // Don't hash this
341             has_self,
342         } = *self;
343
344         parent.hash_stable(hcx, hasher);
345         parent_regions.hash_stable(hcx, hasher);
346         parent_types.hash_stable(hcx, hasher);
347         regions.hash_stable(hcx, hasher);
348         types.hash_stable(hcx, hasher);
349         has_self.hash_stable(hcx, hasher);
350     }
351 }
352
353 impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ty::RegionParameterDef {
354     fn hash_stable<W: StableHasherResult>(&self,
355                                           hcx: &mut StableHashingContext<'a, 'tcx>,
356                                           hasher: &mut StableHasher<W>) {
357         let ty::RegionParameterDef {
358             name,
359             def_id,
360             index,
361             issue_32330: _,
362             pure_wrt_drop
363         } = *self;
364
365         name.hash_stable(hcx, hasher);
366         def_id.hash_stable(hcx, hasher);
367         index.hash_stable(hcx, hasher);
368         pure_wrt_drop.hash_stable(hcx, hasher);
369     }
370 }
371
372 impl_stable_hash_for!(struct ty::TypeParameterDef {
373     name,
374     def_id,
375     index,
376     has_default,
377     object_lifetime_default,
378     pure_wrt_drop
379 });
380
381
382 impl<'a, 'tcx, T> HashStable<StableHashingContext<'a, 'tcx>>
383 for ::middle::resolve_lifetime::Set1<T>
384     where T: HashStable<StableHashingContext<'a, 'tcx>>
385 {
386     fn hash_stable<W: StableHasherResult>(&self,
387                                           hcx: &mut StableHashingContext<'a, 'tcx>,
388                                           hasher: &mut StableHasher<W>) {
389         use middle::resolve_lifetime::Set1;
390
391         mem::discriminant(self).hash_stable(hcx, hasher);
392         match *self {
393             Set1::Empty |
394             Set1::Many => {
395                 // Nothing to do.
396             }
397             Set1::One(ref value) => {
398                 value.hash_stable(hcx, hasher);
399             }
400         }
401     }
402 }
403
404 impl_stable_hash_for!(enum ::middle::resolve_lifetime::Region {
405     Static,
406     EarlyBound(index, decl),
407     LateBound(db_index, decl),
408     LateBoundAnon(db_index, anon_index),
409     Free(call_site_scope_data, decl)
410 });
411
412 impl_stable_hash_for!(struct ::middle::region::CallSiteScopeData {
413     fn_id,
414     body_id
415 });
416
417 impl_stable_hash_for!(struct ty::DebruijnIndex {
418     depth
419 });
420
421 impl_stable_hash_for!(enum ty::cast::CastKind {
422     CoercionCast,
423     PtrPtrCast,
424     PtrAddrCast,
425     AddrPtrCast,
426     NumericCast,
427     EnumCast,
428     PrimIntCast,
429     U8CharCast,
430     ArrayPtrCast,
431     FnPtrPtrCast,
432     FnPtrAddrCast
433 });
434
435 impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ::middle::region::CodeExtent
436 {
437     fn hash_stable<W: StableHasherResult>(&self,
438                                           hcx: &mut StableHashingContext<'a, 'tcx>,
439                                           hasher: &mut StableHasher<W>) {
440         hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
441             hcx.tcx().region_maps().code_extent_data(*self).hash_stable(hcx, hasher);
442         });
443     }
444 }
445
446 impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ::middle::region::CodeExtentData
447 {
448     fn hash_stable<W: StableHasherResult>(&self,
449                                           hcx: &mut StableHashingContext<'a, 'tcx>,
450                                           hasher: &mut StableHasher<W>) {
451         use middle::region::CodeExtentData;
452
453         mem::discriminant(self).hash_stable(hcx, hasher);
454         match *self {
455             CodeExtentData::Misc(node_id) |
456             CodeExtentData::DestructionScope(node_id) => {
457                 node_id.hash_stable(hcx, hasher);
458             }
459             CodeExtentData::CallSiteScope { fn_id, body_id } |
460             CodeExtentData::ParameterScope { fn_id, body_id } => {
461                 fn_id.hash_stable(hcx, hasher);
462                 body_id.hash_stable(hcx, hasher);
463             }
464             CodeExtentData::Remainder(block_remainder) => {
465                 block_remainder.hash_stable(hcx, hasher);
466             }
467         }
468     }
469 }
470
471 impl_stable_hash_for!(struct ::middle::region::BlockRemainder {
472     block,
473     first_statement_index
474 });
475
476 impl_stable_hash_for!(struct ty::adjustment::CoerceUnsizedInfo {
477     custom_kind
478 });
479
480 impl_stable_hash_for!(struct ty::FreeRegion {
481     scope,
482     bound_region
483 });
484
485 impl_stable_hash_for!(enum ty::BoundRegion {
486     BrAnon(index),
487     BrNamed(def_id, name),
488     BrFresh(index),
489     BrEnv
490 });
491
492 impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ty::TypeVariants<'tcx>
493 {
494     fn hash_stable<W: StableHasherResult>(&self,
495                                           hcx: &mut StableHashingContext<'a, 'tcx>,
496                                           hasher: &mut StableHasher<W>) {
497         use ty::TypeVariants::*;
498
499         mem::discriminant(self).hash_stable(hcx, hasher);
500         match *self {
501             TyBool  |
502             TyChar  |
503             TyStr   |
504             TyNever => {
505                 // Nothing more to hash.
506             }
507             TyInt(int_ty) => {
508                 int_ty.hash_stable(hcx, hasher);
509             }
510             TyUint(uint_ty) => {
511                 uint_ty.hash_stable(hcx, hasher);
512             }
513             TyFloat(float_ty)  => {
514                 float_ty.hash_stable(hcx, hasher);
515             }
516             TyAdt(adt_def, substs) => {
517                 adt_def.hash_stable(hcx, hasher);
518                 substs.hash_stable(hcx, hasher);
519             }
520             TyArray(inner_ty, len) => {
521                 inner_ty.hash_stable(hcx, hasher);
522                 len.hash_stable(hcx, hasher);
523             }
524             TySlice(inner_ty) => {
525                 inner_ty.hash_stable(hcx, hasher);
526             }
527             TyRawPtr(pointee_ty) => {
528                 pointee_ty.hash_stable(hcx, hasher);
529             }
530             TyRef(region, pointee_ty) => {
531                 region.hash_stable(hcx, hasher);
532                 pointee_ty.hash_stable(hcx, hasher);
533             }
534             TyFnDef(def_id, substs, ref sig) => {
535                 def_id.hash_stable(hcx, hasher);
536                 substs.hash_stable(hcx, hasher);
537                 sig.hash_stable(hcx, hasher);
538             }
539             TyFnPtr(ref sig) => {
540                 sig.hash_stable(hcx, hasher);
541             }
542             TyDynamic(ref existential_predicates, region) => {
543                 existential_predicates.hash_stable(hcx, hasher);
544                 region.hash_stable(hcx, hasher);
545             }
546             TyClosure(def_id, closure_substs) => {
547                 def_id.hash_stable(hcx, hasher);
548                 closure_substs.hash_stable(hcx, hasher);
549             }
550             TyTuple(inner_tys, from_diverging_type_var) => {
551                 inner_tys.hash_stable(hcx, hasher);
552                 from_diverging_type_var.hash_stable(hcx, hasher);
553             }
554             TyProjection(ref projection_ty) => {
555                 projection_ty.hash_stable(hcx, hasher);
556             }
557             TyAnon(def_id, substs) => {
558                 def_id.hash_stable(hcx, hasher);
559                 substs.hash_stable(hcx, hasher);
560             }
561             TyParam(param_ty) => {
562                 param_ty.hash_stable(hcx, hasher);
563             }
564
565             TyError     |
566             TyInfer(..) => {
567                 bug!("ty::TypeVariants::hash_stable() - Unexpected variant.")
568             }
569         }
570     }
571 }
572
573 impl_stable_hash_for!(struct ty::ParamTy {
574     idx,
575     name
576 });
577
578 impl_stable_hash_for!(struct ty::TypeAndMut<'tcx> {
579     ty,
580     mutbl
581 });
582
583 impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ty::ExistentialPredicate<'tcx>
584 {
585     fn hash_stable<W: StableHasherResult>(&self,
586                                           hcx: &mut StableHashingContext<'a, 'tcx>,
587                                           hasher: &mut StableHasher<W>) {
588         mem::discriminant(self).hash_stable(hcx, hasher);
589         match *self {
590             ty::ExistentialPredicate::Trait(ref trait_ref) => {
591                 trait_ref.hash_stable(hcx, hasher);
592             }
593             ty::ExistentialPredicate::Projection(ref projection) => {
594                 projection.hash_stable(hcx, hasher);
595             }
596             ty::ExistentialPredicate::AutoTrait(def_id) => {
597                 def_id.hash_stable(hcx, hasher);
598             }
599         }
600     }
601 }
602
603 impl_stable_hash_for!(struct ty::ExistentialTraitRef<'tcx> {
604     def_id,
605     substs
606 });
607
608 impl_stable_hash_for!(struct ty::ExistentialProjection<'tcx> {
609     trait_ref,
610     item_name,
611     ty
612 });
613
614
615 impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ty::TypeckTables<'tcx> {
616     fn hash_stable<W: StableHasherResult>(&self,
617                                           hcx: &mut StableHashingContext<'a, 'tcx>,
618                                           hasher: &mut StableHasher<W>) {
619         let ty::TypeckTables {
620             ref type_relative_path_defs,
621             ref node_types,
622             ref item_substs,
623             ref adjustments,
624             ref method_map,
625             ref upvar_capture_map,
626             ref closure_tys,
627             ref closure_kinds,
628             ref liberated_fn_sigs,
629             ref fru_field_types,
630
631             ref cast_kinds,
632
633             // FIXME(#41184): This is still ignored at the moment.
634             lints: _,
635             ref used_trait_imports,
636             tainted_by_errors,
637             ref free_region_map,
638         } = *self;
639
640         hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
641             ich::hash_stable_nodemap(hcx, hasher, type_relative_path_defs);
642             ich::hash_stable_nodemap(hcx, hasher, node_types);
643             ich::hash_stable_nodemap(hcx, hasher, item_substs);
644             ich::hash_stable_nodemap(hcx, hasher, adjustments);
645
646             ich::hash_stable_hashmap(hcx, hasher, method_map, |hcx, method_call| {
647                 let ty::MethodCall {
648                     expr_id,
649                     autoderef
650                 } = *method_call;
651
652                 let def_id = hcx.tcx().hir.local_def_id(expr_id);
653                 (hcx.def_path_hash(def_id), autoderef)
654             });
655
656             ich::hash_stable_hashmap(hcx, hasher, upvar_capture_map, |hcx, up_var_id| {
657                 let ty::UpvarId {
658                     var_id,
659                     closure_expr_id
660                 } = *up_var_id;
661
662                 let var_def_id = hcx.tcx().hir.local_def_id(var_id);
663                 let closure_def_id = hcx.tcx().hir.local_def_id(closure_expr_id);
664                 (hcx.def_path_hash(var_def_id), hcx.def_path_hash(closure_def_id))
665             });
666
667             ich::hash_stable_nodemap(hcx, hasher, closure_tys);
668             ich::hash_stable_nodemap(hcx, hasher, closure_kinds);
669             ich::hash_stable_nodemap(hcx, hasher, liberated_fn_sigs);
670             ich::hash_stable_nodemap(hcx, hasher, fru_field_types);
671             ich::hash_stable_nodemap(hcx, hasher, cast_kinds);
672
673             ich::hash_stable_hashset(hcx, hasher, used_trait_imports, |hcx, def_id| {
674                 hcx.def_path_hash(*def_id)
675             });
676
677             tainted_by_errors.hash_stable(hcx, hasher);
678             free_region_map.hash_stable(hcx, hasher);
679         })
680     }
681 }