Skip to content

Commit 20a451e

Browse files
cjgillotMark-Simulacrum
authored andcommitted
Remove NodeIdHashingMode.
1 parent 6a5f43d commit 20a451e

File tree

16 files changed

+54
-356
lines changed

16 files changed

+54
-356
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::cell::RefCell;
33
use rustc_data_structures::{
44
fingerprint::Fingerprint,
55
fx::FxHashMap,
6-
stable_hasher::{HashStable, NodeIdHashingMode, StableHasher},
6+
stable_hasher::{HashStable, StableHasher},
77
};
88
use rustc_middle::{
99
bug,
@@ -94,11 +94,7 @@ impl<'tcx> UniqueTypeId<'tcx> {
9494
pub fn generate_unique_id_string(self, tcx: TyCtxt<'tcx>) -> String {
9595
let mut hasher = StableHasher::new();
9696
let mut hcx = tcx.create_stable_hashing_context();
97-
hcx.while_hashing_spans(false, |hcx| {
98-
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
99-
self.hash_stable(hcx, &mut hasher);
100-
});
101-
});
97+
hcx.while_hashing_spans(false, |hcx| self.hash_stable(hcx, &mut hasher));
10298
hasher.finish::<Fingerprint>().to_hex()
10399
}
104100

compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use rustc_hir::{AsyncGeneratorKind, GeneratorKind, Mutability};
1919
use rustc_middle::ty::layout::{IntegerExt, TyAndLayout};
2020
use rustc_middle::ty::subst::{GenericArgKind, SubstsRef};
2121
use rustc_middle::ty::{self, ExistentialProjection, GeneratorSubsts, ParamEnv, Ty, TyCtxt};
22-
use rustc_query_system::ich::NodeIdHashingMode;
2322
use rustc_target::abi::{Integer, TagEncoding, Variants};
2423
use smallvec::SmallVec;
2524

@@ -704,11 +703,7 @@ fn push_const_param<'tcx>(tcx: TyCtxt<'tcx>, ct: ty::Const<'tcx>, output: &mut S
704703
// but we get a deterministic, virtually unique value for the constant.
705704
let hcx = &mut tcx.create_stable_hashing_context();
706705
let mut hasher = StableHasher::new();
707-
hcx.while_hashing_spans(false, |hcx| {
708-
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
709-
ct.val().hash_stable(hcx, &mut hasher);
710-
});
711-
});
706+
hcx.while_hashing_spans(false, |hcx| ct.val().hash_stable(hcx, &mut hasher));
712707
// Let's only emit 64 bits of the hash value. That should be plenty for
713708
// avoiding collisions and will make the emitted type names shorter.
714709
let hash: u64 = hasher.finish();

compiler/rustc_data_structures/src/stable_hasher.rs

-7
Original file line numberDiff line numberDiff line change
@@ -612,12 +612,6 @@ fn stable_hash_reduce<HCX, I, C, F>(
612612
}
613613
}
614614

