0000: 2f 2f 21 20 54 68 69 73 20 6d 6f 64 75 6c 65 20 //! This module
0010: 63 6f 6e 74 61 69 6e 73 20 60 48 61 73 68 53 74 contains `HashSt
0020: 61 62 6c 65 60 20 69 6d 70 6c 65 6d 65 6e 74 61 able` implementa
0030: 74 69 6f 6e 73 20 66 6f 72 20 76 61 72 69 6f 75 tions for variou
0040: 73 20 48 49 52 20 64 61 74 61 0a 2f 2f 21 20 74 s HIR data.//! t
0050: 79 70 65 73 20 69 6e 20 6e 6f 20 70 61 72 74 69 ypes in no parti
0060: 63 75 6c 61 72 20 6f 72 64 65 72 2e 0a 0a 75 73 cular order...us
0070: 65 20 63 72 61 74 65 3a 3a 68 69 72 3b 0a 75 73 e crate::hir;.us
0080: 65 20 63 72 61 74 65 3a 3a 68 69 72 3a 3a 6d 61 e crate::hir::ma
0090: 70 3a 3a 44 65 66 50 61 74 68 48 61 73 68 3b 0a p::DefPathHash;.
00a0: 75 73 65 20 63 72 61 74 65 3a 3a 68 69 72 3a 3a use crate::hir::
00b0: 64 65 66 5f 69 64 3a 3a 7b 44 65 66 49 64 2c 20 def_id::{DefId,
00c0: 4c 6f 63 61 6c 44 65 66 49 64 2c 20 43 72 61 74 LocalDefId, Crat
00d0: 65 4e 75 6d 2c 20 43 52 41 54 45 5f 44 45 46 5f eNum, CRATE_DEF_
00e0: 49 4e 44 45 58 7d 3b 0a 75 73 65 20 63 72 61 74 INDEX};.use crat
00f0: 65 3a 3a 69 63 68 3a 3a 7b 53 74 61 62 6c 65 48 e::ich::{StableH
0100: 61 73 68 69 6e 67 43 6f 6e 74 65 78 74 2c 20 4e ashingContext, N
0110: 6f 64 65 49 64 48 61 73 68 69 6e 67 4d 6f 64 65 odeIdHashingMode
0120: 2c 20 46 69 6e 67 65 72 70 72 69 6e 74 7d 3b 0a , Fingerprint};.
0130: 0a 75 73 65 20 72 75 73 74 63 5f 64 61 74 61 5f .use rustc_data_
0140: 73 74 72 75 63 74 75 72 65 73 3a 3a 73 74 61 62 structures::stab
0150: 6c 65 5f 68 61 73 68 65 72 3a 3a 7b 48 61 73 68 le_hasher::{Hash
0160: 53 74 61 62 6c 65 2c 20 54 6f 53 74 61 62 6c 65 Stable, ToStable
0170: 48 61 73 68 4b 65 79 2c 20 53 74 61 62 6c 65 48 HashKey, StableH
0180: 61 73 68 65 72 7d 3b 0a 75 73 65 20 73 6d 61 6c asher};.use smal
0190: 6c 76 65 63 3a 3a 53 6d 61 6c 6c 56 65 63 3b 0a lvec::SmallVec;.
01a0: 75 73 65 20 73 74 64 3a 3a 6d 65 6d 3b 0a 75 73 use std::mem;.us
01b0: 65 20 73 79 6e 74 61 78 3a 3a 61 74 74 72 3b 0a e syntax::attr;.
01c0: 0a 69 6d 70 6c 3c 27 61 3e 20 48 61 73 68 53 74 .impl<'a> HashSt
01d0: 61 62 6c 65 3c 53 74 61 62 6c 65 48 61 73 68 69 able<StableHashi
01e0: 6e 67 43 6f 6e 74 65 78 74 3c 27 61 3e 3e 20 66 ngContext<'a>> f
01f0: 6f 72 20 44 65 66 49 64 20 7b 0a 20 20 20 20 23 or DefId {. #
0200: 5b 69 6e 6c 69 6e 65 5d 0a 20 20 20 20 66 6e 20 [inline]. fn
0210: 68 61 73 68 5f 73 74 61 62 6c 65 28 26 73 65 6c hash_stable(&sel
0220: 66 2c 20 68 63 78 3a 20 26 6d 75 74 20 53 74 61 f, hcx: &mut Sta
0230: 62 6c 65 48 61 73 68 69 6e 67 43 6f 6e 74 65 78 bleHashingContex
0240: 74 3c 27 61 3e 2c 20 68 61 73 68 65 72 3a 20 26 t<'a>, hasher: &
0250: 6d 75 74 20 53 74 61 62 6c 65 48 61 73 68 65 72 mut StableHasher
0260: 29 20 7b 0a 20 20 20 20 20 20 20 20 68 63 78 2e ) {. hcx.
0270: 64 65 66 5f 70 61 74 68 5f 68 61 73 68 28 2a 73 def_path_hash(*s
0280: 65 6c 66 29 2e 68 61 73 68 5f 73 74 61 62 6c 65 elf).hash_stable
0290: 28 68 63 78 2c 20 68 61 73 68 65 72 29 3b 0a 20 (hcx, hasher);.
02a0: 20 20 20 7d 0a 7d 0a 0a 69 6d 70 6c 3c 27 61 3e }.}..impl<'a>
02b0: 20 54 6f 53 74 61 62 6c 65 48 61 73 68 4b 65 79 ToStableHashKey
02c0: 3c 53 74 61 62 6c 65 48 61 73 68 69 6e 67 43 6f <StableHashingCo
02d0: 6e 74 65 78 74 3c 27 61 3e 3e 20 66 6f 72 20 44 ntext<'a>> for D
02e0: 65 66 49 64 20 7b 0a 20 20 20 20 74 79 70 65 20 efId {. type
02f0: 4b 65 79 54 79 70 65 20 3d 20 44 65 66 50 61 74 KeyType = DefPat
0300: 68 48 61 73 68 3b 0a 0a 20 20 20 20 23 5b 69 6e hHash;.. #[in
0310: 6c 69 6e 65 5d 0a 20 20 20 20 66 6e 20 74 6f 5f line]. fn to_
0320: 73 74 61 62 6c 65 5f 68 61 73 68 5f 6b 65 79 28 stable_hash_key(
0330: 26 73 65 6c 66 2c 20 68 63 78 3a 20 26 53 74 61 &self, hcx: &Sta
0340: 62 6c 65 48 61 73 68 69 6e 67 43 6f 6e 74 65 78 bleHashingContex
0350: 74 3c 27 61 3e 29 20 2d 3e 20 44 65 66 50 61 74 t<'a>) -> DefPat
0360: 68 48 61 73 68 20 7b 0a 20 20 20 20 20 20 20 20 hHash {.
0370: 68 63 78 2e 64 65 66 5f 70 61 74 68 5f 68 61 73 hcx.def_path_has
0380: 68 28 2a 73 65 6c 66 29 0a 20 20 20 20 7d 0a 7d h(*self). }.}
0390: 0a 0a 69 6d 70 6c 3c 27 61 3e 20 48 61 73 68 53 ..impl<'a> HashS
03a0: 74 61 62 6c 65 3c 53 74 61 62 6c 65 48 61 73 68 table<StableHash
03b0: 69 6e 67 43 6f 6e 74 65 78 74 3c 27 61 3e 3e 20 ingContext<'a>>
03c0: 66 6f 72 20 4c 6f 63 61 6c 44 65 66 49 64 20 7b for LocalDefId {
03d0: 0a 20 20 20 20 23 5b 69 6e 6c 69 6e 65 5d 0a 20 . #[inline].
03e0: 20 20 20 66 6e 20 68 61 73 68 5f 73 74 61 62 6c fn hash_stabl
03f0: 65 28 26 73 65 6c 66 2c 20 68 63 78 3a 20 26 6d e(&self, hcx: &m
0400: 75 74 20 53 74 61 62 6c 65 48 61 73 68 69 6e 67 ut StableHashing
0410: 43 6f 6e 74 65 78 74 3c 27 61 3e 2c 20 68 61 73 Context<'a>, has
0420: 68 65 72 3a 20 26 6d 75 74 20 53 74 61 62 6c 65 her: &mut Stable
0430: 48 61 73 68 65 72 29 20 7b 0a 20 20 20 20 20 20 Hasher) {.
0440: 20 20 68 63 78 2e 64 65 66 5f 70 61 74 68 5f 68 hcx.def_path_h
0450: 61 73 68 28 73 65 6c 66 2e 74 6f 5f 64 65 66 5f ash(self.to_def_
0460: 69 64 28 29 29 2e 68 61 73 68 5f 73 74 61 62 6c id()).hash_stabl
0470: 65 28 68 63 78 2c 20 68 61 73 68 65 72 29 3b 0a e(hcx, hasher);.
0480: 20 20 20 20 7d 0a 7d 0a 0a 69 6d 70 6c 3c 27 61 }.}..impl<'a
0490: 3e 20 54 6f 53 74 61 62 6c 65 48 61 73 68 4b 65 > ToStableHashKe
04a0: 79 3c 53 74 61 62 6c 65 48 61 73 68 69 6e 67 43 y<StableHashingC
04b0: 6f 6e 74 65 78 74 3c 27 61 3e 3e 20 66 6f 72 20 ontext<'a>> for
04c0: 4c 6f 63 61 6c 44 65 66 49 64 20 7b 0a 20 20 20 LocalDefId {.
04d0: 20 74 79 70 65 20 4b 65 79 54 79 70 65 20 3d 20 type KeyType =
04e0: 44 65 66 50 61 74 68 48 61 73 68 3b 0a 0a 20 20 DefPathHash;..
04f0: 20 20 23 5b 69 6e 6c 69 6e 65 5d 0a 20 20 20 20 #[inline].
0500: 66 6e 20 74 6f 5f 73 74 61 62 6c 65 5f 68 61 73 fn to_stable_has
0510: 68 5f 6b 65 79 28 26 73 65 6c 66 2c 20 68 63 78 h_key(&self, hcx
0520: 3a 20 26 53 74 61 62 6c 65 48 61 73 68 69 6e 67 : &StableHashing
0530: 43 6f 6e 74 65 78 74 3c 27 61 3e 29 20 2d 3e 20 Context<'a>) ->
0540: 44 65 66 50 61 74 68 48 61 73 68 20 7b 0a 20 20 DefPathHash {.
0550: 20 20 20 20 20 20 68 63 78 2e 64 65 66 5f 70 61 hcx.def_pa
0560: 74 68 5f 68 61 73 68 28 73 65 6c 66 2e 74 6f 5f th_hash(self.to_
0570: 64 65 66 5f 69 64 28 29 29 0a 20 20 20 20 7d 0a def_id()). }.
0580: 7d 0a 0a 69 6d 70 6c 3c 27 61 3e 20 48 61 73 68 }..impl<'a> Hash
0590: 53 74 61 62 6c 65 3c 53 74 61 62 6c 65 48 61 73 Stable<StableHas
05a0: 68 69 6e 67 43 6f 6e 74 65 78 74 3c 27 61 3e 3e hingContext<'a>>
05b0: 20 66 6f 72 20 43 72 61 74 65 4e 75 6d 20 7b 0a for CrateNum {.
05c0: 20 20 20 20 23 5b 69 6e 6c 69 6e 65 5d 0a 20 20 #[inline].
05d0: 20 20 66 6e 20 68 61 73 68 5f 73 74 61 62 6c 65 fn hash_stable
05e0: 28 26 73 65 6c 66 2c 20 68 63 78 3a 20 26 6d 75 (&self, hcx: &mu
05f0: 74 20 53 74 61 62 6c 65 48 61 73 68 69 6e 67 43 t StableHashingC
0600: 6f 6e 74 65 78 74 3c 27 61 3e 2c 20 68 61 73 68 ontext<'a>, hash
0610: 65 72 3a 20 26 6d 75 74 20 53 74 61 62 6c 65 48 er: &mut StableH
0620: 61 73 68 65 72 29 20 7b 0a 20 20 20 20 20 20 20 asher) {.
0630: 20 68 63 78 2e 64 65 66 5f 70 61 74 68 5f 68 61 hcx.def_path_ha
0640: 73 68 28 44 65 66 49 64 20 7b 0a 20 20 20 20 20 sh(DefId {.
0650: 20 20 20 20 20 20 20 6b 72 61 74 65 3a 20 2a 73 krate: *s
0660: 65 6c 66 2c 0a 20 20 20 20 20 20 20 20 20 20 20 elf,.
0670: 20 69 6e 64 65 78 3a 20 43 52 41 54 45 5f 44 45 index: CRATE_DE
0680: 46 5f 49 4e 44 45 58 0a 20 20 20 20 20 20 20 20 F_INDEX.
0690: 7d 29 2e 68 61 73 68 5f 73 74 61 62 6c 65 28 68 }).hash_stable(h
06a0: 63 78 2c 20 68 61 73 68 65 72 29 3b 0a 20 20 20 cx, hasher);.
06b0: 20 7d 0a 7d 0a 0a 69 6d 70 6c 3c 27 61 3e 20 54 }.}..impl<'a> T
06c0: 6f 53 74 61 62 6c 65 48 61 73 68 4b 65 79 3c 53 oStableHashKey<S
06d0: 74 61 62 6c 65 48 61 73 68 69 6e 67 43 6f 6e 74 tableHashingCont
06e0: 65 78 74 3c 27 61 3e 3e 20 66 6f 72 20 43 72 61 ext<'a>> for Cra
06f0: 74 65 4e 75 6d 20 7b 0a 20 20 20 20 74 79 70 65 teNum {. type
0700: 20 4b 65 79 54 79 70 65 20 3d 20 44 65 66 50 61 KeyType = DefPa
0710: 74 68 48 61 73 68 3b 0a 0a 20 20 20 20 23 5b 69 thHash;.. #[i
0720: 6e 6c 69 6e 65 5d 0a 20 20 20 20 66 6e 20 74 6f nline]. fn to
0730: 5f 73 74 61 62 6c 65 5f 68 61 73 68 5f 6b 65 79 _stable_hash_key
0740: 28 26 73 65 6c 66 2c 20 68 63 78 3a 20 26 53 74 (&self, hcx: &St
0750: 61 62 6c 65 48 61 73 68 69 6e 67 43 6f 6e 74 65 ableHashingConte
0760: 78 74 3c 27 61 3e 29 20 2d 3e 20 44 65 66 50 61 xt<'a>) -> DefPa
0770: 74 68 48 61 73 68 20 7b 0a 20 20 20 20 20 20 20 thHash {.
0780: 20 6c 65 74 20 64 65 66 5f 69 64 20 3d 20 44 65 let def_id = De
0790: 66 49 64 20 7b 20 6b 72 61 74 65 3a 20 2a 73 65 fId { krate: *se
07a0: 6c 66 2c 20 69 6e 64 65 78 3a 20 43 52 41 54 45 lf, index: CRATE
07b0: 5f 44 45 46 5f 49 4e 44 45 58 20 7d 3b 0a 20 20 _DEF_INDEX };.
07c0: 20 20 20 20 20 20 64 65 66 5f 69 64 2e 74 6f 5f def_id.to_
07d0: 73 74 61 62 6c 65 5f 68 61 73 68 5f 6b 65 79 28 stable_hash_key(
07e0: 68 63 78 29 0a 20 20 20 20 7d 0a 7d 0a 0a 69 6d hcx). }.}..im
07f0: 70 6c 3c 27 61 3e 20 54 6f 53 74 61 62 6c 65 48 pl<'a> ToStableH
0800: 61 73 68 4b 65 79 3c 53 74 61 62 6c 65 48 61 73 ashKey<StableHas
0810: 68 69 6e 67 43 6f 6e 74 65 78 74 3c 27 61 3e 3e hingContext<'a>>
0820: 0a 66 6f 72 20 68 69 72 3a 3a 49 74 65 6d 4c 6f .for hir::ItemLo
0830: 63 61 6c 49 64 20 7b 0a 20 20 20 20 74 79 70 65 calId {. type
0840: 20 4b 65 79 54 79 70 65 20 3d 20 68 69 72 3a 3a KeyType = hir::
0850: 49 74 65 6d 4c 6f 63 61 6c 49 64 3b 0a 0a 20 20 ItemLocalId;..
0860: 20 20 23 5b 69 6e 6c 69 6e 65 5d 0a 20 20 20 20 #[inline].
0870: 66 6e 20 74 6f 5f 73 74 61 62 6c 65 5f 68 61 73 fn to_stable_has
0880: 68 5f 6b 65 79 28 26 73 65 6c 66 2c 0a 20 20 20 h_key(&self,.
0890: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
08a0: 20 20 20 20 20 20 20 5f 3a 20 26 53 74 61 62 6c _: &Stabl
08b0: 65 48 61 73 68 69 6e 67 43 6f 6e 74 65 78 74 3c eHashingContext<
08c0: 27 61 3e 29 0a 20 20 20 20 20 20 20 20 20 20 20 'a>).
08d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d -
08e0: 3e 20 68 69 72 3a 3a 49 74 65 6d 4c 6f 63 61 6c > hir::ItemLocal
08f0: 49 64 20 7b 0a 20 20 20 20 20 20 20 20 2a 73 65 Id {. *se
0900: 6c 66 0a 20 20 20 20 7d 0a 7d 0a 0a 2f 2f 20 54 lf. }.}..// T
0910: 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 69 6d 70 he following imp
0920: 6c 65 6d 65 6e 74 61 74 69 6f 6e 73 20 6f 66 20 lementations of
0930: 48 61 73 68 53 74 61 62 6c 65 20 66 6f 72 20 60 HashStable for `
0940: 49 74 65 6d 49 64 60 2c 20 60 54 72 61 69 74 49 ItemId`, `TraitI
0950: 74 65 6d 49 64 60 2c 20 61 6e 64 0a 2f 2f 20 60 temId`, and.// `
0960: 49 6d 70 6c 49 74 65 6d 49 64 60 20 64 65 73 65 ImplItemId` dese
0970: 72 76 65 20 73 70 65 63 69 61 6c 20 61 74 74 65 rve special atte
0980: 6e 74 69 6f 6e 2e 20 4e 6f 72 6d 61 6c 6c 79 20 ntion. Normally
0990: 77 65 20 64 6f 20 6e 6f 74 20 68 61 73 68 20 60 we do not hash `
09a0: 4e 6f 64 65 49 64 60 73 20 77 69 74 68 69 6e 0a NodeId`s within.
09b0: 2f 2f 20 74 68 65 20 48 49 52 2c 20 73 69 6e 63 // the HIR, sinc
09c0: 65 20 74 68 65 79 20 6a 75 73 74 20 73 69 67 6e e they just sign
09d0: 69 66 79 20 61 20 48 49 52 20 6e 6f 64 65 73 20 ify a HIR nodes
09e0: 6f 77 6e 20 70 61 74 68 2e 20 42 75 74 20 60 49 own path. But `I
09f0: 74 65 6d 49 64 60 20 65 74 20 61 6c 0a 2f 2f 20 temId` et al.//
0a00: 61 72 65 20 75 73 65 64 20 77 68 65 6e 20 61 6e are used when an
0a10: 6f 74 68 65 72 20 69 74 65 6d 20 69 6e 20 74 68 other item in th
0a20: 65 20 48 49 52 20 69 73 20 2a 72 65 66 65 72 65 e HIR is *refere
0a30: 6e 63 65 64 2a 20 61 6e 64 20 77 65 20 63 65 72 nced* and we cer
0a40: 74 61 69 6e 6c 79 0a 2f 2f 20 77 61 6e 74 20 74 tainly.// want t
0a50: 6f 20 70 69 63 6b 20 75 70 20 6f 6e 20 61 20 72 o pick up on a r
0a60: 65 66 65 72 65 6e 63 65 20 63 68 61 6e 67 69 6e eference changin
0a70: 67 20 69 74 73 20 74 61 72 67 65 74 2c 20 73 6f g its target, so
0a80: 20 77 65 20 68 61 73 68 20 74 68 65 20 4e 6f 64 we hash the Nod
0a90: 65 49 64 73 0a 2f 2f 20 69 6e 20 22 44 65 66 50 eIds.// in "DefP
0aa0: 61 74 68 20 4d 6f 64 65 22 2e 0a 0a 69 6d 70 6c ath Mode"...impl
0ab0: 3c 27 61 3e 20 48 61 73 68 53 74 61 62 6c 65 3c <'a> HashStable<
0ac0: 53 74 61 62 6c 65 48 61 73 68 69 6e 67 43 6f 6e StableHashingCon
0ad0: 74 65 78 74 3c 27 61 3e 3e 20 66 6f 72 20 68 69 text<'a>> for hi
0ae0: 72 3a 3a 49 74 65 6d 49 64 20 7b 0a 20 20 20 20 r::ItemId {.
0af0: 66 6e 20 68 61 73 68 5f 73 74 61 62 6c 65 28 26 fn hash_stable(&
0b00: 73 65 6c 66 2c 20 68 63 78 3a 20 26 6d 75 74 20 self, hcx: &mut
0b10: 53 74 61 62 6c 65 48 61 73 68 69 6e 67 43 6f 6e StableHashingCon
0b20: 74 65 78 74 3c 27 61 3e 2c 20 68 61 73 68 65 72 text<'a>, hasher
0b30: 3a 20 26 6d 75 74 20 53 74 61 62 6c 65 48 61 73 : &mut StableHas
0b40: 68 65 72 29 20 7b 0a 20 20 20 20 20 20 20 20 6c her) {. l
0b50: 65 74 20 68 69 72 3a 3a 49 74 65 6d 49 64 20 7b et hir::ItemId {
0b60: 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 64 0a . id.
0b70: 20 20 20 20 20 20 20 20 7d 20 3d 20 2a 73 65 6c } = *sel
0b80: 66 3b 0a 0a 20 20 20 20 20 20 20 20 68 63 78 2e f;.. hcx.
0b90: 77 69 74 68 5f 6e 6f 64 65 5f 69 64 5f 68 61 73 with_node_id_has
0ba0: 68 69 6e 67 5f 6d 6f 64 65 28 4e 6f 64 65 49 64 hing_mode(NodeId
0bb0: 48 61 73 68 69 6e 67 4d 6f 64 65 3a 3a 48 61 73 HashingMode::Has
0bc0: 68 44 65 66 50 61 74 68 2c 20 7c 68 63 78 7c 20 hDefPath, |hcx|
0bd0: 7b 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 64 {. id
0be0: 2e 68 61 73 68 5f 73 74 61 62 6c 65 28 68 63 78 .hash_stable(hcx
0bf0: 2c 20 68 61 73 68 65 72 29 3b 0a 20 20 20 20 20 , hasher);.
0c00: 20 20 20 7d 29 0a 20 20 20 20 7d 0a 7d 0a 0a 69 }). }.}..i
0c10: 6d 70 6c 3c 27 61 3e 20 48 61 73 68 53 74 61 62 mpl<'a> HashStab
0c20: 6c 65 3c 53 74 61 62 6c 65 48 61 73 68 69 6e 67 le<StableHashing
0c30: 43 6f 6e 74 65 78 74 3c 27 61 3e 3e 20 66 6f 72 Context<'a>> for
0c40: 20 68 69 72 3a 3a 54 72 61 69 74 49 74 65 6d 49 hir::TraitItemI
0c50: 64 20 7b 0a 20 20 20 20 66 6e 20 68 61 73 68 5f d {. fn hash_
0c60: 73 74 61 62 6c 65 28 26 73 65 6c 66 2c 20 68 63 stable(&self, hc
0c70: 78 3a 20 26 6d 75 74 20 53 74 61 62 6c 65 48 61 x: &mut StableHa
0c80: 73 68 69 6e 67 43 6f 6e 74 65 78 74 3c 27 61 3e shingContext<'a>
0c90: 2c 20 68 61 73 68 65 72 3a 20 26 6d 75 74 20 53 , hasher: &mut S
0ca0: 74 61 62 6c 65 48 61 73 68 65 72 29 20 7b 0a 20 tableHasher) {.
0cb0: 20 20 20 20 20 20 20 6c 65 74 20 68 69 72 3a 3a let hir::
0cc0: 54 72 61 69 74 49 74 65 6d 49 64 20 7b 0a 20 20 TraitItemId {.
0cd0: 20 20 20 20 20 20 20 20 20 20 68 69 72 5f 69 64 hir_id
0ce0: 0a 20 20 20 20 20 20 20 20 7d 20 3d 20 2a 20 73 . } = * s
0cf0: 65 6c 66 3b 0a 0a 20 20 20 20 20 20 20 20 68 63 elf;.. hc
0d00: 78 2e 77 69 74 68 5f 6e 6f 64 65 5f 69 64 5f 68 x.with_node_id_h
0d10: 61 73 68 69 6e 67 5f 6d 6f 64 65 28 4e 6f 64 65 ashing_mode(Node
0d20: 49 64 48 61 73 68 69 6e 67 4d 6f 64 65 3a 3a 48 IdHashingMode::H
0d30: 61 73 68 44 65 66 50 61 74 68 2c 20 7c 68 63 78 ashDefPath, |hcx
0d40: 7c 20 7b 0a 20 20 20 20 20 20 20 20 20 20 20 20 | {.
0d50: 68 69 72 5f 69 64 2e 68 61 73 68 5f 73 74 61 62 hir_id.hash_stab
0d60: 6c 65 28 68 63 78 2c 20 68 61 73 68 65 72 29 3b le(hcx, hasher);
0d70: 0a 20 20 20 20 20 20 20 20 7d 29 0a 20 20 20 20 . }).
0d80: 7d 0a 7d 0a 0a 69 6d 70 6c 3c 27 61 3e 20 48 61 }.}..impl<'a> Ha
0d90: 73 68 53 74 61 62 6c 65 3c 53 74 61 62 6c 65 48 shStable<StableH
0da0: 61 73 68 69 6e 67 43 6f 6e 74 65 78 74 3c 27 61 ashingContext<'a
0db0: 3e 3e 20 66 6f 72 20 68 69 72 3a 3a 49 6d 70 6c >> for hir::Impl
0dc0: 49 74 65 6d 49 64 20 7b 0a 20 20 20 20 66 6e 20 ItemId {. fn
0dd0: 68 61 73 68 5f 73 74 61 62 6c 65 28 26 73 65 6c hash_stable(&sel
0de0: 66 2c 20 68 63 78 3a 20 26 6d 75 74 20 53 74 61 f, hcx: &mut Sta
0df0: 62 6c 65 48 61 73 68 69 6e 67 43 6f 6e 74 65 78 bleHashingContex
0e00: 74 3c 27 61 3e 2c 20 68 61 73 68 65 72 3a 20 26 t<'a>, hasher: &
0e10: 6d 75 74 20 53 74 61 62 6c 65 48 61 73 68 65 72 mut StableHasher
0e20: 29 20 7b 0a 20 20 20 20 20 20 20 20 6c 65 74 20 ) {. let
0e30: 68 69 72 3a 3a 49 6d 70 6c 49 74 65 6d 49 64 20 hir::ImplItemId
0e40: 7b 0a 20 20 20 20 20 20 20 20 20 20 20 20 68 69 {. hi
0e50: 72 5f 69 64 0a 20 20 20 20 20 20 20 20 7d 20 3d r_id. } =
0e60: 20 2a 20 73 65 6c 66 3b 0a 0a 20 20 20 20 20 20 * self;..
0e70: 20 20 68 63 78 2e 77 69 74 68 5f 6e 6f 64 65 5f hcx.with_node_
0e80: 69 64 5f 68 61 73 68 69 6e 67 5f 6d 6f 64 65 28 id_hashing_mode(
0e90: 4e 6f 64 65 49 64 48 61 73 68 69 6e 67 4d 6f 64 NodeIdHashingMod
0ea0: 65 3a 3a 48 61 73 68 44 65 66 50 61 74 68 2c 20 e::HashDefPath,
0eb0: 7c 68 63 78 7c 20 7b 0a 20 20 20 20 20 20 20 20 |hcx| {.
0ec0: 20 20 20 20 68 69 72 5f 69 64 2e 68 61 73 68 5f hir_id.hash_
0ed0: 73 74 61 62 6c 65 28 68 63 78 2c 20 68 61 73 68 stable(hcx, hash
0ee0: 65 72 29 3b 0a 20 20 20 20 20 20 20 20 7d 29 0a er);. }).
0ef0: 20 20 20 20 7d 0a 7d 0a 0a 69 6d 70 6c 3c 27 61 }.}..impl<'a
0f00: 3e 20 48 61 73 68 53 74 61 62 6c 65 3c 53 74 61 > HashStable<Sta
0f10: 62 6c 65 48 61 73 68 69 6e 67 43 6f 6e 74 65 78 bleHashingContex
0f20: 74 3c 27 61 3e 3e 20 66 6f 72 20 68 69 72 3a 3a t<'a>> for hir::
0f30: 54 79 20 7b 0a 20 20 20 20 66 6e 20 68 61 73 68 Ty {. fn hash
0f40: 5f 73 74 61 62 6c 65 28 26 73 65 6c 66 2c 20 68 _stable(&self, h
0f50: 63 78 3a 20 26 6d 75 74 20 53 74 61 62 6c 65 48 cx: &mut StableH
0f60: 61 73 68 69 6e 67 43 6f 6e 74 65 78 74 3c 27 61 ashingContext<'a
0f70: 3e 2c 20 68 61 73 68 65 72 3a 20 26 6d 75 74 20 >, hasher: &mut
0f80: 53 74 61 62 6c 65 48 61 73 68 65 72 29 20 7b 0a StableHasher) {.
0f90: 20 20 20 20 20 20 20 20 68 63 78 2e 77 68 69 6c hcx.whil
0fa0: 65 5f 68 61 73 68 69 6e 67 5f 68 69 72 5f 62 6f e_hashing_hir_bo
0fb0: 64 69 65 73 28 74 72 75 65 2c 20 7c 68 63 78 7c dies(true, |hcx|
0fc0: 20 7b 0a 20 20 20 20 20 20 20 20 20 20 20 20 6c {. l
0fd0: 65 74 20 68 69 72 3a 3a 54 79 20 7b 0a 20 20 20 et hir::Ty {.
0fe0: 20 20 20 20 20 20 20 20 20 20 20 20 20 68 69 72 hir
0ff0: 5f 69 64 3a 20 5f 2c 0a 20 20 20 20 20 20 20 20 _id: _,.
1000: 20 20 20 20 20 20 20 20 72 65 66 20 6b 69 6e 64 ref kind
1010: 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ,.
1020: 20 20 72 65 66 20 73 70 61 6e 2c 0a 20 20 20 20 ref span,.
1030: 20 20 20 20 20 20 20 20 7d 20 3d 20 2a 73 65 6c } = *sel
1040: 66 3b 0a 0a 20 20 20 20 20 20 20 20 20 20 20 20 f;..
1050: 6b 69 6e 64 2e 68 61 73 68 5f 73 74 61 62 6c 65 kind.hash_stable
1060: 28 68 63 78 2c 20 68 61 73 68 65 72 29 3b 0a 20 (hcx, hasher);.
1070: 20 20 20 20 20 20 20 20 20 20 20 73 70 61 6e 2e span.
1080: 68 61 73 68 5f 73 74 61 62 6c 65 28 68 63 78 2c hash_stable(hcx,
1090: 20 68 61 73 68 65 72 29 3b 0a 20 20 20 20 20 20 hasher);.
10a0: 20 20 7d 29 0a 20 20 20 20 7d 0a 7d 0a 0a 69 6d }). }.}..im
10b0: 70 6c 3c 27 61 3e 20 48 61 73 68 53 74 61 62 6c pl<'a> HashStabl
10c0: 65 3c 53 74 61 62 6c 65 48 61 73 68 69 6e 67 43 e<StableHashingC
10d0: 6f 6e 74 65 78 74 3c 27 61 3e 3e 20 66 6f 72 20 ontext<'a>> for
10e0: 68 69 72 3a 3a 45 78 70 72 20 7b 0a 20 20 20 20 hir::Expr {.
10f0: 66 6e 20 68 61 73 68 5f 73 74 61 62 6c 65 28 26 fn hash_stable(&
1100: 73 65 6c 66 2c 20 68 63 78 3a 20 26 6d 75 74 20 self, hcx: &mut
1110: 53 74 61 62 6c 65 48 61 73 68 69 6e 67 43 6f 6e StableHashingCon
1120: 74 65 78 74 3c 27 61 3e 2c 20 68 61 73 68 65 72 text<'a>, hasher
1130: 3a 20 26 6d 75 74 20 53 74 61 62 6c 65 48 61 73 : &mut StableHas
1140: 68 65 72 29 20 7b 0a 20 20 20 20 20 20 20 20 68 her) {. h
1150: 63 78 2e 77 68 69 6c 65 5f 68 61 73 68 69 6e 67 cx.while_hashing
1160: 5f 68 69 72 5f 62 6f 64 69 65 73 28 74 72 75 65 _hir_bodies(true
1170: 2c 20 7c 68 63 78 7c 20 7b 0a 20 20 20 20 20 20 , |hcx| {.
1180: 20 20 20 20 20 20 6c 65 74 20 68 69 72 3a 3a 45 let hir::E
1190: 78 70 72 20 7b 0a 20 20 20 20 20 20 20 20 20 20 xpr {.
11a0: 20 20 20 20 20 20 68 69 72 5f 69 64 3a 20 5f 2c hir_id: _,
11b0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
11c0: 20 72 65 66 20 73 70 61 6e 2c 0a 20 20 20 20 20 ref span,.
11d0: 20 20 20 20 20 20 20 20 20 20 20 72 65 66 20 6b ref k
11e0: 69 6e 64 2c 0a 20 20 20 20 20 20 20 20 20 20 20 ind,.
11f0: 20 20 20 20 20 72 65 66 20 61 74 74 72 73 0a 20 ref attrs.
1200: 20 20 20 20 20 20 20 20 20 20 20 7d 20 3d 20 2a } = *
1210: 73 65 6c 66 3b 0a 0a 20 20 20 20 20 20 20 20 20 self;..
1220: 20 20 20 73 70 61 6e 2e 68 61 73 68 5f 73 74 61 span.hash_sta
1230: 62 6c 65 28 68 63 78 2c 20 68 61 73 68 65 72 29 ble(hcx, hasher)
1240: 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 6b 69 ;. ki
1250: 6e 64 2e 68 61 73 68 5f 73 74 61 62 6c 65 28 68 nd.hash_stable(h
1260: 63 78 2c 20 68 61 73 68 65 72 29 3b 0a 20 20 20 cx, hasher);.
1270: 20 20 20 20 20 20 20 20 20 61 74 74 72 73 2e 68 attrs.h
1280: 61 73 68 5f 73 74 61 62 6c 65 28 68 63 78 2c 20 ash_stable(hcx,
1290: 68 61 73 68 65 72 29 3b 0a 20 20 20 20 20 20 20 hasher);.
12a0: 20 7d 29 0a 20 20 20 20 7d 0a 7d 0a 0a 69 6d 70 }). }.}..imp
12b0: 6c 3c 27 61 3e 20 48 61 73 68 53 74 61 62 6c 65 l<'a> HashStable
12c0: 3c 53 74 61 62 6c 65 48 61 73 68 69 6e 67 43 6f <StableHashingCo
12d0: 6e 74 65 78 74 3c 27 61 3e 3e 20 66 6f 72 20 68 ntext<'a>> for h
12e0: 69 72 3a 3a 54 72 61 69 74 49 74 65 6d 20 7b 0a ir::TraitItem {.
12f0: 20 20 20 20 66 6e 20 68 61 73 68 5f 73 74 61 62 fn hash_stab
1300: 6c 65 28 26 73 65 6c 66 2c 20 68 63 78 3a 20 26 le(&self, hcx: &
1310: 6d 75 74 20 53 74 61 62 6c 65 48 61 73 68 69 6e mut StableHashin
1320: 67 43 6f 6e 74 65 78 74 3c 27 61 3e 2c 20 68 61 gContext<'a>, ha
1330: 73 68 65 72 3a 20 26 6d 75 74 20 53 74 61 62 6c sher: &mut Stabl
1340: 65 48 61 73 68 65 72 29 20 7b 0a 20 20 20 20 20 eHasher) {.
1350: 20 20 20 6c 65 74 20 68 69 72 3a 3a 54 72 61 69 let hir::Trai
1360: 74 49 74 65 6d 20 7b 0a 20 20 20 20 20 20 20 20 tItem {.
1370: 20 20 20 20 68 69 72 5f 69 64 3a 20 5f 2c 0a 20 hir_id: _,.
1380: 20 20 20 20 20 20 20 20 20 20 20 69 64 65 6e 74 ident
1390: 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 ,. re
13a0: 66 20 61 74 74 72 73 2c 0a 20 20 20 20 20 20 20 f attrs,.
13b0: 20 20 20 20 20 72 65 66 20 67 65 6e 65 72 69 63 ref generic
13c0: 73 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 s,. r
13d0: 65 66 20 6b 69 6e 64 2c 0a 20 20 20 20 20 20 20 ef kind,.
13e0: 20 20 20 20 20 73 70 61 6e 0a 20 20 20 20 20 20 span.
13f0: 20 20 7d 20 3d 20 2a 73 65 6c 66 3b 0a 0a 20 20 } = *self;..
1400: 20 20 20 20 20 20 68 63 78 2e 68 61 73 68 5f 68 hcx.hash_h
1410: 69 72 5f 69 74 65 6d 5f 6c 69 6b 65 28 7c 68 63 ir_item_like(|hc
1420: 78 7c 20 7b 0a 20 20 20 20 20 20 20 20 20 20 20 x| {.
1430: 20 69 64 65 6e 74 2e 6e 61 6d 65 2e 68 61 73 68 ident.name.hash
1440: 5f 73 74 61 62 6c 65 28 68 63 78 2c 20 68 61 73 _stable(hcx, has
1450: 68 65 72 29 3b 0a 20 20 20 20 20 20 20 20 20 20 her);.
1460: 20 20 61 74 74 72 73 2e 68 61 73 68 5f 73 74 61 attrs.hash_sta
1470: 62 6c 65 28 68 63 78 2c 20 68 61 73 68 65 72 29 ble(hcx, hasher)
1480: 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 67 65 ;. ge
1490: 6e 65 72 69 63 73 2e 68 61 73 68 5f 73 74 61 62 nerics.hash_stab
14a0: 6c 65 28 68 63 78 2c 20 68 61 73 68 65 72 29 3b le(hcx, hasher);
14b0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 6b 69 6e . kin
14c0: 64 2e 68 61 73 68 5f 73 74 61 62 6c 65 28 68 63 d.hash_stable(hc
14d0: 78 2c 20 68 61 73 68 65 72 29 3b 0a 20 20 20 20 x, hasher);.
14e0: 20 20 20 20 20 20 20 20 73 70 61 6e 2e 68 61 73 span.has
14f0: 68 5f 73 74 61 62 6c 65 28 68 63 78 2c 20 68 61 h_stable(hcx, ha
1500: 73 68 65 72 29 3b 0a 20 20 20 20 20 20 20 20 7d sher);. }
1510: 29 3b 0a 20 20 20 20 7d 0a 7d 0a 0a 0a 69 6d 70 );. }.}...imp
1520: 6c 3c 27 61 3e 20 48 61 73 68 53 74 61 62 6c 65 l<'a> HashStable
1530: 3c 53 74 61 62 6c 65 48 61 73 68 69 6e 67 43 6f <StableHashingCo
1540: 6e 74 65 78 74 3c 27 61 3e 3e 20 66 6f 72 20 68 ntext<'a>> for h
1550: 69 72 3a 3a 49 6d 70 6c 49 74 65 6d 20 7b 0a 20 ir::ImplItem {.
1560: 20 20 20 66 6e 20 68 61 73 68 5f 73 74 61 62 6c fn hash_stabl
1570: 65 28 26 73 65 6c 66 2c 20 68 63 78 3a 20 26 6d e(&self, hcx: &m
1580: 75 74 20 53 74 61 62 6c 65 48 61 73 68 69 6e 67 ut StableHashing
1590: 43 6f 6e 74 65 78 74 3c 27 61 3e 2c 20 68 61 73 Context<'a>, has
15a0: 68 65 72 3a 20 26 6d 75 74 20 53 74 61 62 6c 65 her: &mut Stable
15b0: 48 61 73 68 65 72 29 20 7b 0a 20 20 20 20 20 20 Hasher) {.
15c0: 20 20 6c 65 74 20 68 69 72 3a 3a 49 6d 70 6c 49 let hir::ImplI
15d0: 74 65 6d 20 7b 0a 20 20 20 20 20 20 20 20 20 20 tem {.
15e0: 20 20 68 69 72 5f 69 64 3a 20 5f 2c 0a 20 20 20 hir_id: _,.
15f0: 20 20 20 20 20 20 20 20 20 69 64 65 6e 74 2c 0a ident,.
1600: 20 20 20 20 20 20 20 20 20 20 20 20 72 65 66 20 ref
1610: 76 69 73 2c 0a 20 20 20 20 20 20 20 20 20 20 20 vis,.
1620: 20 64 65 66 61 75 6c 74 6e 65 73 73 2c 0a 20 20 defaultness,.
1630: 20 20 20 20 20 20 20 20 20 20 72 65 66 20 61 74 ref at
1640: 74 72 73 2c 0a 20 20 20 20 20 20 20 20 20 20 20 trs,.
1650: 20 72 65 66 20 67 65 6e 65 72 69 63 73 2c 0a 20 ref generics,.
1660: 20 20 20 20 20 20 20 20 20 20 20 72 65 66 20 6b ref k
1670: 69 6e 64 2c 0a 20 20 20 20 20 20 20 20 20 20 20 ind,.
1680: 20 73 70 61 6e 0a 20 20 20 20 20 20 20 20 7d 20 span. }
1690: 3d 20 2a 73 65 6c 66 3b 0a 0a 20 20 20 20 20 20 = *self;..
16a0: 20 20 68 63 78 2e 68 61 73 68 5f 68 69 72 5f 69 hcx.hash_hir_i
16b0: 74 65 6d 5f 6c 69 6b 65 28 7c 68 63 78 7c 20 7b tem_like(|hcx| {
16c0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 64 65 . ide
16d0: 6e 74 2e 6e 61 6d 65 2e 68 61 73 68 5f 73 74 61 nt.name.hash_sta
16e0: 62 6c 65 28 68 63 78 2c 20 68 61 73 68 65 72 29 ble(hcx, hasher)
16f0: 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 69 ;. vi
1700: 73 2e 68 61 73 68 5f 73 74 61 62 6c 65 28 68 63 s.hash_stable(hc
1710: 78 2c 20 68 61 73 68 65 72 29 3b 0a 20 20 20 20 x, hasher);.
1720: 20 20 20 20 20 20 20 20 64 65 66 61 75 6c 74 6e defaultn
1730: 65 73 73 2e 68 61 73 68 5f 73 74 61 62 6c 65 28 ess.hash_stable(
1740: 68 63 78 2c 20 68 61 73 68 65 72 29 3b 0a 20 20 hcx, hasher);.
1750: 20 20 20 20 20 20 20 20 20 20 61 74 74 72 73 2e attrs.
1760: 68 61 73 68 5f 73 74 61 62 6c 65 28 68 63 78 2c hash_stable(hcx,
1770: 20 68 61 73 68 65 72 29 3b 0a 20 20 20 20 20 20 hasher);.
1780: 20 20 20 20 20 20 67 65 6e 65 72 69 63 73 2e 68 generics.h
1790: 61 73 68 5f 73 74 61 62 6c 65 28 68 63 78 2c 20 ash_stable(hcx,
17a0: 68 61 73 68 65 72 29 3b 0a 20 20 20 20 20 20 20 hasher);.
17b0: 20 20 20 20 20 6b 69 6e 64 2e 68 61 73 68 5f 73 kind.hash_s
17c0: 74 61 62 6c 65 28 68 63 78 2c 20 68 61 73 68 65 table(hcx, hashe
17d0: 72 29 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 r);.
17e0: 73 70 61 6e 2e 68 61 73 68 5f 73 74 61 62 6c 65 span.hash_stable
17f0: 28 68 63 78 2c 20 68 61 73 68 65 72 29 3b 0a 20 (hcx, hasher);.
1800: 20 20 20 20 20 20 20 7d 29 3b 0a 20 20 20 20 7d });. }
1810: 0a 7d 0a 0a 69 6d 70 6c 3c 27 61 3e 20 48 61 73 .}..impl<'a> Has
1820: 68 53 74 61 62 6c 65 3c 53 74 61 62 6c 65 48 61 hStable<StableHa
1830: 73 68 69 6e 67 43 6f 6e 74 65 78 74 3c 27 61 3e shingContext<'a>
1840: 3e 20 66 6f 72 20 68 69 72 3a 3a 56 69 73 69 62 > for hir::Visib
1850: 69 6c 69 74 79 4b 69 6e 64 20 7b 0a 20 20 20 20 ilityKind {.
1860: 66 6e 20 68 61 73 68 5f 73 74 61 62 6c 65 28 26 fn hash_stable(&
1870: 73 65 6c 66 2c 20 68 63 78 3a 20 26 6d 75 74 20 self, hcx: &mut
1880: 53 74 61 62 6c 65 48 61 73 68 69 6e 67 43 6f 6e StableHashingCon
1890: 74 65 78 74 3c 27 61 3e 2c 20 68 61 73 68 65 72 text<'a>, hasher
18a0: 3a 20 26 6d 75 74 20 53 74 61 62 6c 65 48 61 73 : &mut StableHas
18b0: 68 65 72 29 20 7b 0a 20 20 20 20 20 20 20 20 6d her) {. m
18c0: 65 6d 3a 3a 64 69 73 63 72 69 6d 69 6e 61 6e 74 em::discriminant
18d0: 28 73 65 6c 66 29 2e 68 61 73 68 5f 73 74 61 62 (self).hash_stab
18e0: 6c 65 28 68 63 78 2c 20 68 61 73 68 65 72 29 3b le(hcx, hasher);
18f0: 0a 20 20 20 20 20 20 20 20 6d 61 74 63 68 20 2a . match *
1900: 73 65 6c 66 20 7b 0a 20 20 20 20 20 20 20 20 20 self {.
1910: 20 20 20 68 69 72 3a 3a 56 69 73 69 62 69 6c 69 hir::Visibili
1920: 74 79 4b 69 6e 64 3a 3a 50 75 62 6c 69 63 20 7c tyKind::Public |
1930: 0a 20 20 20 20 20 20 20 20 20 20 20 20 68 69 72 . hir
1940: 3a 3a 56 69 73 69 62 69 6c 69 74 79 4b 69 6e 64 ::VisibilityKind
1950: 3a 3a 49 6e 68 65 72 69 74 65 64 20 3d 3e 20 7b ::Inherited => {
1960: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
1970: 20 2f 2f 20 4e 6f 20 66 69 65 6c 64 73 20 74 6f // No fields to
1980: 20 68 61 73 68 2e 0a 20 20 20 20 20 20 20 20 20 hash..
1990: 20 20 20 7d 0a 20 20 20 20 20 20 20 20 20 20 20 }.
19a0: 20 68 69 72 3a 3a 56 69 73 69 62 69 6c 69 74 79 hir::Visibility
19b0: 4b 69 6e 64 3a 3a 43 72 61 74 65 28 73 75 67 61 Kind::Crate(suga
19c0: 72 29 20 3d 3e 20 7b 0a 20 20 20 20 20 20 20 20 r) => {.
19d0: 20 20 20 20 20 20 20 20 73 75 67 61 72 2e 68 61 sugar.ha
19e0: 73 68 5f 73 74 61 62 6c 65 28 68 63 78 2c 20 68 sh_stable(hcx, h
19f0: 61 73 68 65 72 29 3b 0a 20 20 20 20 20 20 20 20 asher);.
1a00: 20 20 20 20 7d 0a 20 20 20 20 20 20 20 20 20 20 }.
1a10: 20 20 68 69 72 3a 3a 56 69 73 69 62 69 6c 69 74 hir::Visibilit
1a20: 79 4b 69 6e 64 3a 3a 52 65 73 74 72 69 63 74 65 yKind::Restricte
1a30: 64 20 7b 20 72 65 66 20 70 61 74 68 2c 20 68 69 d { ref path, hi
1a40: 72 5f 69 64 20 7d 20 3d 3e 20 7b 0a 20 20 20 20 r_id } => {.
1a50: 20 20 20 20 20 20 20 20 20 20 20 20 68 63 78 2e hcx.
1a60: 77 69 74 68 5f 6e 6f 64 65 5f 69 64 5f 68 61 73 with_node_id_has
1a70: 68 69 6e 67 5f 6d 6f 64 65 28 4e 6f 64 65 49 64 hing_mode(NodeId
1a80: 48 61 73 68 69 6e 67 4d 6f 64 65 3a 3a 48 61 73 HashingMode::Has
1a90: 68 44 65 66 50 61 74 68 2c 20 7c 68 63 78 7c 20 hDefPath, |hcx|
1aa0: 7b 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 {.
1ab0: 20 20 20 20 20 20 68 69 72 5f 69 64 2e 68 61 73 hir_id.has
1ac0: 68 5f 73 74 61 62 6c 65 28 68 63 78 2c 20 68 61 h_stable(hcx, ha
1ad0: 73 68 65 72 29 3b 0a 20 20 20 20 20 20 20 20 20 sher);.
1ae0: 20 20 20 20 20 20 20 7d 29 3b 0a 20 20 20 20 20 });.
1af0: 20 20 20 20 20 20 20 20 20 20 20 70 61 74 68 2e path.
1b00: 68 61 73 68 5f 73 74 61 62 6c 65 28 68 63 78 2c hash_stable(hcx,
1b10: 20 68 61 73 68 65 72 29 3b 0a 20 20 20 20 20 20 hasher);.
1b20: 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 20 20 }.
1b30: 7d 0a 20 20 20 20 7d 0a 7d 0a 0a 69 6d 70 6c 3c }. }.}..impl<
1b40: 27 61 3e 20 48 61 73 68 53 74 61 62 6c 65 3c 53 'a> HashStable<S
1b50: 74 61 62 6c 65 48 61 73 68 69 6e 67 43 6f 6e 74 tableHashingCont
1b60: 65 78 74 3c 27 61 3e 3e 20 66 6f 72 20 68 69 72 ext<'a>> for hir
1b70: 3a 3a 4d 6f 64 20 7b 0a 20 20 20 20 66 6e 20 68 ::Mod {. fn h
1b80: 61 73 68 5f 73 74 61 62 6c 65 28 26 73 65 6c 66 ash_stable(&self
1b90: 2c 20 68 63 78 3a 20 26 6d 75 74 20 53 74 61 62 , hcx: &mut Stab
1ba0: 6c 65 48 61 73 68 69 6e 67 43 6f 6e 74 65 78 74 leHashingContext
1bb0: 3c 27 61 3e 2c 20 68 61 73 68 65 72 3a 20 26 6d <'a>, hasher: &m
1bc0: 75 74 20 53 74 61 62 6c 65 48 61 73 68 65 72 29 ut StableHasher)
1bd0: 20 7b 0a 20 20 20 20 20 20 20 20 6c 65 74 20 68 {. let h
1be0: 69 72 3a 3a 4d 6f 64 20 7b 0a 20 20 20 20 20 20 ir::Mod {.
1bf0: 20 20 20 20 20 20 69 6e 6e 65 72 3a 20 72 65 66 inner: ref
1c00: 20 69 6e 6e 65 72 5f 73 70 61 6e 2c 0a 20 20 20 inner_span,.
1c10: 20 20 20 20 20 20 20 20 20 72 65 66 20 69 74 65 ref ite
1c20: 6d 5f 69 64 73 2c 0a 20 20 20 20 20 20 20 20 7d m_ids,. }
1c30: 20 3d 20 2a 73 65 6c 66 3b 0a 0a 20 20 20 20 20 = *self;..
1c40: 20 20 20 69 6e 6e 65 72 5f 73 70 61 6e 2e 68 61 inner_span.ha
1c50: 73 68 5f 73 74 61 62 6c 65 28 68 63 78 2c 20 68 sh_stable(hcx, h
1c60: 61 73 68 65 72 29 3b 0a 0a 20 20 20 20 20 20 20 asher);..
1c70: 20 2f 2f 20 43 6f 6d 62 69 6e 69 6e 67 20 74 68 // Combining th
1c80: 65 20 60 44 65 66 50 61 74 68 48 61 73 68 60 73 e `DefPathHash`s
1c90: 20 64 69 72 65 63 74 6c 79 20 69 73 20 66 61 73 directly is fas
1ca0: 74 65 72 20 74 68 61 6e 20 66 65 65 64 69 6e 67 ter than feeding
1cb0: 20 74 68 65 6d 0a 20 20 20 20 20 20 20 20 2f 2f them. //
1cc0: 20 69 6e 74 6f 20 74 68 65 20 68 61 73 68 65 72 into the hasher
1cd0: 2e 20 42 65 63 61 75 73 65 20 77 65 20 75 73 65 . Because we use
1ce0: 20 61 20 63 6f 6d 6d 75 74 61 74 69 76 65 20 63 a commutative c
1cf0: 6f 6d 62 69 6e 65 2c 20 77 65 20 61 6c 73 6f 20 ombine, we also
1d00: 64 6f 6e 27 74 0a 20 20 20 20 20 20 20 20 2f 2f don't. //
1d10: 20 68 61 76 65 20 74 6f 20 73 6f 72 74 20 74 68 have to sort th
1d20: 65 20 61 72 72 61 79 2e 0a 20 20 20 20 20 20 20 e array..
1d30: 20 6c 65 74 20 69 74 65 6d 5f 69 64 73 5f 68 61 let item_ids_ha
1d40: 73 68 20 3d 20 69 74 65 6d 5f 69 64 73 0a 20 20 sh = item_ids.
1d50: 20 20 20 20 20 20 20 20 20 20 2e 69 74 65 72 28 .iter(
1d60: 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 2e 6d ). .m
1d70: 61 70 28 7c 69 64 7c 20 7b 0a 20 20 20 20 20 20 ap(|id| {.
1d80: 20 20 20 20 20 20 20 20 20 20 6c 65 74 20 28 64 let (d
1d90: 65 66 5f 70 61 74 68 5f 68 61 73 68 2c 20 6c 6f ef_path_hash, lo
1da0: 63 61 6c 5f 69 64 29 20 3d 20 69 64 2e 69 64 2e cal_id) = id.id.
1db0: 74 6f 5f 73 74 61 62 6c 65 5f 68 61 73 68 5f 6b to_stable_hash_k
1dc0: 65 79 28 68 63 78 29 3b 0a 20 20 20 20 20 20 20 ey(hcx);.
1dd0: 20 20 20 20 20 20 20 20 20 64 65 62 75 67 5f 61 debug_a
1de0: 73 73 65 72 74 5f 65 71 21 28 6c 6f 63 61 6c 5f ssert_eq!(local_
1df0: 69 64 2c 20 68 69 72 3a 3a 49 74 65 6d 4c 6f 63 id, hir::ItemLoc
1e00: 61 6c 49 64 3a 3a 66 72 6f 6d 5f 75 33 32 28 30 alId::from_u32(0
1e10: 29 29 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 ));.
1e20: 20 20 20 20 64 65 66 5f 70 61 74 68 5f 68 61 73 def_path_has
1e30: 68 2e 30 0a 20 20 20 20 20 20 20 20 20 20 20 20 h.0.
1e40: 7d 29 2e 66 6f 6c 64 28 46 69 6e 67 65 72 70 72 }).fold(Fingerpr
1e50: 69 6e 74 3a 3a 5a 45 52 4f 2c 20 7c 61 2c 20 62 int::ZERO, |a, b
1e60: 7c 20 7b 0a 20 20 20 20 20 20 20 20 20 20 20 20 | {.
1e70: 20 20 20 20 61 2e 63 6f 6d 62 69 6e 65 5f 63 6f a.combine_co
1e80: 6d 6d 75 74 61 74 69 76 65 28 62 29 0a 20 20 20 mmutative(b).
1e90: 20 20 20 20 20 20 20 20 20 7d 29 3b 0a 0a 20 20 });..
1ea0: 20 20 20 20 20 20 69 74 65 6d 5f 69 64 73 2e 6c item_ids.l
1eb0: 65 6e 28 29 2e 68 61 73 68 5f 73 74 61 62 6c 65 en().hash_stable
1ec0: 28 68 63 78 2c 20 68 61 73 68 65 72 29 3b 0a 20 (hcx, hasher);.
1ed0: 20 20 20 20 20 20 20 69 74 65 6d 5f 69 64 73 5f item_ids_
1ee0: 68 61 73 68 2e 68 61 73 68 5f 73 74 61 62 6c 65 hash.hash_stable
1ef0: 28 68 63 78 2c 20 68 61 73 68 65 72 29 3b 0a 20 (hcx, hasher);.
1f00: 20 20 20 7d 0a 7d 0a 0a 69 6d 70 6c 3c 27 61 3e }.}..impl<'a>
1f10: 20 48 61 73 68 53 74 61 62 6c 65 3c 53 74 61 62 HashStable<Stab
1f20: 6c 65 48 61 73 68 69 6e 67 43 6f 6e 74 65 78 74 leHashingContext
1f30: 3c 27 61 3e 3e 20 66 6f 72 20 68 69 72 3a 3a 49 <'a>> for hir::I
1f40: 74 65 6d 20 7b 0a 20 20 20 20 66 6e 20 68 61 73 tem {. fn has
1f50: 68 5f 73 74 61 62 6c 65 28 26 73 65 6c 66 2c 20 h_stable(&self,
1f60: 68 63 78 3a 20 26 6d 75 74 20 53 74 61 62 6c 65 hcx: &mut Stable
1f70: 48 61 73 68 69 6e 67 43 6f 6e 74 65 78 74 3c 27 HashingContext<'
1f80: 61 3e 2c 20 68 61 73 68 65 72 3a 20 26 6d 75 74 a>, hasher: &mut
1f90: 20 53 74 61 62 6c 65 48 61 73 68 65 72 29 20 7b StableHasher) {
1fa0: 0a 20 20 20 20 20 20 20 20 6c 65 74 20 68 69 72 . let hir
1fb0: 3a 3a 49 74 65 6d 20 7b 0a 20 20 20 20 20 20 20 ::Item {.
1fc0: 20 20 20 20 20 69 64 65 6e 74 2c 0a 20 20 20 20 ident,.
1fd0: 20 20 20 20 20 20 20 20 72 65 66 20 61 74 74 72 ref attr
1fe0: 73 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 68 s,. h
1ff0: 69 72 5f 69 64 3a 20 5f 2c 0a 20 20 20 20 20 20 ir_id: _,.
2000: 20 20 20 20 20 20 72 65 66 20 6b 69 6e 64 2c 0a ref kind,.
2010: 20 20 20 20 20 20 20 20 20 20 20 20 72 65 66 20 ref
2020: 76 69 73 2c 0a 20 20 20 20 20 20 20 20 20 20 20 vis,.
2030: 20 73 70 61 6e 0a 20 20 20 20 20 20 20 20 7d 20 span. }
2040: 3d 20 2a 73 65 6c 66 3b 0a 0a 20 20 20 20 20 20 = *self;..
2050: 20 20 68 63 78 2e 68 61 73 68 5f 68 69 72 5f 69 hcx.hash_hir_i
2060: 74 65 6d 5f 6c 69 6b 65 28 7c 68 63 78 7c 20 7b tem_like(|hcx| {
2070: 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 64 65 . ide
2080: 6e 74 2e 6e 61 6d 65 2e 68 61 73 68 5f 73 74 61 nt.name.hash_sta
2090: 62 6c 65 28 68 63 78 2c 20 68 61 73 68 65 72 29 ble(hcx, hasher)
20a0: 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 61 74 ;. at
20b0: 74 72 73 2e 68 61 73 68 5f 73 74 61 62 6c 65 28 trs.hash_stable(
20c0: 68 63 78 2c 20 68 61 73 68 65 72 29 3b 0a 20 20 hcx, hasher);.
20d0: 20 20 20 20 20 20 20 20 20 20 6b 69 6e 64 2e 68 kind.h
20e0: 61 73 68 5f 73 74 61 62 6c 65 28 68 63 78 2c 20 ash_stable(hcx,
20f0: 68 61 73 68 65 72 29 3b 0a 20 20 20 20 20 20 20 hasher);.
2100: 20 20 20 20 20 76 69 73 2e 68 61 73 68 5f 73 74 vis.hash_st
2110: 61 62 6c 65 28 68 63 78 2c 20 68 61 73 68 65 72 able(hcx, hasher
2120: 29 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 73 );. s
2130: 70 61 6e 2e 68 61 73 68 5f 73 74 61 62 6c 65 28 pan.hash_stable(
2140: 68 63 78 2c 20 68 61 73 68 65 72 29 3b 0a 20 20 hcx, hasher);.
2150: 20 20 20 20 20 20 7d 29 3b 0a 20 20 20 20 7d 0a });. }.
2160: 7d 0a 0a 69 6d 70 6c 3c 27 61 3e 20 48 61 73 68 }..impl<'a> Hash
2170: 53 74 61 62 6c 65 3c 53 74 61 62 6c 65 48 61 73 Stable<StableHas
2180: 68 69 6e 67 43 6f 6e 74 65 78 74 3c 27 61 3e 3e hingContext<'a>>
2190: 20 66 6f 72 20 68 69 72 3a 3a 42 6f 64 79 20 7b for hir::Body {
21a0: 0a 20 20 20 20 66 6e 20 68 61 73 68 5f 73 74 61 . fn hash_sta
21b0: 62 6c 65 28 26 73 65 6c 66 2c 20 68 63 78 3a 20 ble(&self, hcx:
21c0: 26 6d 75 74 20 53 74 61 62 6c 65 48 61 73 68 69 &mut StableHashi
21d0: 6e 67 43 6f 6e 74 65 78 74 3c 27 61 3e 2c 20 68 ngContext<'a>, h
21e0: 61 73 68 65 72 3a 20 26 6d 75 74 20 53 74 61 62 asher: &mut Stab
21f0: 6c 65 48 61 73 68 65 72 29 20 7b 0a 20 20 20 20 leHasher) {.
2200: 20 20 20 20 6c 65 74 20 68 69 72 3a 3a 42 6f 64 let hir::Bod
2210: 79 20 7b 0a 20 20 20 20 20 20 20 20 20 20 20 20 y {.
2220: 70 61 72 61 6d 73 2c 0a 20 20 20 20 20 20 20 20 params,.
2230: 20 20 20 20 76 61 6c 75 65 2c 0a 20 20 20 20 20 value,.
2240: 20 20 20 20 20 20 20 67 65 6e 65 72 61 74 6f 72 generator
2250: 5f 6b 69 6e 64 2c 0a 20 20 20 20 20 20 20 20 7d _kind,. }
2260: 20 3d 20 73 65 6c 66 3b 0a 0a 20 20 20 20 20 20 = self;..
2270: 20 20 68 63 78 2e 77 69 74 68 5f 6e 6f 64 65 5f hcx.with_node_
2280: 69 64 5f 68 61 73 68 69 6e 67 5f 6d 6f 64 65 28 id_hashing_mode(
2290: 4e 6f 64 65 49 64 48 61 73 68 69 6e 67 4d 6f 64 NodeIdHashingMod
22a0: 65 3a 3a 49 67 6e 6f 72 65 2c 20 7c 68 63 78 7c e::Ignore, |hcx|
22b0: 20 7b 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 {. p
22c0: 61 72 61 6d 73 2e 68 61 73 68 5f 73 74 61 62 6c arams.hash_stabl
22d0: 65 28 68 63 78 2c 20 68 61 73 68 65 72 29 3b 0a e(hcx, hasher);.
22e0: 20 20 20 20 20 20 20 20 20 20 20 20 76 61 6c 75 valu
22f0: 65 2e 68 61 73 68 5f 73 74 61 62 6c 65 28 68 63 e.hash_stable(hc
2300: 78 2c 20 68 61 73 68 65 72 29 3b 0a 20 20 20 20 x, hasher);.
2310: 20 20 20 20 20 20 20 20 67 65 6e 65 72 61 74 6f generato
2320: 72 5f 6b 69 6e 64 2e 68 61 73 68 5f 73 74 61 62 r_kind.hash_stab
2330: 6c 65 28 68 63 78 2c 20 68 61 73 68 65 72 29 3b le(hcx, hasher);
2340: 0a 20 20 20 20 20 20 20 20 7d 29 3b 0a 20 20 20 . });.
2350: 20 7d 0a 7d 0a 0a 69 6d 70 6c 3c 27 61 3e 20 54 }.}..impl<'a> T
2360: 6f 53 74 61 62 6c 65 48 61 73 68 4b 65 79 3c 53 oStableHashKey<S
2370: 74 61 62 6c 65 48 61 73 68 69 6e 67 43 6f 6e 74 tableHashingCont
2380: 65 78 74 3c 27 61 3e 3e 20 66 6f 72 20 68 69 72 ext<'a>> for hir
2390: 3a 3a 42 6f 64 79 49 64 20 7b 0a 20 20 20 20 74 ::BodyId {. t
23a0: 79 70 65 20 4b 65 79 54 79 70 65 20 3d 20 28 44 ype KeyType = (D
23b0: 65 66 50 61 74 68 48 61 73 68 2c 20 68 69 72 3a efPathHash, hir:
23c0: 3a 49 74 65 6d 4c 6f 63 61 6c 49 64 29 3b 0a 0a :ItemLocalId);..
23d0: 20 20 20 20 23 5b 69 6e 6c 69 6e 65 5d 0a 20 20 #[inline].
23e0: 20 20 66 6e 20 74 6f 5f 73 74 61 62 6c 65 5f 68 fn to_stable_h
23f0: 61 73 68 5f 6b 65 79 28 26 73 65 6c 66 2c 0a 20 ash_key(&self,.
2400: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2410: 20 20 20 20 20 20 20 20 20 68 63 78 3a 20 26 53 hcx: &S
2420: 74 61 62 6c 65 48 61 73 68 69 6e 67 43 6f 6e 74 tableHashingCont
2430: 65 78 74 3c 27 61 3e 29 0a 20 20 20 20 20 20 20 ext<'a>).
2440: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2450: 20 20 20 2d 3e 20 28 44 65 66 50 61 74 68 48 61 -> (DefPathHa
2460: 73 68 2c 20 68 69 72 3a 3a 49 74 65 6d 4c 6f 63 sh, hir::ItemLoc
2470: 61 6c 49 64 29 20 7b 0a 20 20 20 20 20 20 20 20 alId) {.
2480: 6c 65 74 20 68 69 72 3a 3a 42 6f 64 79 49 64 20 let hir::BodyId
2490: 7b 20 68 69 72 5f 69 64 20 7d 20 3d 20 2a 73 65 { hir_id } = *se
24a0: 6c 66 3b 0a 20 20 20 20 20 20 20 20 68 69 72 5f lf;. hir_
24b0: 69 64 2e 74 6f 5f 73 74 61 62 6c 65 5f 68 61 73 id.to_stable_has
24c0: 68 5f 6b 65 79 28 68 63 78 29 0a 20 20 20 20 7d h_key(hcx). }
24d0: 0a 7d 0a 0a 69 6d 70 6c 3c 27 61 3e 20 48 61 73 .}..impl<'a> Has
24e0: 68 53 74 61 62 6c 65 3c 53 74 61 62 6c 65 48 61 hStable<StableHa
24f0: 73 68 69 6e 67 43 6f 6e 74 65 78 74 3c 27 61 3e shingContext<'a>
2500: 3e 20 66 6f 72 20 68 69 72 3a 3a 64 65 66 5f 69 > for hir::def_i
2510: 64 3a 3a 44 65 66 49 6e 64 65 78 20 7b 0a 0a 20 d::DefIndex {..
2520: 20 20 20 66 6e 20 68 61 73 68 5f 73 74 61 62 6c fn hash_stabl
2530: 65 28 26 73 65 6c 66 2c 20 68 63 78 3a 20 26 6d e(&self, hcx: &m
2540: 75 74 20 53 74 61 62 6c 65 48 61 73 68 69 6e 67 ut StableHashing
2550: 43 6f 6e 74 65 78 74 3c 27 61 3e 2c 20 68 61 73 Context<'a>, has
2560: 68 65 72 3a 20 26 6d 75 74 20 53 74 61 62 6c 65 her: &mut Stable
2570: 48 61 73 68 65 72 29 20 7b 0a 20 20 20 20 20 20 Hasher) {.
2580: 20 20 68 63 78 2e 6c 6f 63 61 6c 5f 64 65 66 5f hcx.local_def_
2590: 70 61 74 68 5f 68 61 73 68 28 2a 73 65 6c 66 29 path_hash(*self)
25a0: 2e 68 61 73 68 5f 73 74 61 62 6c 65 28 68 63 78 .hash_stable(hcx
25b0: 2c 20 68 61 73 68 65 72 29 3b 0a 20 20 20 20 7d , hasher);. }
25c0: 0a 7d 0a 0a 69 6d 70 6c 3c 27 61 3e 20 54 6f 53 .}..impl<'a> ToS
25d0: 74 61 62 6c 65 48 61 73 68 4b 65 79 3c 53 74 61 tableHashKey<Sta
25e0: 62 6c 65 48 61 73 68 69 6e 67 43 6f 6e 74 65 78 bleHashingContex
25f0: 74 3c 27 61 3e 3e 20 66 6f 72 20 68 69 72 3a 3a t<'a>> for hir::
2600: 64 65 66 5f 69 64 3a 3a 44 65 66 49 6e 64 65 78 def_id::DefIndex
2610: 20 7b 0a 20 20 20 20 74 79 70 65 20 4b 65 79 54 {. type KeyT
2620: 79 70 65 20 3d 20 44 65 66 50 61 74 68 48 61 73 ype = DefPathHas
2630: 68 3b 0a 0a 20 20 20 20 23 5b 69 6e 6c 69 6e 65 h;.. #[inline
2640: 5d 0a 20 20 20 20 66 6e 20 74 6f 5f 73 74 61 62 ]. fn to_stab
2650: 6c 65 5f 68 61 73 68 5f 6b 65 79 28 26 73 65 6c le_hash_key(&sel
2660: 66 2c 20 68 63 78 3a 20 26 53 74 61 62 6c 65 48 f, hcx: &StableH
2670: 61 73 68 69 6e 67 43 6f 6e 74 65 78 74 3c 27 61 ashingContext<'a
2680: 3e 29 20 2d 3e 20 44 65 66 50 61 74 68 48 61 73 >) -> DefPathHas
2690: 68 20 7b 0a 20 20 20 20 20 20 20 20 20 68 63 78 h {. hcx
26a0: 2e 6c 6f 63 61 6c 5f 64 65 66 5f 70 61 74 68 5f .local_def_path_
26b0: 68 61 73 68 28 2a 73 65 6c 66 29 0a 20 20 20 20 hash(*self).
26c0: 7d 0a 7d 0a 0a 69 6d 70 6c 3c 27 61 3e 20 48 61 }.}..impl<'a> Ha
26d0: 73 68 53 74 61 62 6c 65 3c 53 74 61 62 6c 65 48 shStable<StableH
26e0: 61 73 68 69 6e 67 43 6f 6e 74 65 78 74 3c 27 61 ashingContext<'a
26f0: 3e 3e 20 66 6f 72 20 63 72 61 74 65 3a 3a 6d 69 >> for crate::mi
2700: 64 64 6c 65 3a 3a 6c 61 6e 67 5f 69 74 65 6d 73 ddle::lang_items
2710: 3a 3a 4c 61 6e 67 49 74 65 6d 20 7b 0a 20 20 20 ::LangItem {.
2720: 20 66 6e 20 68 61 73 68 5f 73 74 61 62 6c 65 28 fn hash_stable(
2730: 26 73 65 6c 66 2c 20 5f 3a 20 26 6d 75 74 20 53 &self, _: &mut S
2740: 74 61 62 6c 65 48 61 73 68 69 6e 67 43 6f 6e 74 tableHashingCont
2750: 65 78 74 3c 27 61 3e 2c 20 68 61 73 68 65 72 3a ext<'a>, hasher:
2760: 20 26 6d 75 74 20 53 74 61 62 6c 65 48 61 73 68 &mut StableHash
2770: 65 72 29 20 7b 0a 20 20 20 20 20 20 20 20 3a 3a er) {. ::
2780: 73 74 64 3a 3a 68 61 73 68 3a 3a 48 61 73 68 3a std::hash::Hash:
2790: 3a 68 61 73 68 28 73 65 6c 66 2c 20 68 61 73 68 :hash(self, hash
27a0: 65 72 29 3b 0a 20 20 20 20 7d 0a 7d 0a 0a 69 6d er);. }.}..im
27b0: 70 6c 3c 27 61 3e 20 48 61 73 68 53 74 61 62 6c pl<'a> HashStabl
27c0: 65 3c 53 74 61 62 6c 65 48 61 73 68 69 6e 67 43 e<StableHashingC
27d0: 6f 6e 74 65 78 74 3c 27 61 3e 3e 20 66 6f 72 20 ontext<'a>> for
27e0: 68 69 72 3a 3a 54 72 61 69 74 43 61 6e 64 69 64 hir::TraitCandid
27f0: 61 74 65 20 7b 0a 20 20 20 20 66 6e 20 68 61 73 ate {. fn has
2800: 68 5f 73 74 61 62 6c 65 28 26 73 65 6c 66 2c 20 h_stable(&self,
2810: 68 63 78 3a 20 26 6d 75 74 20 53 74 61 62 6c 65 hcx: &mut Stable
2820: 48 61 73 68 69 6e 67 43 6f 6e 74 65 78 74 3c 27 HashingContext<'
2830: 61 3e 2c 20 68 61 73 68 65 72 3a 20 26 6d 75 74 a>, hasher: &mut
2840: 20 53 74 61 62 6c 65 48 61 73 68 65 72 29 20 7b StableHasher) {
2850: 0a 20 20 20 20 20 20 20 20 68 63 78 2e 77 69 74 . hcx.wit
2860: 68 5f 6e 6f 64 65 5f 69 64 5f 68 61 73 68 69 6e h_node_id_hashin
2870: 67 5f 6d 6f 64 65 28 4e 6f 64 65 49 64 48 61 73 g_mode(NodeIdHas
2880: 68 69 6e 67 4d 6f 64 65 3a 3a 48 61 73 68 44 65 hingMode::HashDe
2890: 66 50 61 74 68 2c 20 7c 68 63 78 7c 20 7b 0a 20 fPath, |hcx| {.
28a0: 20 20 20 20 20 20 20 20 20 20 20 6c 65 74 20 68 let h
28b0: 69 72 3a 3a 54 72 61 69 74 43 61 6e 64 69 64 61 ir::TraitCandida
28c0: 74 65 20 7b 0a 20 20 20 20 20 20 20 20 20 20 20 te {.
28d0: 20 20 20 20 20 64 65 66 5f 69 64 2c 0a 20 20 20 def_id,.
28e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 69 6d 70 imp
28f0: 6f 72 74 5f 69 64 73 2c 0a 20 20 20 20 20 20 20 ort_ids,.
2900: 20 20 20 20 20 7d 20 3d 20 73 65 6c 66 3b 0a 0a } = self;..
2910: 20 20 20 20 20 20 20 20 20 20 20 20 64 65 66 5f def_
2920: 69 64 2e 68 61 73 68 5f 73 74 61 62 6c 65 28 68 id.hash_stable(h
2930: 63 78 2c 20 68 61 73 68 65 72 29 3b 0a 20 20 20 cx, hasher);.
2940: 20 20 20 20 20 20 20 20 20 69 6d 70 6f 72 74 5f import_
2950: 69 64 73 2e 68 61 73 68 5f 73 74 61 62 6c 65 28 ids.hash_stable(
2960: 68 63 78 2c 20 68 61 73 68 65 72 29 3b 0a 20 20 hcx, hasher);.
2970: 20 20 20 20 20 20 7d 29 3b 0a 20 20 20 20 7d 0a });. }.
2980: 7d 0a 0a 69 6d 70 6c 3c 27 61 3e 20 54 6f 53 74 }..impl<'a> ToSt
2990: 61 62 6c 65 48 61 73 68 4b 65 79 3c 53 74 61 62 ableHashKey<Stab
29a0: 6c 65 48 61 73 68 69 6e 67 43 6f 6e 74 65 78 74 leHashingContext
29b0: 3c 27 61 3e 3e 20 66 6f 72 20 68 69 72 3a 3a 54 <'a>> for hir::T
29c0: 72 61 69 74 43 61 6e 64 69 64 61 74 65 20 7b 0a raitCandidate {.
29d0: 20 20 20 20 74 79 70 65 20 4b 65 79 54 79 70 65 type KeyType
29e0: 20 3d 20 28 44 65 66 50 61 74 68 48 61 73 68 2c = (DefPathHash,
29f0: 20 53 6d 61 6c 6c 56 65 63 3c 5b 28 44 65 66 50 SmallVec<[(DefP
2a00: 61 74 68 48 61 73 68 2c 20 68 69 72 3a 3a 49 74 athHash, hir::It
2a10: 65 6d 4c 6f 63 61 6c 49 64 29 3b 20 31 5d 3e 29 emLocalId); 1]>)
2a20: 3b 0a 0a 20 20 20 20 66 6e 20 74 6f 5f 73 74 61 ;.. fn to_sta
2a30: 62 6c 65 5f 68 61 73 68 5f 6b 65 79 28 26 73 65 ble_hash_key(&se
2a40: 6c 66 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 lf,.
2a50: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 68 63 hc
2a60: 78 3a 20 26 53 74 61 62 6c 65 48 61 73 68 69 6e x: &StableHashin
2a70: 67 43 6f 6e 74 65 78 74 3c 27 61 3e 29 0a 20 20 gContext<'a>).
2a80: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2a90: 20 20 20 20 20 20 20 20 2d 3e 20 53 65 6c 66 3a -> Self:
2aa0: 3a 4b 65 79 54 79 70 65 20 7b 0a 20 20 20 20 20 :KeyType {.
2ab0: 20 20 20 6c 65 74 20 68 69 72 3a 3a 54 72 61 69 let hir::Trai
2ac0: 74 43 61 6e 64 69 64 61 74 65 20 7b 0a 20 20 20 tCandidate {.
2ad0: 20 20 20 20 20 20 20 20 20 64 65 66 5f 69 64 2c def_id,
2ae0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 6d 70 . imp
2af0: 6f 72 74 5f 69 64 73 2c 0a 20 20 20 20 20 20 20 ort_ids,.
2b00: 20 7d 20 3d 20 73 65 6c 66 3b 0a 0a 20 20 20 20 } = self;..
2b10: 20 20 20 20 6c 65 74 20 69 6d 70 6f 72 74 5f 6b let import_k
2b20: 65 79 73 20 3d 20 69 6d 70 6f 72 74 5f 69 64 73 eys = import_ids
2b30: 2e 69 74 65 72 28 29 2e 6d 61 70 28 7c 6e 6f 64 .iter().map(|nod
2b40: 65 5f 69 64 7c 20 68 63 78 2e 6e 6f 64 65 5f 74 e_id| hcx.node_t
2b50: 6f 5f 68 69 72 5f 69 64 28 2a 6e 6f 64 65 5f 69 o_hir_id(*node_i
2b60: 64 29 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 d)).
2b70: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2b80: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2e .
2b90: 6d 61 70 28 7c 68 69 72 5f 69 64 7c 20 28 68 63 map(|hir_id| (hc
2ba0: 78 2e 6c 6f 63 61 6c 5f 64 65 66 5f 70 61 74 68 x.local_def_path
2bb0: 5f 68 61 73 68 28 68 69 72 5f 69 64 2e 6f 77 6e _hash(hir_id.own
2bc0: 65 72 29 2c 0a 20 20 20 20 20 20 20 20 20 20 20 er),.
2bd0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2be0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2bf0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 68 h
2c00: 69 72 5f 69 64 2e 6c 6f 63 61 6c 5f 69 64 29 29 ir_id.local_id))
2c10: 2e 63 6f 6c 6c 65 63 74 28 29 3b 0a 20 20 20 20 .collect();.
2c20: 20 20 20 20 28 68 63 78 2e 64 65 66 5f 70 61 74 (hcx.def_pat
2c30: 68 5f 68 61 73 68 28 2a 64 65 66 5f 69 64 29 2c h_hash(*def_id),
2c40: 20 69 6d 70 6f 72 74 5f 6b 65 79 73 29 0a 20 20 import_keys).
2c50: 20 20 7d 0a 7d 0a 0a 69 6d 70 6c 3c 27 68 69 72 }.}..impl<'hir
2c60: 3e 20 48 61 73 68 53 74 61 62 6c 65 3c 53 74 61 > HashStable<Sta
2c70: 62 6c 65 48 61 73 68 69 6e 67 43 6f 6e 74 65 78 bleHashingContex
2c80: 74 3c 27 68 69 72 3e 3e 20 66 6f 72 20 61 74 74 t<'hir>> for att
2c90: 72 3a 3a 49 6e 6c 69 6e 65 41 74 74 72 20 7b 0a r::InlineAttr {.
2ca0: 20 20 20 20 66 6e 20 68 61 73 68 5f 73 74 61 62 fn hash_stab
2cb0: 6c 65 28 26 73 65 6c 66 2c 20 68 63 78 3a 20 26 le(&self, hcx: &
2cc0: 6d 75 74 20 53 74 61 62 6c 65 48 61 73 68 69 6e mut StableHashin
2cd0: 67 43 6f 6e 74 65 78 74 3c 27 68 69 72 3e 2c 20 gContext<'hir>,
2ce0: 68 61 73 68 65 72 3a 20 26 6d 75 74 20 53 74 61 hasher: &mut Sta
2cf0: 62 6c 65 48 61 73 68 65 72 29 20 7b 0a 20 20 20 bleHasher) {.
2d00: 20 20 20 20 20 6d 65 6d 3a 3a 64 69 73 63 72 69 mem::discri
2d10: 6d 69 6e 61 6e 74 28 73 65 6c 66 29 2e 68 61 73 minant(self).has
2d20: 68 5f 73 74 61 62 6c 65 28 68 63 78 2c 20 68 61 h_stable(hcx, ha
2d30: 73 68 65 72 29 3b 0a 20 20 20 20 7d 0a 7d 0a 0a sher);. }.}..
2d40: 69 6d 70 6c 3c 27 68 69 72 3e 20 48 61 73 68 53 impl<'hir> HashS
2d50: 74 61 62 6c 65 3c 53 74 61 62 6c 65 48 61 73 68 table<StableHash
2d60: 69 6e 67 43 6f 6e 74 65 78 74 3c 27 68 69 72 3e ingContext<'hir>
2d70: 3e 20 66 6f 72 20 61 74 74 72 3a 3a 4f 70 74 69 > for attr::Opti
2d80: 6d 69 7a 65 41 74 74 72 20 7b 0a 20 20 20 20 66 mizeAttr {. f
2d90: 6e 20 68 61 73 68 5f 73 74 61 62 6c 65 28 26 73 n hash_stable(&s
2da0: 65 6c 66 2c 20 68 63 78 3a 20 26 6d 75 74 20 53 elf, hcx: &mut S
2db0: 74 61 62 6c 65 48 61 73 68 69 6e 67 43 6f 6e 74 tableHashingCont
2dc0: 65 78 74 3c 27 68 69 72 3e 2c 20 68 61 73 68 65 ext<'hir>, hashe
2dd0: 72 3a 20 26 6d 75 74 20 53 74 61 62 6c 65 48 61 r: &mut StableHa
2de0: 73 68 65 72 29 20 7b 0a 20 20 20 20 20 20 20 20 sher) {.
2df0: 6d 65 6d 3a 3a 64 69 73 63 72 69 6d 69 6e 61 6e mem::discriminan
2e00: 74 28 73 65 6c 66 29 2e 68 61 73 68 5f 73 74 61 t(self).hash_sta
2e10: 62 6c 65 28 68 63 78 2c 20 68 61 73 68 65 72 29 ble(hcx, hasher)
2e20: 3b 0a 20 20 20 20 7d 0a 7d 0a ;. }.}.