]> git.lizzy.rs Git - rust.git/blob - src/librustc/ich/impls_ty.rs
Rollup merge of #41141 - michaelwoerister:direct-metadata-ich-final, r=nikomatsakis
[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
168 impl<'a, 'tcx, A, B> HashStable<StableHashingContext<'a, 'tcx>> for ty::OutlivesPredicate<A, B>
169     where A: HashStable<StableHashingContext<'a, 'tcx>>,
170           B: HashStable<StableHashingContext<'a, 'tcx>>,
171 {
172     fn hash_stable<W: StableHasherResult>(&self,
173                                           hcx: &mut StableHashingContext<'a, 'tcx>,
174                                           hasher: &mut StableHasher<W>) {
175         let ty::OutlivesPredicate(ref a, ref b) = *self;
176         a.hash_stable(hcx, hasher);
177         b.hash_stable(hcx, hasher);
178     }
179 }
180
181 impl_stable_hash_for!(struct ty::ProjectionPredicate<'tcx> { projection_ty, ty });
182 impl_stable_hash_for!(struct ty::ProjectionTy<'tcx> { trait_ref, item_name });
183
184
185 impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ty::Predicate<'tcx> {
186     fn hash_stable<W: StableHasherResult>(&self,
187                                           hcx: &mut StableHashingContext<'a, 'tcx>,
188                                           hasher: &mut StableHasher<W>) {
189         mem::discriminant(self).hash_stable(hcx, hasher);
190         match *self {
191             ty::Predicate::Trait(ref pred) => {
192                 pred.hash_stable(hcx, hasher);
193             }
194             ty::Predicate::Equate(ref pred) => {
195                 pred.hash_stable(hcx, hasher);
196             }
197             ty::Predicate::RegionOutlives(ref pred) => {
198                 pred.hash_stable(hcx, hasher);
199             }
200             ty::Predicate::TypeOutlives(ref pred) => {
201                 pred.hash_stable(hcx, hasher);
202             }
203             ty::Predicate::Projection(ref pred) => {
204                 pred.hash_stable(hcx, hasher);
205             }
206             ty::Predicate::WellFormed(ty) => {
207                 ty.hash_stable(hcx, hasher);
208             }
209             ty::Predicate::ObjectSafe(def_id) => {
210                 def_id.hash_stable(hcx, hasher);
211             }
212             ty::Predicate::ClosureKind(def_id, closure_kind) => {
213                 def_id.hash_stable(hcx, hasher);
214                 closure_kind.hash_stable(hcx, hasher);
215             }
216         }
217     }
218 }
219
220 impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ty::AdtFlags {
221     fn hash_stable<W: StableHasherResult>(&self,
222                                           _: &mut StableHashingContext<'a, 'tcx>,
223                                           hasher: &mut StableHasher<W>) {
224         std_hash::Hash::hash(self, hasher);
225     }
226 }
227
228 impl_stable_hash_for!(struct ty::VariantDef {
229     did,
230     name,
231     discr,
232     fields,
233     ctor_kind
234 });
235
236 impl_stable_hash_for!(enum ty::VariantDiscr {
237     Explicit(def_id),
238     Relative(distance)
239 });
240
241 impl_stable_hash_for!(struct ty::FieldDef {
242     did,
243     name,
244     vis
245 });
246
247 impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>>
248 for ::middle::const_val::ConstVal<'tcx> {
249     fn hash_stable<W: StableHasherResult>(&self,
250                                           hcx: &mut StableHashingContext<'a, 'tcx>,
251                                           hasher: &mut StableHasher<W>) {
252         use middle::const_val::ConstVal;
253
254         mem::discriminant(self).hash_stable(hcx, hasher);
255
256         match *self {
257             ConstVal::Float(ref value) => {
258                 value.hash_stable(hcx, hasher);
259             }
260             ConstVal::Integral(ref value) => {
261                 value.hash_stable(hcx, hasher);
262             }
263             ConstVal::Str(ref value) => {
264                 value.hash_stable(hcx, hasher);
265             }
266             ConstVal::ByteStr(ref value) => {
267                 value.hash_stable(hcx, hasher);
268             }
269             ConstVal::Bool(value) => {
270                 value.hash_stable(hcx, hasher);
271             }
272             ConstVal::Function(def_id, substs) => {
273                 def_id.hash_stable(hcx, hasher);
274                 substs.hash_stable(hcx, hasher);
275             }
276             ConstVal::Struct(ref name_value_map) => {
277                 let mut values: Vec<(InternedString, &ConstVal)> =
278                     name_value_map.iter()
279                                   .map(|(name, val)| (name.as_str(), val))
280                                   .collect();
281
282                 values.sort_unstable_by_key(|&(ref name, _)| name.clone());
283                 values.hash_stable(hcx, hasher);
284             }
285             ConstVal::Tuple(ref value) => {
286                 value.hash_stable(hcx, hasher);
287             }
288             ConstVal::Array(ref value) => {
289                 value.hash_stable(hcx, hasher);
290             }
291             ConstVal::Repeat(ref value, times) => {
292                 value.hash_stable(hcx, hasher);
293                 times.hash_stable(hcx, hasher);
294             }
295             ConstVal::Char(value) => {
296                 value.hash_stable(hcx, hasher);
297             }
298         }
299     }
300 }
301
302 impl_stable_hash_for!(struct ty::ClosureSubsts<'tcx> { substs });
303
304 impl_stable_hash_for!(struct ty::GenericPredicates<'tcx> {
305     parent,
306     predicates
307 });
308
309 impl_stable_hash_for!(enum ty::Variance {
310     Covariant,
311     Invariant,
312     Contravariant,
313     Bivariant
314 });
315
316 impl_stable_hash_for!(enum ty::adjustment::CustomCoerceUnsized {
317     Struct(index)
318 });
319
320 impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ty::Generics {
321     fn hash_stable<W: StableHasherResult>(&self,
322                                           hcx: &mut StableHashingContext<'a, 'tcx>,
323                                           hasher: &mut StableHasher<W>) {
324         let ty::Generics {
325             parent,
326             parent_regions,
327             parent_types,
328             ref regions,
329             ref types,
330
331             // Reverse map to each `TypeParameterDef`'s `index` field, from
332             // `def_id.index` (`def_id.krate` is the same as the item's).
333             type_param_to_index: _, // Don't hash this
334             has_self,
335         } = *self;
336
337         parent.hash_stable(hcx, hasher);
338         parent_regions.hash_stable(hcx, hasher);
339         parent_types.hash_stable(hcx, hasher);
340         regions.hash_stable(hcx, hasher);
341         types.hash_stable(hcx, hasher);
342         has_self.hash_stable(hcx, hasher);
343     }
344 }
345
346 impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ty::RegionParameterDef {
347     fn hash_stable<W: StableHasherResult>(&self,
348                                           hcx: &mut StableHashingContext<'a, 'tcx>,
349                                           hasher: &mut StableHasher<W>) {
350         let ty::RegionParameterDef {
351             name,
352             def_id,
353             index,
354             issue_32330: _,
355             pure_wrt_drop
356         } = *self;
357
358         name.hash_stable(hcx, hasher);
359         def_id.hash_stable(hcx, hasher);
360         index.hash_stable(hcx, hasher);
361         pure_wrt_drop.hash_stable(hcx, hasher);
362     }
363 }
364
365 impl_stable_hash_for!(struct ty::TypeParameterDef {
366     name,
367     def_id,
368     index,
369     has_default,
370     object_lifetime_default,
371     pure_wrt_drop
372 });
373
374
375 impl<'a, 'tcx, T> HashStable<StableHashingContext<'a, 'tcx>>
376 for ::middle::resolve_lifetime::Set1<T>
377     where T: HashStable<StableHashingContext<'a, 'tcx>>
378 {
379     fn hash_stable<W: StableHasherResult>(&self,
380                                           hcx: &mut StableHashingContext<'a, 'tcx>,
381                                           hasher: &mut StableHasher<W>) {
382         use middle::resolve_lifetime::Set1;
383
384         mem::discriminant(self).hash_stable(hcx, hasher);
385         match *self {
386             Set1::Empty |
387             Set1::Many => {
388                 // Nothing to do.
389             }
390             Set1::One(ref value) => {
391                 value.hash_stable(hcx, hasher);
392             }
393         }
394     }
395 }
396
397 impl_stable_hash_for!(enum ::middle::resolve_lifetime::Region {
398     Static,
399     EarlyBound(index, decl),
400     LateBound(db_index, decl),
401     LateBoundAnon(db_index, anon_index),
402     Free(call_site_scope_data, decl)
403 });
404
405 impl_stable_hash_for!(struct ::middle::region::CallSiteScopeData {
406     fn_id,
407     body_id
408 });
409
410 impl_stable_hash_for!(struct ty::DebruijnIndex {
411     depth
412 });
413
414 impl_stable_hash_for!(enum ty::cast::CastKind {
415     CoercionCast,
416     PtrPtrCast,
417     PtrAddrCast,
418     AddrPtrCast,
419     NumericCast,
420     EnumCast,
421     PrimIntCast,
422     U8CharCast,
423     ArrayPtrCast,
424     FnPtrPtrCast,
425     FnPtrAddrCast
426 });
427
428 impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ::middle::region::CodeExtent
429 {
430     fn hash_stable<W: StableHasherResult>(&self,
431                                           hcx: &mut StableHashingContext<'a, 'tcx>,
432                                           hasher: &mut StableHasher<W>) {
433         hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
434             hcx.tcx().region_maps.code_extent_data(*self).hash_stable(hcx, hasher);
435         });
436     }
437 }
438
439 impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ::middle::region::CodeExtentData
440 {
441     fn hash_stable<W: StableHasherResult>(&self,
442                                           hcx: &mut StableHashingContext<'a, 'tcx>,
443                                           hasher: &mut StableHasher<W>) {
444         use middle::region::CodeExtentData;
445
446         mem::discriminant(self).hash_stable(hcx, hasher);
447         match *self {
448             CodeExtentData::Misc(node_id) |
449             CodeExtentData::DestructionScope(node_id) => {
450                 node_id.hash_stable(hcx, hasher);
451             }
452             CodeExtentData::CallSiteScope { fn_id, body_id } |
453             CodeExtentData::ParameterScope { fn_id, body_id } => {
454                 fn_id.hash_stable(hcx, hasher);
455                 body_id.hash_stable(hcx, hasher);
456             }
457             CodeExtentData::Remainder(block_remainder) => {
458                 block_remainder.hash_stable(hcx, hasher);
459             }
460         }
461     }
462 }
463
464 impl_stable_hash_for!(struct ::middle::region::BlockRemainder {
465     block,
466     first_statement_index
467 });
468
469 impl_stable_hash_for!(struct ty::adjustment::CoerceUnsizedInfo {
470     custom_kind
471 });
472
473 impl_stable_hash_for!(struct ty::FreeRegion {
474     scope,
475     bound_region
476 });
477
478 impl_stable_hash_for!(enum ty::BoundRegion {
479     BrAnon(index),
480     BrNamed(def_id, name),
481     BrFresh(index),
482     BrEnv
483 });
484
485 impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ty::TypeVariants<'tcx>
486 {
487     fn hash_stable<W: StableHasherResult>(&self,
488                                           hcx: &mut StableHashingContext<'a, 'tcx>,
489                                           hasher: &mut StableHasher<W>) {
490         use ty::TypeVariants::*;
491
492         mem::discriminant(self).hash_stable(hcx, hasher);
493         match *self {
494             TyBool  |
495             TyChar  |
496             TyStr   |
497             TyNever => {
498                 // Nothing more to hash.
499             }
500             TyInt(int_ty) => {
501                 int_ty.hash_stable(hcx, hasher);
502             }
503             TyUint(uint_ty) => {
504                 uint_ty.hash_stable(hcx, hasher);
505             }
506             TyFloat(float_ty)  => {
507                 float_ty.hash_stable(hcx, hasher);
508             }
509             TyAdt(adt_def, substs) => {
510                 adt_def.hash_stable(hcx, hasher);
511                 substs.hash_stable(hcx, hasher);
512             }
513             TyArray(inner_ty, len) => {
514                 inner_ty.hash_stable(hcx, hasher);
515                 len.hash_stable(hcx, hasher);
516             }
517             TySlice(inner_ty) => {
518                 inner_ty.hash_stable(hcx, hasher);
519             }
520             TyRawPtr(pointee_ty) => {
521                 pointee_ty.hash_stable(hcx, hasher);
522             }
523             TyRef(region, pointee_ty) => {
524                 region.hash_stable(hcx, hasher);
525                 pointee_ty.hash_stable(hcx, hasher);
526             }
527             TyFnDef(def_id, substs, ref sig) => {
528                 def_id.hash_stable(hcx, hasher);
529                 substs.hash_stable(hcx, hasher);
530                 sig.hash_stable(hcx, hasher);
531             }
532             TyFnPtr(ref sig) => {
533                 sig.hash_stable(hcx, hasher);
534             }
535             TyDynamic(ref existential_predicates, region) => {
536                 existential_predicates.hash_stable(hcx, hasher);
537                 region.hash_stable(hcx, hasher);
538             }
539             TyClosure(def_id, closure_substs) => {
540                 def_id.hash_stable(hcx, hasher);
541                 closure_substs.hash_stable(hcx, hasher);
542             }
543             TyTuple(inner_tys, from_diverging_type_var) => {
544                 inner_tys.hash_stable(hcx, hasher);
545                 from_diverging_type_var.hash_stable(hcx, hasher);
546             }
547             TyProjection(ref projection_ty) => {
548                 projection_ty.hash_stable(hcx, hasher);
549             }
550             TyAnon(def_id, substs) => {
551                 def_id.hash_stable(hcx, hasher);
552                 substs.hash_stable(hcx, hasher);
553             }
554             TyParam(param_ty) => {
555                 param_ty.hash_stable(hcx, hasher);
556             }
557
558             TyError     |
559             TyInfer(..) => {
560                 bug!("ty::TypeVariants::hash_stable() - Unexpected variant.")
561             }
562         }
563     }
564 }
565
566 impl_stable_hash_for!(struct ty::ParamTy {
567     idx,
568     name
569 });
570
571 impl_stable_hash_for!(struct ty::TypeAndMut<'tcx> {
572     ty,
573     mutbl
574 });
575
576 impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ty::ExistentialPredicate<'tcx>
577 {
578     fn hash_stable<W: StableHasherResult>(&self,
579                                           hcx: &mut StableHashingContext<'a, 'tcx>,
580                                           hasher: &mut StableHasher<W>) {
581         mem::discriminant(self).hash_stable(hcx, hasher);
582         match *self {
583             ty::ExistentialPredicate::Trait(ref trait_ref) => {
584                 trait_ref.hash_stable(hcx, hasher);
585             }
586             ty::ExistentialPredicate::Projection(ref projection) => {
587                 projection.hash_stable(hcx, hasher);
588             }
589             ty::ExistentialPredicate::AutoTrait(def_id) => {
590                 def_id.hash_stable(hcx, hasher);
591             }
592         }
593     }
594 }
595
596 impl_stable_hash_for!(struct ty::ExistentialTraitRef<'tcx> {
597     def_id,
598     substs
599 });
600
601 impl_stable_hash_for!(struct ty::ExistentialProjection<'tcx> {
602     trait_ref,
603     item_name,
604     ty
605 });
606
607
608 impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ty::TypeckTables<'tcx> {
609     fn hash_stable<W: StableHasherResult>(&self,
610                                           hcx: &mut StableHashingContext<'a, 'tcx>,
611                                           hasher: &mut StableHasher<W>) {
612         let ty::TypeckTables {
613             ref type_relative_path_defs,
614             ref node_types,
615             ref item_substs,
616             ref adjustments,
617             ref method_map,
618             ref upvar_capture_map,
619             ref closure_tys,
620             ref closure_kinds,
621             ref liberated_fn_sigs,
622             ref fru_field_types,
623
624             ref cast_kinds,
625
626             // FIXME(#41184): This is still ignored at the moment.
627             lints: _,
628             ref used_trait_imports,
629             tainted_by_errors,
630             ref free_region_map,
631         } = *self;
632
633         hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
634             ich::hash_stable_nodemap(hcx, hasher, type_relative_path_defs);
635             ich::hash_stable_nodemap(hcx, hasher, node_types);
636             ich::hash_stable_nodemap(hcx, hasher, item_substs);
637             ich::hash_stable_nodemap(hcx, hasher, adjustments);
638
639             ich::hash_stable_hashmap(hcx, hasher, method_map, |hcx, method_call| {
640                 let ty::MethodCall {
641                     expr_id,
642                     autoderef
643                 } = *method_call;
644
645                 let def_id = hcx.tcx().hir.local_def_id(expr_id);
646                 (hcx.def_path_hash(def_id), autoderef)
647             });
648
649             ich::hash_stable_hashmap(hcx, hasher, upvar_capture_map, |hcx, up_var_id| {
650                 let ty::UpvarId {
651                     var_id,
652                     closure_expr_id
653                 } = *up_var_id;
654
655                 let var_def_id = hcx.tcx().hir.local_def_id(var_id);
656                 let closure_def_id = hcx.tcx().hir.local_def_id(closure_expr_id);
657                 (hcx.def_path_hash(var_def_id), hcx.def_path_hash(closure_def_id))
658             });
659
660             ich::hash_stable_nodemap(hcx, hasher, closure_tys);
661             ich::hash_stable_nodemap(hcx, hasher, closure_kinds);
662             ich::hash_stable_nodemap(hcx, hasher, liberated_fn_sigs);
663             ich::hash_stable_nodemap(hcx, hasher, fru_field_types);
664             ich::hash_stable_nodemap(hcx, hasher, cast_kinds);
665
666             ich::hash_stable_hashset(hcx, hasher, used_trait_imports, |hcx, def_id| {
667                 hcx.def_path_hash(*def_id)
668             });
669
670             tainted_by_errors.hash_stable(hcx, hasher);
671             free_region_map.hash_stable(hcx, hasher);
672         })
673     }
674 }