Skip to content

Commit 8a4cbcf

Browse files
committed
Derive HashStable for HIR Expr and Ty.
1 parent b0047c1 commit 8a4cbcf

File tree

3 files changed

+3
-32
lines changed

3 files changed

+3
-32
lines changed

compiler/rustc_hir/src/hir.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1626,7 +1626,7 @@ pub struct AnonConst {
16261626
}
16271627

16281628
/// An expression.
1629-
#[derive(Debug)]
1629+
#[derive(Debug, HashStable_Generic)]
16301630
pub struct Expr<'hir> {
16311631
pub hir_id: HirId,
16321632
pub kind: ExprKind<'hir>,
@@ -2380,7 +2380,7 @@ impl TypeBinding<'_> {
23802380
}
23812381
}
23822382

2383-
#[derive(Debug)]
2383+
#[derive(Debug, HashStable_Generic)]
23842384
pub struct Ty<'hir> {
23852385
pub hir_id: HirId,
23862386
pub kind: TyKind<'hir>,

compiler/rustc_hir/src/stable_hash_impls.rs

+1-16
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
22

33
use crate::hir::{
4-
AttributeMap, BodyId, Crate, Expr, ForeignItemId, ImplItemId, ItemId, OwnerNodes, TraitItemId,
5-
Ty,
4+
AttributeMap, BodyId, Crate, ForeignItemId, ImplItemId, ItemId, OwnerNodes, TraitItemId,
65
};
76
use crate::hir_id::{HirId, ItemLocalId};
87
use rustc_span::def_id::DefPathHash;
@@ -14,8 +13,6 @@ pub trait HashStableContext:
1413
rustc_ast::HashStableContext + rustc_target::HashStableContext
1514
{
1615
fn hash_body_id(&mut self, _: BodyId, hasher: &mut StableHasher);
17-
fn hash_hir_expr(&mut self, _: &Expr<'_>, hasher: &mut StableHasher);
18-
fn hash_hir_ty(&mut self, _: &Ty<'_>, hasher: &mut StableHasher);
1916
}
2017

2118
impl<HirCtx: crate::HashStableContext> ToStableHashKey<HirCtx> for HirId {
@@ -96,18 +93,6 @@ impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for BodyId {
9693
// want to pick up on a reference changing its target, so we hash the NodeIds
9794
// in "DefPath Mode".
9895

99-
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for Expr<'_> {
100-
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
101-
hcx.hash_hir_expr(self, hasher)
102-
}
103-
}
104-
105-
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for Ty<'_> {
106-
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
107-
hcx.hash_hir_ty(self, hasher)
108-
}
109-
}
110-
11196
impl<'tcx, HirCtx: crate::HashStableContext> HashStable<HirCtx> for OwnerNodes<'tcx> {
11297
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
11398
// We ignore the `nodes` and `bodies` fields since these refer to information included in

compiler/rustc_query_system/src/ich/impls_hir.rs

-14
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,4 @@ impl<'ctx> rustc_hir::HashStableContext for StableHashingContext<'ctx> {
1919
}
2020
}
2121
}
22-
23-
fn hash_hir_expr(&mut self, expr: &hir::Expr<'_>, hasher: &mut StableHasher) {
24-
let hir::Expr { hir_id, ref span, ref kind } = *expr;
25-
hir_id.hash_stable(self, hasher);
26-
span.hash_stable(self, hasher);
27-
kind.hash_stable(self, hasher);
28-
}
29-
30-
fn hash_hir_ty(&mut self, ty: &hir::Ty<'_>, hasher: &mut StableHasher) {
31-
let hir::Ty { hir_id, ref kind, ref span } = *ty;
32-
hir_id.hash_stable(self, hasher);
33-
kind.hash_stable(self, hasher);
34-
span.hash_stable(self, hasher);
35-
}
3622
}

0 commit comments

Comments
 (0)