615-
#[derive(PartialEq, Eq, Clone, Copy, Hash, Debug)]
616-
pub enum NodeIdHashingMode {
617-
Ignore,
618-
HashDefPath,
619-
}
620-
621615
/// Controls what data we do or not not hash.
622616
/// Whenever a `HashStable` implementation caches its
623617
/// result, it needs to include `HashingControls` as part
@@ -628,5 +622,4 @@ pub enum NodeIdHashingMode {
628622
#[derive(Clone, Hash, Eq, PartialEq, Debug)]
629623
pub struct HashingControls {
630624
pub hash_spans: bool,
631-
pub node_id_hashing_mode: NodeIdHashingMode,
632625
}

compiler/rustc_hir/src/hir.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ pub struct BodyId {
12641264
///
12651265
/// All bodies have an **owner**, which can be accessed via the HIR
12661266
/// map using `body_owner_def_id()`.
1267-
#[derive(Debug)]
1267+
#[derive(Debug, HashStable_Generic)]
12681268
pub struct Body<'hir> {
12691269
pub params: &'hir [Param<'hir>],
12701270
pub value: Expr<'hir>,
@@ -2024,7 +2024,7 @@ pub struct FnSig<'hir> {
20242024
// The bodies for items are stored "out of line", in a separate
20252025
// hashmap in the `Crate`. Here we just record the hir-id of the item
20262026
// so it can fetched later.
2027-
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Debug)]
2027+
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Debug, HashStable_Generic)]
20282028
pub struct TraitItemId {
20292029
pub def_id: LocalDefId,
20302030
}
@@ -2041,7 +2041,7 @@ impl TraitItemId {
20412041
/// possibly including a default implementation. A trait item is
20422042
/// either required (meaning it doesn't have an implementation, just a
20432043
/// signature) or provided (meaning it has a default implementation).
2044-
#[derive(Debug)]
2044+
#[derive(Debug, HashStable_Generic)]
20452045
pub struct TraitItem<'hir> {
20462046
pub ident: Ident,
20472047
pub def_id: LocalDefId,
@@ -2087,7 +2087,7 @@ pub enum TraitItemKind<'hir> {
20872087
// The bodies for items are stored "out of line", in a separate
20882088
// hashmap in the `Crate`. Here we just record the hir-id of the item
20892089
// so it can fetched later.
2090-
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Debug)]
2090+
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Debug, HashStable_Generic)]
20912091
pub struct ImplItemId {
20922092
pub def_id: LocalDefId,
20932093
}
@@ -2101,7 +2101,7 @@ impl ImplItemId {
21012101
}
21022102

21032103
/// Represents anything within an `impl` block.
2104-
#[derive(Debug)]
2104+
#[derive(Debug, HashStable_Generic)]
21052105
pub struct ImplItem<'hir> {
21062106
pub ident: Ident,
21072107
pub def_id: LocalDefId,
@@ -2602,7 +2602,7 @@ pub struct PolyTraitRef<'hir> {
26022602

26032603
pub type Visibility<'hir> = Spanned<VisibilityKind<'hir>>;
26042604

2605-
#[derive(Copy, Clone, Debug)]
2605+
#[derive(Copy, Clone, Debug, HashStable_Generic)]
26062606
pub enum VisibilityKind<'hir> {
26072607
Public,
26082608
Crate(CrateSugar),
@@ -2678,7 +2678,7 @@ impl<'hir> VariantData<'hir> {
26782678
// The bodies for items are stored "out of line", in a separate
26792679
// hashmap in the `Crate`. Here we just record the hir-id of the item
26802680
// so it can fetched later.
2681-
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Debug, Hash)]
2681+
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Debug, Hash, HashStable_Generic)]
26822682
pub struct ItemId {
26832683
pub def_id: LocalDefId,
26842684
}
@@ -2694,7 +2694,7 @@ impl ItemId {
26942694
/// An item
26952695
///
26962696
/// The name might be a dummy name in case of anonymous items
2697-
#[derive(Debug)]
2697+
#[derive(Debug, HashStable_Generic)]
26982698
pub struct Item<'hir> {
26992699
pub ident: Ident,
27002700
pub def_id: LocalDefId,
@@ -2925,7 +2925,7 @@ pub enum AssocItemKind {
29252925
// The bodies for items are stored "out of line", in a separate
29262926
// hashmap in the `Crate`. Here we just record the hir-id of the item
29272927
// so it can fetched later.
2928-
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Debug)]
2928+
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Debug, HashStable_Generic)]
29292929
pub struct ForeignItemId {
29302930
pub def_id: LocalDefId,
29312931
}
@@ -2951,7 +2951,7 @@ pub struct ForeignItemRef {
29512951
pub span: Span,
29522952
}
29532953

