Skip to content

Commit 7fc8490

Browse files
ICH: Add some HashStable implementations.
1 parent b6e8635 commit 7fc8490

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

src/librustc/ich/impls_hir.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//! types in no particular order.
1313
1414
use hir;
15-
use hir::def_id::DefId;
15+
use hir::def_id::{DefId, CrateNum, CRATE_DEF_INDEX};
1616
use ich::{StableHashingContext, NodeIdHashingMode};
1717
use std::mem;
1818

@@ -46,6 +46,19 @@ impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> for hir::H
4646
}
4747
}
4848

49+
50+
impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> for CrateNum {
51+
#[inline]
52+
fn hash_stable<W: StableHasherResult>(&self,
53+
hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
54+
hasher: &mut StableHasher<W>) {
55+
hcx.def_path_hash(DefId {
56+
krate: *self,
57+
index: CRATE_DEF_INDEX
58+
}).hash_stable(hcx, hasher);
59+
}
60+
}
61+
4962
impl_stable_hash_for!(tuple_struct hir::ItemLocalId { index });
5063

5164
// The following implementations of HashStable for ItemId, TraitItemId, and

src/librustc_data_structures/stable_hasher.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,14 @@ impl<CTX> HashStable<CTX> for f64 {
244244
}
245245
}
246246

247+
impl<T1: HashStable<CTX>, CTX> HashStable<CTX> for (T1,) {
248+
fn hash_stable<W: StableHasherResult>(&self,
249+
ctx: &mut CTX,
250+
hasher: &mut StableHasher<W>) {
251+
self.0.hash_stable(ctx, hasher);
252+
}
253+
}
254+
247255
impl<T1: HashStable<CTX>, T2: HashStable<CTX>, CTX> HashStable<CTX> for (T1, T2) {
248256
fn hash_stable<W: StableHasherResult>(&self,
249257
ctx: &mut CTX,
@@ -273,6 +281,24 @@ impl<T: HashStable<CTX>, CTX> HashStable<CTX> for Vec<T> {
273281
}
274282
}
275283

284+
impl<T: HashStable<CTX>, CTX> HashStable<CTX> for ::std::rc::Rc<T> {
285+
#[inline]
286+
fn hash_stable<W: StableHasherResult>(&self,
287+
ctx: &mut CTX,
288+
hasher: &mut StableHasher<W>) {
289+
(**self).hash_stable(ctx, hasher);
290+
}
291+
}
292+
293+
impl<T: HashStable<CTX>, CTX> HashStable<CTX> for ::std::sync::Arc<T> {
294+
#[inline]
295+
fn hash_stable<W: StableHasherResult>(&self,
296+
ctx: &mut CTX,
297+
hasher: &mut StableHasher<W>) {
298+
(**self).hash_stable(ctx, hasher);
299+
}
300+
}
301+
276302
impl<CTX> HashStable<CTX> for str {
277303
#[inline]
278304
fn hash_stable<W: StableHasherResult>(&self,

0 commit comments

Comments
 (0)