Skip to content

Commit 28b0ed0

Browse files
committed
merge item id stable hashing functions
1 parent 4ff8fb9 commit 28b0ed0

File tree

2 files changed

+5
-26
lines changed

2 files changed

+5
-26
lines changed

src/librustc/ich/impls_hir.rs

+1-20
Original file line numberDiff line numberDiff line change
@@ -47,33 +47,14 @@ impl<'ctx> rustc_hir::HashStableContext for StableHashingContext<'ctx> {
4747
// want to pick up on a reference changing its target, so we hash the NodeIds
4848
// in "DefPath Mode".
4949

50-
fn hash_item_id(&mut self, id: hir::ItemId, hasher: &mut StableHasher) {
50+
fn hash_reference_to_item(&mut self, id: hir::HirId, hasher: &mut StableHasher) {
5151
let hcx = self;
52-
let hir::ItemId { id } = id;
5352

5453
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
5554
id.hash_stable(hcx, hasher);
5655
})
5756
}
5857

59-
fn hash_impl_item_id(&mut self, id: hir::ImplItemId, hasher: &mut StableHasher) {
60-
let hcx = self;
61-
let hir::ImplItemId { hir_id } = id;
62-
63-
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
64-
hir_id.hash_stable(hcx, hasher);
65-
})
66-
}
67-
68-
fn hash_trait_item_id(&mut self, id: hir::TraitItemId, hasher: &mut StableHasher) {
69-
let hcx = self;
70-
let hir::TraitItemId { hir_id } = id;
71-
72-
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
73-
hir_id.hash_stable(hcx, hasher);
74-
})
75-
}
76-
7758
fn hash_hir_mod(&mut self, module: &hir::Mod<'_>, hasher: &mut StableHasher) {
7859
let hcx = self;
7960
let hir::Mod { inner: ref inner_span, ref item_ids } = *module;

src/librustc_hir/stable_hash_impls.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ pub trait HashStableContext: syntax::HashStableContext + rustc_target::HashStabl
1111
fn hash_def_id(&mut self, _: DefId, hasher: &mut StableHasher);
1212
fn hash_hir_id(&mut self, _: HirId, hasher: &mut StableHasher);
1313
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);
1715
fn hash_hir_mod(&mut self, _: &Mod<'_>, hasher: &mut StableHasher);
1816
fn hash_hir_expr(&mut self, _: &Expr<'_>, hasher: &mut StableHasher);
1917
fn hash_hir_ty(&mut self, _: &Ty<'_>, hasher: &mut StableHasher);
@@ -40,19 +38,19 @@ impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for BodyId {
4038

4139
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for ItemId {
4240
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
43-
hcx.hash_item_id(*self, hasher)
41+
hcx.hash_reference_to_item(self.id, hasher)
4442
}
4543
}
4644

4745
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for ImplItemId {
4846
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
49-
hcx.hash_impl_item_id(*self, hasher)
47+
hcx.hash_reference_to_item(self.hir_id, hasher)
5048
}
5149
}
5250

5351
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for TraitItemId {
5452
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
55-
hcx.hash_trait_item_id(*self, hasher)
53+
hcx.hash_reference_to_item(self.hir_id, hasher)
5654
}
5755
}
5856

0 commit comments

Comments
 (0)