2954-
#[derive(Debug)]
2954+
#[derive(Debug, HashStable_Generic)]
29552955
pub struct ForeignItem<'hir> {
29562956
pub ident: Ident,
29572957
pub kind: ForeignItemKind<'hir>,
@@ -2993,7 +2993,7 @@ pub struct Upvar {
29932993
// The TraitCandidate's import_ids is empty if the trait is defined in the same module, and
29942994
// has length > 0 if the trait is found through an chain of imports, starting with the
29952995
// import/use statement in the scope where the trait is used.
2996-
#[derive(Encodable, Decodable, Clone, Debug)]
2996+
#[derive(Encodable, Decodable, Clone, Debug, HashStable_Generic)]
29972997
pub struct TraitCandidate {
29982998
pub def_id: DefId,
29992999
pub import_ids: SmallVec<[LocalDefId; 1]>,

compiler/rustc_hir/src/hir_id.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::fmt;
1212
/// incremental compilation where we have to persist things through changes to
1313
/// the code base.
1414
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
15-
#[derive(Encodable, Decodable)]
15+
#[derive(Encodable, Decodable, HashStable_Generic)]
1616
#[rustc_pass_by_value]
1717
pub struct HirId {
1818
pub owner: LocalDefId,
+2-102
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
22

33
use crate::hir::{
4-
AttributeMap, BodyId, Crate, Expr, ForeignItem, ForeignItemId, ImplItem, ImplItemId, Item,
5-
ItemId, OwnerNodes, TraitCandidate, TraitItem, TraitItemId, Ty, VisibilityKind,
4+
AttributeMap, BodyId, Crate, Expr, ForeignItemId, ImplItemId, ItemId, OwnerNodes, TraitItemId,
5+
Ty,
66
};
77
use crate::hir_id::{HirId, ItemLocalId};
88
use rustc_span::def_id::DefPathHash;
@@ -13,14 +13,9 @@ use rustc_span::def_id::DefPathHash;
1313
pub trait HashStableContext:
1414
rustc_ast::HashStableContext + rustc_target::HashStableContext
1515
{
16-
fn hash_hir_id(&mut self, _: HirId, hasher: &mut StableHasher);
1716
fn hash_body_id(&mut self, _: BodyId, hasher: &mut StableHasher);
18-
fn hash_reference_to_item(&mut self, _: HirId, hasher: &mut StableHasher);
1917
fn hash_hir_expr(&mut self, _: &Expr<'_>, hasher: &mut StableHasher);
2018
fn hash_hir_ty(&mut self, _: &Ty<'_>, hasher: &mut StableHasher);
21-
fn hash_hir_visibility_kind(&mut self, _: &VisibilityKind<'_>, hasher: &mut StableHasher);
22-
fn hash_hir_item_like<F: FnOnce(&mut Self)>(&mut self, f: F);
23-
fn hash_hir_trait_candidate(&mut self, _: &TraitCandidate, hasher: &mut StableHasher);
2419
}
2520

2621
impl<HirCtx: crate::HashStableContext> ToStableHashKey<HirCtx> for HirId {
@@ -88,12 +83,6 @@ impl<HirCtx: crate::HashStableContext> ToStableHashKey<HirCtx> for ForeignItemId
8883
}
8984
}
9085

91-
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for HirId {
92-
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
93-
hcx.hash_hir_id(*self, hasher)
94-
}
95-
}
96-
9786
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for BodyId {
9887
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
9988
hcx.hash_body_id(*self, hasher)
@@ -107,30 +96,6 @@ impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for BodyId {
10796
// want to pick up on a reference changing its target, so we hash the NodeIds
10897
// in "DefPath Mode".
10998

110-
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for ItemId {
111-
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
112-
hcx.hash_reference_to_item(self.hir_id(), hasher)
113-
}
114-
}
115-
116-
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for ForeignItemId {
117-
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
118-
hcx.hash_reference_to_item(self.hir_id(), hasher)
119-
}
120-
}
121-
122-
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for ImplItemId {
123-
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
124-
hcx.hash_reference_to_item(self.hir_id(), hasher)
125-
}
126-
}
127-
128-
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for TraitItemId {
129-
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
130-
hcx.hash_reference_to_item(self.hir_id(), hasher)
131-
}
132-
}
133-
13499
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for Expr<'_> {
135100
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
136101
hcx.hash_hir_expr(self, hasher)
@@ -143,65 +108,6 @@ impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for Ty<'_> {
143108
}
144109
}
145110

