Skip to content

Commit 64ef0f1

Browse files
Switch over all StableHash impls to new format
1 parent cf134d3 commit 64ef0f1

File tree

37 files changed

+186
-466
lines changed

37 files changed

+186
-466
lines changed

src/librustc/hir/map/collector.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use syntax_pos::Span;
1717
use std::iter::repeat;
1818

1919
use crate::ich::StableHashingContext;
20-
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult};
20+
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
2121

2222
/// A visitor that walks over the HIR and collects `Node`s into a HIR map.
2323
pub(super) struct NodeCollector<'a, 'hir> {
@@ -602,9 +602,7 @@ impl<'hir, T> HashStable<StableHashingContext<'hir>> for HirItemLike<T>
602602
where
603603
T: HashStable<StableHashingContext<'hir>>,
604604
{
605-
fn hash_stable<W: StableHasherResult>(&self,
606-
hcx: &mut StableHashingContext<'hir>,
607-
hasher: &mut StableHasher<W>) {
605+
fn hash_stable(&self, hcx: &mut StableHashingContext<'hir>, hasher: &mut StableHasher) {
608606
hcx.while_hashing_hir_bodies(self.hash_bodies, |hcx| {
609607
self.item_like.hash_stable(hcx, hasher);
610608
});

src/librustc/hir/ptr.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ use std::{slice, vec};
99

1010
use rustc_serialize::{Encodable, Decodable, Encoder, Decoder};
1111

12-
use rustc_data_structures::stable_hasher::{StableHasher, StableHasherResult,
13-
HashStable};
12+
use rustc_data_structures::stable_hasher::{StableHasher, HashStable};
1413
/// An owned smart pointer.
1514
#[derive(Hash, PartialEq, Eq)]
1615
pub struct P<T: ?Sized> {
@@ -133,9 +132,7 @@ impl<T: Decodable> Decodable for P<[T]> {
133132
impl<CTX, T> HashStable<CTX> for P<T>
134133
where T: ?Sized + HashStable<CTX>
135134
{
136-
fn hash_stable<W: StableHasherResult>(&self,
137-
hcx: &mut CTX,
138-
hasher: &mut StableHasher<W>) {
135+
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
139136
(**self).hash_stable(hcx, hasher);
140137
}
141138
}

src/librustc/ich/hcx.rs

+9-23
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use syntax_pos::{Span, DUMMY_SP};
2020
use syntax_pos::hygiene;
2121

2222
use rustc_data_structures::stable_hasher::{
23-
HashStable, StableHasher, StableHasherResult, ToStableHashKey,
23+
HashStable, StableHasher, ToStableHashKey,
2424
};
2525
use rustc_data_structures::fx::{FxHashSet, FxHashMap};
2626
use smallvec::SmallVec;
@@ -219,9 +219,7 @@ impl<'a> StableHashingContextProvider<'a> for StableHashingContext<'a> {
219219
impl<'a> crate::dep_graph::DepGraphSafe for StableHashingContext<'a> {}
220220

221221
impl<'a> HashStable<StableHashingContext<'a>> for hir::BodyId {
222-
fn hash_stable<W: StableHasherResult>(&self,
223-
hcx: &mut StableHashingContext<'a>,
224-
hasher: &mut StableHasher<W>) {
222+
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
225223
if hcx.hash_bodies() {
226224
hcx.body_resolver.body(*self).hash_stable(hcx, hasher);
227225
}
@@ -230,9 +228,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::BodyId {
230228

231229
impl<'a> HashStable<StableHashingContext<'a>> for hir::HirId {
232230
#[inline]
233-
fn hash_stable<W: StableHasherResult>(&self,
234-
hcx: &mut StableHashingContext<'a>,
235-
hasher: &mut StableHasher<W>) {
231+
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
236232
match hcx.node_id_hashing_mode {
237233
NodeIdHashingMode::Ignore => {
238234
// Don't do anything.
@@ -263,9 +259,7 @@ impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::HirId {
263259
}
264260

265261
impl<'a> HashStable<StableHashingContext<'a>> for ast::NodeId {
266-
fn hash_stable<W: StableHasherResult>(&self,
267-
hcx: &mut StableHashingContext<'a>,
268-
hasher: &mut StableHasher<W>) {
262+
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
269263
match hcx.node_id_hashing_mode {
270264
NodeIdHashingMode::Ignore => {
271265
// Don't do anything.
@@ -298,9 +292,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for Span {
298292
/// codepoint offsets. For the purpose of the hash that's sufficient.
299293
/// Also, hashing filenames is expensive so we avoid doing it twice when the
300294
/// span starts and ends in the same file, which is almost always the case.
301-
fn hash_stable<W: StableHasherResult>(&self,
302-
hcx: &mut StableHashingContext<'a>,
303-
hasher: &mut StableHasher<W>) {
295+
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
304296
const TAG_VALID_SPAN: u8 = 0;
305297
const TAG_INVALID_SPAN: u8 = 1;
306298
const TAG_EXPANSION: u8 = 0;
@@ -379,24 +371,18 @@ impl<'a> HashStable<StableHashingContext<'a>> for Span {
379371
}
380372

381373
impl<'a> HashStable<StableHashingContext<'a>> for DelimSpan {
382-
fn hash_stable<W: StableHasherResult>(
383-
&self,
384-
hcx: &mut StableHashingContext<'a>,
385-
hasher: &mut StableHasher<W>,
386-
) {
374+
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
387375
self.open.hash_stable(hcx, hasher);
388376
self.close.hash_stable(hcx, hasher);
389377
}
390378
}
391379

392-
pub fn hash_stable_trait_impls<'a, W>(
380+
pub fn hash_stable_trait_impls<'a>(
393381
hcx: &mut StableHashingContext<'a>,
394-
hasher: &mut StableHasher<W>,
382+
hasher: &mut StableHasher,
395383
blanket_impls: &[DefId],
396384
non_blanket_impls: &FxHashMap<fast_reject::SimplifiedType, Vec<DefId>>,
397-
) where
398-
W: StableHasherResult,
399-
{
385+
) {
400386
{
401387
let mut blanket_impls: SmallVec<[_; 8]> = blanket_impls
402388
.iter()

src/librustc/ich/impls_hir.rs

+20-60
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,15 @@ use crate::hir::map::DefPathHash;
66
use crate::hir::def_id::{DefId, LocalDefId, CrateNum, CRATE_DEF_INDEX};
77
use crate::ich::{StableHashingContext, NodeIdHashingMode, Fingerprint};
88

9-
use rustc_data_structures::stable_hasher::{
10-
HashStable, ToStableHashKey, StableHasher, StableHasherResult,
11-
};
9+
use rustc_data_structures::stable_hasher::{HashStable, ToStableHashKey, StableHasher};
1210
use smallvec::SmallVec;
1311
use std::mem;
1412
use syntax::ast;
1513
use syntax::attr;
1614

1715
impl<'a> HashStable<StableHashingContext<'a>> for DefId {
1816
#[inline]
19-
fn hash_stable<W: StableHasherResult>(&self,
20-
hcx: &mut StableHashingContext<'a>,
21-
hasher: &mut StableHasher<W>) {
17+
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
2218
hcx.def_path_hash(*self).hash_stable(hcx, hasher);
2319
}
2420
}
@@ -34,9 +30,7 @@ impl<'a> ToStableHashKey<StableHashingContext<'a>> for DefId {
3430

3531
impl<'a> HashStable<StableHashingContext<'a>> for LocalDefId {
3632
#[inline]
37-
fn hash_stable<W: StableHasherResult>(&self,
38-
hcx: &mut StableHashingContext<'a>,
39-
hasher: &mut StableHasher<W>) {
33+
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
4034
hcx.def_path_hash(self.to_def_id()).hash_stable(hcx, hasher);
4135
}
4236
}
@@ -52,9 +46,7 @@ impl<'a> ToStableHashKey<StableHashingContext<'a>> for LocalDefId {
5246

5347
impl<'a> HashStable<StableHashingContext<'a>> for CrateNum {
5448
#[inline]
55-
fn hash_stable<W: StableHasherResult>(&self,
56-
hcx: &mut StableHashingContext<'a>,
57-
hasher: &mut StableHasher<W>) {
49+
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
5850
hcx.def_path_hash(DefId {
5951
krate: *self,
6052
index: CRATE_DEF_INDEX
@@ -92,9 +84,7 @@ for hir::ItemLocalId {
9284
// in "DefPath Mode".
9385

9486
impl<'a> HashStable<StableHashingContext<'a>> for hir::ItemId {
95-
fn hash_stable<W: StableHasherResult>(&self,
96-
hcx: &mut StableHashingContext<'a>,
97-
hasher: &mut StableHasher<W>) {
87+
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
9888
let hir::ItemId {
9989
id
10090
} = *self;
@@ -106,9 +96,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::ItemId {
10696
}
10797

10898
impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitItemId {
109-
fn hash_stable<W: StableHasherResult>(&self,
110-
hcx: &mut StableHashingContext<'a>,
111-
hasher: &mut StableHasher<W>) {
99+
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
112100
let hir::TraitItemId {
113101
hir_id
114102
} = * self;
@@ -120,9 +108,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitItemId {
120108
}
121109

122110
impl<'a> HashStable<StableHashingContext<'a>> for hir::ImplItemId {
123-
fn hash_stable<W: StableHasherResult>(&self,
124-
hcx: &mut StableHashingContext<'a>,
125-
hasher: &mut StableHasher<W>) {
111+
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
126112
let hir::ImplItemId {
127113
hir_id
128114
} = * self;
@@ -138,9 +124,7 @@ impl_stable_hash_for!(struct ast::Label {
138124
});
139125

140126
impl<'a> HashStable<StableHashingContext<'a>> for hir::Ty {
141-
fn hash_stable<W: StableHasherResult>(&self,
142-
hcx: &mut StableHashingContext<'a>,
143-
hasher: &mut StableHasher<W>) {
127+
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
144128
hcx.while_hashing_hir_bodies(true, |hcx| {
145129
let hir::Ty {
146130
hir_id: _,
@@ -166,9 +150,7 @@ impl_stable_hash_for!(struct hir::Stmt {
166150
impl_stable_hash_for_spanned!(ast::Name);
167151

168152
impl<'a> HashStable<StableHashingContext<'a>> for hir::Expr {
169-
fn hash_stable<W: StableHasherResult>(&self,
170-
hcx: &mut StableHashingContext<'a>,
171-
hasher: &mut StableHasher<W>) {
153+
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
172154
hcx.while_hashing_hir_bodies(true, |hcx| {
173155
let hir::Expr {
174156
hir_id: _,
@@ -192,9 +174,7 @@ impl_stable_hash_for!(struct ast::Ident {
192174
});
193175

194176
impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitItem {
195-
fn hash_stable<W: StableHasherResult>(&self,
196-
hcx: &mut StableHashingContext<'a>,
197-
hasher: &mut StableHasher<W>) {
177+
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
198178
let hir::TraitItem {
199179
hir_id: _,
200180
ident,
@@ -216,9 +196,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitItem {
216196

217197

218198
impl<'a> HashStable<StableHashingContext<'a>> for hir::ImplItem {
219-
fn hash_stable<W: StableHasherResult>(&self,
220-
hcx: &mut StableHashingContext<'a>,
221-
hasher: &mut StableHasher<W>) {
199+
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
222200
let hir::ImplItem {
223201
hir_id: _,
224202
ident,
@@ -248,9 +226,7 @@ impl_stable_hash_for!(enum ast::CrateSugar {
248226
});
249227

250228
impl<'a> HashStable<StableHashingContext<'a>> for hir::VisibilityKind {
251-
fn hash_stable<W: StableHasherResult>(&self,
252-
hcx: &mut StableHashingContext<'a>,
253-
hasher: &mut StableHasher<W>) {
229+
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
254230
mem::discriminant(self).hash_stable(hcx, hasher);
255231
match *self {
256232
hir::VisibilityKind::Public |
@@ -273,9 +249,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::VisibilityKind {
273249
impl_stable_hash_for_spanned!(hir::VisibilityKind);
274250

275251
impl<'a> HashStable<StableHashingContext<'a>> for hir::Mod {
276-
fn hash_stable<W: StableHasherResult>(&self,
277-
hcx: &mut StableHashingContext<'a>,
278-
hasher: &mut StableHasher<W>) {
252+
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
279253
let hir::Mod {
280254
inner: ref inner_span,
281255
ref item_ids,
@@ -305,9 +279,7 @@ impl_stable_hash_for_spanned!(hir::Variant);
305279

306280

307281
impl<'a> HashStable<StableHashingContext<'a>> for hir::Item {
308-
fn hash_stable<W: StableHasherResult>(&self,
309-
hcx: &mut StableHashingContext<'a>,
310-
hasher: &mut StableHasher<W>) {
282+
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
311283
let hir::Item {
312284
ident,
313285
ref attrs,
@@ -328,9 +300,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Item {
328300
}
329301

330302
impl<'a> HashStable<StableHashingContext<'a>> for hir::Body {
331-
fn hash_stable<W: StableHasherResult>(&self,
332-
hcx: &mut StableHashingContext<'a>,
333-
hasher: &mut StableHasher<W>) {
303+
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
334304
let hir::Body {
335305
params,
336306
value,
@@ -359,9 +329,7 @@ impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::BodyId {
359329

360330
impl<'a> HashStable<StableHashingContext<'a>> for hir::def_id::DefIndex {
361331

362-
fn hash_stable<W: StableHasherResult>(&self,
363-
hcx: &mut StableHashingContext<'a>,
364-
hasher: &mut StableHasher<W>) {
332+
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
365333
hcx.local_def_path_hash(*self).hash_stable(hcx, hasher);
366334
}
367335
}
@@ -376,17 +344,13 @@ impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::def_id::DefIndex {
376344
}
377345

378346
impl<'a> HashStable<StableHashingContext<'a>> for crate::middle::lang_items::LangItem {
379-
fn hash_stable<W: StableHasherResult>(&self,
380-
_: &mut StableHashingContext<'a>,
381-
hasher: &mut StableHasher<W>) {
347+
fn hash_stable(&self, _: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
382348
::std::hash::Hash::hash(self, hasher);
383349
}
384350
}
385351

386352
impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitCandidate {
387-
fn hash_stable<W: StableHasherResult>(&self,
388-
hcx: &mut StableHashingContext<'a>,
389-
hasher: &mut StableHasher<W>) {
353+
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
390354
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
391355
let hir::TraitCandidate {
392356
def_id,
@@ -418,17 +382,13 @@ impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::TraitCandidate {
418382
}
419383

420384
impl<'hir> HashStable<StableHashingContext<'hir>> for attr::InlineAttr {
421-
fn hash_stable<W: StableHasherResult>(&self,
422-
hcx: &mut StableHashingContext<'hir>,
423-
hasher: &mut StableHasher<W>) {
385+
fn hash_stable(&self, hcx: &mut StableHashingContext<'hir>, hasher: &mut StableHasher) {
424386
mem::discriminant(self).hash_stable(hcx, hasher);
425387
}
426388
}
427389

428390
impl<'hir> HashStable<StableHashingContext<'hir>> for attr::OptimizeAttr {
429-
fn hash_stable<W: StableHasherResult>(&self,
430-
hcx: &mut StableHashingContext<'hir>,
431-
hasher: &mut StableHasher<W>) {
391+
fn hash_stable(&self, hcx: &mut StableHashingContext<'hir>, hasher: &mut StableHasher) {
432392
mem::discriminant(self).hash_stable(hcx, hasher);
433393
}
434394
}

0 commit comments

Comments
 (0)