Skip to content

Commit 443333d

Browse files
committed
Remove NodeIdHashingMode.
1 parent 341883d commit 443333d

File tree

16 files changed

+55
-359
lines changed

16 files changed

+55
-359
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
@@ -1265,7 +1265,7 @@ pub struct BodyId {
12651265
///
12661266
/// All bodies have an **owner**, which can be accessed via the HIR
12671267
/// map using `body_owner_def_id()`.
1268-
#[derive(Debug)]
1268+
#[derive(Debug, HashStable_Generic)]
12691269
pub struct Body<'hir> {
12701270
pub params: &'hir [Param<'hir>],
12711271
pub value: Expr<'hir>,
@@ -2025,7 +2025,7 @@ pub struct FnSig<'hir> {
20252025
// The bodies for items are stored "out of line", in a separate
20262026
// hashmap in the `Crate`. Here we just record the hir-id of the item
20272027
// so it can fetched later.
2028-
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Debug)]
2028+
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Debug, HashStable_Generic)]
20292029
pub struct TraitItemId {
20302030
pub def_id: LocalDefId,
20312031
}
@@ -2042,7 +2042,7 @@ impl TraitItemId {
20422042
/// possibly including a default implementation. A trait item is
20432043
/// either required (meaning it doesn't have an implementation, just a
20442044
/// signature) or provided (meaning it has a default implementation).
2045-
#[derive(Debug)]
2045+
#[derive(Debug, HashStable_Generic)]
20462046
pub struct TraitItem<'hir> {
20472047
pub ident: Ident,
20482048
pub def_id: LocalDefId,
@@ -2088,7 +2088,7 @@ pub enum TraitItemKind<'hir> {
20882088
// The bodies for items are stored "out of line", in a separate
20892089
// hashmap in the `Crate`. Here we just record the hir-id of the item
20902090
// so it can fetched later.
2091-
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Debug)]
2091+
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Debug, HashStable_Generic)]
20922092
pub struct ImplItemId {
20932093
pub def_id: LocalDefId,
20942094
}
@@ -2102,7 +2102,7 @@ impl ImplItemId {
21022102
}
21032103

21042104
/// Represents anything within an `impl` block.
2105-
#[derive(Debug)]
2105+
#[derive(Debug, HashStable_Generic)]
21062106
pub struct ImplItem<'hir> {
21072107
pub ident: Ident,
21082108
pub def_id: LocalDefId,
@@ -2603,7 +2603,7 @@ pub struct PolyTraitRef<'hir> {
26032603

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

2606-
#[derive(Copy, Clone, Debug)]
2606+
#[derive(Copy, Clone, Debug, HashStable_Generic)]
26072607
pub enum VisibilityKind<'hir> {
26082608
Public,
26092609
Crate(CrateSugar),
@@ -2679,7 +2679,7 @@ impl<'hir> VariantData<'hir> {
26792679
// The bodies for items are stored "out of line", in a separate
26802680
// hashmap in the `Crate`. Here we just record the hir-id of the item
26812681
// so it can fetched later.
2682-
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Debug, Hash)]
2682+
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Debug, Hash, HashStable_Generic)]
26832683
pub struct ItemId {
26842684
pub def_id: LocalDefId,
26852685
}
@@ -2695,7 +2695,7 @@ impl ItemId {
26952695
/// An item
26962696
///
26972697
/// The name might be a dummy name in case of anonymous items
2698-
#[derive(Debug)]
2698+
#[derive(Debug, HashStable_Generic)]
26992699
pub struct Item<'hir> {
27002700
pub ident: Ident,
27012701
pub def_id: LocalDefId,
@@ -2926,7 +2926,7 @@ pub enum AssocItemKind {
29262926
// The bodies for items are stored "out of line", in a separate
29272927
// hashmap in the `Crate`. Here we just record the hir-id of the item
29282928
// so it can fetched later.
2929-
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Debug)]
2929+
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Debug, HashStable_Generic)]
29302930
pub struct ForeignItemId {
29312931
pub def_id: LocalDefId,
29322932
}
@@ -2952,7 +2952,7 @@ pub struct ForeignItemRef {
29522952
pub span: Span,
29532953
}
29542954

2955-
#[derive(Debug)]
2955+
#[derive(Debug, HashStable_Generic)]
29562956
pub struct ForeignItem<'hir> {
29572957
pub ident: Ident,
29582958
pub kind: ForeignItemKind<'hir>,
@@ -2994,7 +2994,7 @@ pub struct Upvar {
29942994
// The TraitCandidate's import_ids is empty if the trait is defined in the same module, and
29952995
// has length > 0 if the trait is found through an chain of imports, starting with the
29962996
// import/use statement in the scope where the trait is used.
2997-
#[derive(Encodable, Decodable, Clone, Debug)]
2997+
#[derive(Encodable, Decodable, Clone, Debug, HashStable_Generic)]
29982998
pub struct TraitCandidate {
29992999
pub def_id: DefId,
30003000
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)