@@ -11,9 +11,7 @@ pub trait HashStableContext: syntax::HashStableContext + rustc_target::HashStabl
11
11
fn hash_def_id ( & mut self , _: DefId , hasher : & mut StableHasher ) ;
12
12
fn hash_hir_id ( & mut self , _: HirId , hasher : & mut StableHasher ) ;
13
13
fn hash_body_id ( & mut self , _: BodyId , hasher : & mut StableHasher ) ;
14
- fn hash_item_id ( & mut self , _: ItemId , hasher : & mut StableHasher ) ;
15
- fn hash_impl_item_id ( & mut self , _: ImplItemId , hasher : & mut StableHasher ) ;
16
- fn hash_trait_item_id ( & mut self , _: TraitItemId , hasher : & mut StableHasher ) ;
14
+ fn hash_reference_to_item ( & mut self , _: HirId , hasher : & mut StableHasher ) ;
17
15
fn hash_hir_mod ( & mut self , _: & Mod < ' _ > , hasher : & mut StableHasher ) ;
18
16
fn hash_hir_expr ( & mut self , _: & Expr < ' _ > , hasher : & mut StableHasher ) ;
19
17
fn hash_hir_ty ( & mut self , _: & Ty < ' _ > , hasher : & mut StableHasher ) ;
@@ -38,21 +36,28 @@ impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for BodyId {
38
36
}
39
37
}
40
38
39
+ // The following implementations of HashStable for `ItemId`, `TraitItemId`, and
40
+ // `ImplItemId` deserve special attention. Normally we do not hash `NodeId`s within
41
+ // the HIR, since they just signify a HIR nodes own path. But `ItemId` et al
42
+ // are used when another item in the HIR is *referenced* and we certainly
43
+ // want to pick up on a reference changing its target, so we hash the NodeIds
44
+ // in "DefPath Mode".
45
+
41
46
impl < HirCtx : crate :: HashStableContext > HashStable < HirCtx > for ItemId {
42
47
fn hash_stable ( & self , hcx : & mut HirCtx , hasher : & mut StableHasher ) {
43
- hcx. hash_item_id ( * self , hasher)
48
+ hcx. hash_reference_to_item ( self . id , hasher)
44
49
}
45
50
}
46
51
47
52
impl < HirCtx : crate :: HashStableContext > HashStable < HirCtx > for ImplItemId {
48
53
fn hash_stable ( & self , hcx : & mut HirCtx , hasher : & mut StableHasher ) {
49
- hcx. hash_impl_item_id ( * self , hasher)
54
+ hcx. hash_reference_to_item ( self . hir_id , hasher)
50
55
}
51
56
}
52
57
53
58
impl < HirCtx : crate :: HashStableContext > HashStable < HirCtx > for TraitItemId {
54
59
fn hash_stable ( & self , hcx : & mut HirCtx , hasher : & mut StableHasher ) {
55
- hcx. hash_trait_item_id ( * self , hasher)
60
+ hcx. hash_reference_to_item ( self . hir_id , hasher)
56
61
}
57
62
}
58
63
0 commit comments