Derive HashStable for HIR Expr and Ty.
This commit is contained in:
parent
b0047c18cb
commit
8a4cbcf220
3 changed files with 3 additions and 32 deletions
|
@ -1626,7 +1626,7 @@ pub struct AnonConst {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An expression.
|
/// An expression.
|
||||||
#[derive(Debug)]
|
#[derive(Debug, HashStable_Generic)]
|
||||||
pub struct Expr<'hir> {
|
pub struct Expr<'hir> {
|
||||||
pub hir_id: HirId,
|
pub hir_id: HirId,
|
||||||
pub kind: ExprKind<'hir>,
|
pub kind: ExprKind<'hir>,
|
||||||
|
@ -2380,7 +2380,7 @@ impl TypeBinding<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, HashStable_Generic)]
|
||||||
pub struct Ty<'hir> {
|
pub struct Ty<'hir> {
|
||||||
pub hir_id: HirId,
|
pub hir_id: HirId,
|
||||||
pub kind: TyKind<'hir>,
|
pub kind: TyKind<'hir>,
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
|
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
|
||||||
|
|
||||||
use crate::hir::{
|
use crate::hir::{
|
||||||
AttributeMap, BodyId, Crate, Expr, ForeignItemId, ImplItemId, ItemId, OwnerNodes, TraitItemId,
|
AttributeMap, BodyId, Crate, ForeignItemId, ImplItemId, ItemId, OwnerNodes, TraitItemId,
|
||||||
Ty,
|
|
||||||
};
|
};
|
||||||
use crate::hir_id::{HirId, ItemLocalId};
|
use crate::hir_id::{HirId, ItemLocalId};
|
||||||
use rustc_span::def_id::DefPathHash;
|
use rustc_span::def_id::DefPathHash;
|
||||||
|
@ -14,8 +13,6 @@ pub trait HashStableContext:
|
||||||
rustc_ast::HashStableContext + rustc_target::HashStableContext
|
rustc_ast::HashStableContext + rustc_target::HashStableContext
|
||||||
{
|
{
|
||||||
fn hash_body_id(&mut self, _: BodyId, hasher: &mut StableHasher);
|
fn hash_body_id(&mut self, _: BodyId, hasher: &mut StableHasher);
|
||||||
fn hash_hir_expr(&mut self, _: &Expr<'_>, hasher: &mut StableHasher);
|
|
||||||
fn hash_hir_ty(&mut self, _: &Ty<'_>, hasher: &mut StableHasher);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<HirCtx: crate::HashStableContext> ToStableHashKey<HirCtx> for HirId {
|
impl<HirCtx: crate::HashStableContext> ToStableHashKey<HirCtx> for HirId {
|
||||||
|
@ -96,18 +93,6 @@ impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for BodyId {
|
||||||
// want to pick up on a reference changing its target, so we hash the NodeIds
|
// want to pick up on a reference changing its target, so we hash the NodeIds
|
||||||
// in "DefPath Mode".
|
// in "DefPath Mode".
|
||||||
|
|
||||||
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for Expr<'_> {
|
|
||||||
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
|
|
||||||
hcx.hash_hir_expr(self, hasher)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for Ty<'_> {
|
|
||||||
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
|
|
||||||
hcx.hash_hir_ty(self, hasher)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'tcx, HirCtx: crate::HashStableContext> HashStable<HirCtx> for OwnerNodes<'tcx> {
|
impl<'tcx, HirCtx: crate::HashStableContext> HashStable<HirCtx> for OwnerNodes<'tcx> {
|
||||||
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
|
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
|
||||||
// We ignore the `nodes` and `bodies` fields since these refer to information included in
|
// We ignore the `nodes` and `bodies` fields since these refer to information included in
|
||||||
|
|
|
@ -19,18 +19,4 @@ impl<'ctx> rustc_hir::HashStableContext for StableHashingContext<'ctx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hash_hir_expr(&mut self, expr: &hir::Expr<'_>, hasher: &mut StableHasher) {
|
|
||||||
let hir::Expr { hir_id, ref span, ref kind } = *expr;
|
|
||||||
hir_id.hash_stable(self, hasher);
|
|
||||||
span.hash_stable(self, hasher);
|
|
||||||
kind.hash_stable(self, hasher);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn hash_hir_ty(&mut self, ty: &hir::Ty<'_>, hasher: &mut StableHasher) {
|
|
||||||
let hir::Ty { hir_id, ref kind, ref span } = *ty;
|
|
||||||
hir_id.hash_stable(self, hasher);
|
|
||||||
kind.hash_stable(self, hasher);
|
|
||||||
span.hash_stable(self, hasher);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue