Skip to content

Commit ad7bb20

Browse files
committed
Stable Hash: Ignore all HirIds that just identify the node itself
1 parent 88ab2d8 commit ad7bb20

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

Diff for: compiler/rustc_hir/src/hir.rs

+20-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use crate::intravisit::FnKind;
3434

3535
#[derive(Debug, Copy, Clone, HashStable_Generic)]
3636
pub struct Lifetime {
37+
#[stable_hasher(ignore)]
3738
pub hir_id: HirId,
3839

3940
/// Either "`'a`", referring to a named lifetime definition,
@@ -214,6 +215,7 @@ impl Path<'_> {
214215
pub struct PathSegment<'hir> {
215216
/// The identifier portion of this path segment.
216217
pub ident: Ident,
218+
#[stable_hasher(ignore)]
217219
pub hir_id: HirId,
218220
pub res: Res,
219221

@@ -304,6 +306,7 @@ pub enum ConstArgKind<'hir> {
304306

305307
#[derive(Clone, Copy, Debug, HashStable_Generic)]
306308
pub struct InferArg {
309+
#[stable_hasher(ignore)]
307310
pub hir_id: HirId,
308311
pub span: Span,
309312
}
@@ -592,6 +595,7 @@ pub enum GenericParamKind<'hir> {
592595

593596
#[derive(Debug, Clone, Copy, HashStable_Generic)]
594597
pub struct GenericParam<'hir> {
598+
#[stable_hasher(ignore)]
595599
pub hir_id: HirId,
596600
pub def_id: LocalDefId,
597601
pub name: ParamName,
@@ -850,6 +854,7 @@ impl<'hir> Generics<'hir> {
850854
/// A single predicate in a where-clause.
851855
#[derive(Debug, Clone, Copy, HashStable_Generic)]
852856
pub struct WherePredicate<'hir> {
857+
#[stable_hasher(ignore)]
853858
pub hir_id: HirId,
854859
pub span: Span,
855860
pub kind: &'hir WherePredicateKind<'hir>,
@@ -1521,6 +1526,7 @@ impl fmt::Debug for DotDotPos {
15211526

15221527
#[derive(Debug, Clone, Copy, HashStable_Generic)]
15231528
pub struct PatExpr<'hir> {
1529+
#[stable_hasher(ignore)]
15241530
pub hir_id: HirId,
15251531
pub span: Span,
15261532
pub kind: PatExprKind<'hir>,
@@ -1610,6 +1616,7 @@ pub enum PatKind<'hir> {
16101616
/// A statement.
16111617
#[derive(Debug, Clone, Copy, HashStable_Generic)]
16121618
pub struct Stmt<'hir> {
1619+
#[stable_hasher(ignore)]
16131620
pub hir_id: HirId,
16141621
pub kind: StmtKind<'hir>,
16151622
pub span: Span,
@@ -1641,6 +1648,7 @@ pub struct LetStmt<'hir> {
16411648
pub init: Option<&'hir Expr<'hir>>,
16421649
/// Else block for a `let...else` binding.
16431650
pub els: Option<&'hir Block<'hir>>,
1651+
#[stable_hasher(ignore)]
16441652
pub hir_id: HirId,
16451653
pub span: Span,
16461654
/// Can be `ForLoopDesugar` if the `let` statement is part of a `for` loop
@@ -1937,6 +1945,7 @@ pub type Lit = Spanned<LitKind>;
19371945
/// `const N: usize = { ... }` with `tcx.hir().opt_const_param_default_param_def_id(..)`
19381946
#[derive(Copy, Clone, Debug, HashStable_Generic)]
19391947
pub struct AnonConst {
1948+
#[stable_hasher(ignore)]
19401949
pub hir_id: HirId,
19411950
pub def_id: LocalDefId,
19421951
pub body: BodyId,
@@ -1946,6 +1955,7 @@ pub struct AnonConst {
19461955
/// An inline constant expression `const { something }`.
19471956
#[derive(Copy, Clone, Debug, HashStable_Generic)]
19481957
pub struct ConstBlock {
1958+
#[stable_hasher(ignore)]
19491959
pub hir_id: HirId,
19501960
pub def_id: LocalDefId,
19511961
pub body: BodyId,
@@ -1961,6 +1971,7 @@ pub struct ConstBlock {
19611971
/// [rust lang reference]: https://doc.rust-lang.org/reference/expressions.html
19621972
#[derive(Debug, Clone, Copy, HashStable_Generic)]
19631973
pub struct Expr<'hir> {
1974+
#[stable_hasher(ignore)]
19641975
pub hir_id: HirId,
19651976
pub kind: ExprKind<'hir>,
19661977
pub span: Span,
@@ -2839,6 +2850,7 @@ pub enum ImplItemKind<'hir> {
28392850
/// * the `f(..): Bound` in `Trait<f(..): Bound>` (feature `return_type_notation`)
28402851
#[derive(Debug, Clone, Copy, HashStable_Generic)]
28412852
pub struct AssocItemConstraint<'hir> {
2853+
#[stable_hasher(ignore)]
28422854
pub hir_id: HirId,
28432855
pub ident: Ident,
28442856
pub gen_args: &'hir GenericArgs<'hir>,
@@ -2907,6 +2919,7 @@ impl<'hir> AssocItemConstraintKind<'hir> {
29072919

29082920
#[derive(Debug, Clone, Copy, HashStable_Generic)]
29092921
pub struct Ty<'hir> {
2922+
#[stable_hasher(ignore)]
29102923
pub hir_id: HirId,
29112924
pub kind: TyKind<'hir>,
29122925
pub span: Span,
@@ -3102,6 +3115,7 @@ pub struct UnsafeBinderTy<'hir> {
31023115

31033116
#[derive(Debug, Clone, Copy, HashStable_Generic)]
31043117
pub struct OpaqueTy<'hir> {
3118+
#[stable_hasher(ignore)]
31053119
pub hir_id: HirId,
31063120
pub def_id: LocalDefId,
31073121
pub bounds: GenericBounds<'hir>,
@@ -3138,6 +3152,7 @@ impl PreciseCapturingArg<'_> {
31383152
/// since resolve_bound_vars operates on `Lifetime`s.
31393153
#[derive(Debug, Clone, Copy, HashStable_Generic)]
31403154
pub struct PreciseCapturingNonLifetimeArg {
3155+
#[stable_hasher(ignore)]
31413156
pub hir_id: HirId,
31423157
pub ident: Ident,
31433158
pub res: Res,
@@ -3311,6 +3326,7 @@ impl InlineAsm<'_> {
33113326
/// Represents a parameter in a function header.
33123327
#[derive(Debug, Clone, Copy, HashStable_Generic)]
33133328
pub struct Param<'hir> {
3329+
#[stable_hasher(ignore)]
33143330
pub hir_id: HirId,
33153331
pub pat: &'hir Pat<'hir>,
33163332
pub ty_span: Span,
@@ -3468,6 +3484,7 @@ pub struct Variant<'hir> {
34683484
/// Name of the variant.
34693485
pub ident: Ident,
34703486
/// Id of the variant (not the constructor, see `VariantData::ctor_hir_id()`).
3487+
#[stable_hasher(ignore)]
34713488
pub hir_id: HirId,
34723489
pub def_id: LocalDefId,
34733490
/// Fields and constructor id of the variant.
@@ -3540,6 +3557,7 @@ pub struct FieldDef<'hir> {
35403557
pub span: Span,
35413558
pub vis_span: Span,
35423559
pub ident: Ident,
3560+
#[stable_hasher(ignore)]
35433561
pub hir_id: HirId,
35443562
pub def_id: LocalDefId,
35453563
pub ty: &'hir Ty<'hir>,
@@ -3564,11 +3582,11 @@ pub enum VariantData<'hir> {
35643582
/// A tuple variant.
35653583
///
35663584
/// E.g., `Bar(..)` as in `enum Foo { Bar(..) }`.
3567-
Tuple(&'hir [FieldDef<'hir>], HirId, LocalDefId),
3585+
Tuple(&'hir [FieldDef<'hir>], #[stable_hasher(ignore)] HirId, LocalDefId),
35683586
/// A unit variant.
35693587
///
35703588
/// E.g., `Bar = ..` as in `enum Foo { Bar = .. }`.
3571-
Unit(HirId, LocalDefId),
3589+
Unit(#[stable_hasher(ignore)] HirId, LocalDefId),
35723590
}
35733591

35743592
impl<'hir> VariantData<'hir> {

0 commit comments

Comments
 (0)