146-
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for VisibilityKind<'_> {
147-
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
148-
hcx.hash_hir_visibility_kind(self, hasher)
149-
}
150-
}
151-
152-
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for TraitItem<'_> {
153-
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
154-
let TraitItem { def_id: _, ident, ref generics, ref kind, span } = *self;
155-
156-
hcx.hash_hir_item_like(|hcx| {
157-
ident.name.hash_stable(hcx, hasher);
158-
generics.hash_stable(hcx, hasher);
159-
kind.hash_stable(hcx, hasher);
160-
span.hash_stable(hcx, hasher);
161-
});
162-
}
163-
}
164-
165-
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for ImplItem<'_> {
166-
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
167-
let ImplItem { def_id: _, ident, ref vis, ref generics, ref kind, span } = *self;
168-
169-
hcx.hash_hir_item_like(|hcx| {
170-
ident.name.hash_stable(hcx, hasher);
171-
vis.hash_stable(hcx, hasher);
172-
generics.hash_stable(hcx, hasher);
173-
kind.hash_stable(hcx, hasher);
174-
span.hash_stable(hcx, hasher);
175-
});
176-
}
177-
}
178-
179-
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for ForeignItem<'_> {
180-
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
181-
let ForeignItem { def_id: _, ident, ref kind, span, ref vis } = *self;
182-
183-
hcx.hash_hir_item_like(|hcx| {
184-
ident.name.hash_stable(hcx, hasher);
185-
kind.hash_stable(hcx, hasher);
186-
span.hash_stable(hcx, hasher);
187-
vis.hash_stable(hcx, hasher);
188-
});
189-
}
190-
}
191-
192-
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for Item<'_> {
193-
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
194-
let Item { ident, def_id: _, ref kind, ref vis, span } = *self;
195-
196-
hcx.hash_hir_item_like(|hcx| {
197-
ident.name.hash_stable(hcx, hasher);
198-
kind.hash_stable(hcx, hasher);
199-
vis.hash_stable(hcx, hasher);
200-
span.hash_stable(hcx, hasher);
201-
});
202-
}
203-
}
204-
205111
impl<'tcx, HirCtx: crate::HashStableContext> HashStable<HirCtx> for OwnerNodes<'tcx> {
206112
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
207113
// We ignore the `nodes` and `bodies` fields since these refer to information included in
@@ -235,9 +141,3 @@ impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for Crate<'_> {
235141
hir_hash.hash_stable(hcx, hasher)
236142
}
237143
}
238-
239-
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for TraitCandidate {
240-
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
241-
hcx.hash_hir_trait_candidate(self, hasher)
242-
}
243-
}

compiler/rustc_middle/src/middle/privacy.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use rustc_data_structures::fx::FxHashMap;
66
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
77
use rustc_macros::HashStable;
8-
use rustc_query_system::ich::{NodeIdHashingMode, StableHashingContext};
8+
use rustc_query_system::ich::StableHashingContext;
99
use rustc_span::def_id::LocalDefId;
1010
use std::hash::Hash;
1111

@@ -58,9 +58,7 @@ impl<Id> Default for AccessLevels<Id> {
5858

5959
impl<'a> HashStable<StableHashingContext<'a>> for AccessLevels {
6060
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
61-
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
62-
let AccessLevels { ref map } = *self;
63-
map.hash_stable(hcx, hasher);
64-
});
61+
let AccessLevels { ref map } = *self;
62+
map.hash_stable(hcx, hasher);
6563
}
6664
}

compiler/rustc_middle/src/middle/region.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
1212
use rustc_hir as hir;
1313
use rustc_hir::Node;
1414
use rustc_macros::HashStable;
15-
use rustc_query_system::ich::{NodeIdHashingMode, StableHashingContext};
15+
use rustc_query_system::ich::StableHashingContext;
1616
use rustc_span::{Span, DUMMY_SP};
1717

1818
use std::fmt;
@@ -446,10 +446,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for ScopeTree {
446446
ref yield_in_scope,
447447
} = *self;
448448

449-
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
450-
root_body.hash_stable(hcx, hasher)
451-
});
452-
449+
root_body.hash_stable(hcx, hasher);
453450
body_expr_count.hash_stable(hcx, hasher);
454451
parent_map.hash_stable(hcx, hasher);
455452
var_map.hash_stable(hcx, hasher);

0 commit comments

Comments
 (0)