Skip to content

Commit f60e58e

Browse files
StableHasher does not need to be generic over the Result type
1 parent f3c8eba commit f60e58e

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/librustc_data_structures/stable_hasher.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@ use crate::bit_set;
1313
/// To that end we always convert integers to little-endian format before
1414
/// hashing and the architecture dependent `isize` and `usize` types are
1515
/// extended to 64 bits if needed.
16-
pub struct StableHasher<W> {
16+
pub struct StableHasher {
1717
state: SipHasher128,
18-
width: PhantomData<W>,
1918
}
2019

21-
impl<W: StableHasherResult> ::std::fmt::Debug for StableHasher<W> {
20+
impl ::std::fmt::Debug for StableHasher {
2221
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2322
write!(f, "{:?}", self.state)
2423
}
@@ -28,15 +27,14 @@ pub trait StableHasherResult: Sized {
2827
fn finish(hasher: StableHasher<Self>) -> Self;
2928
}
3029

31-
impl<W: StableHasherResult> StableHasher<W> {
30+
impl StableHasher {
3231
pub fn new() -> Self {
3332
StableHasher {
3433
state: SipHasher128::new_with_keys(0, 0),
35-
width: PhantomData,
3634
}
3735
}
3836

39-
pub fn finish(self) -> W {
37+
pub fn finish<W: StableHasherResult>(self) -> W {
4038
W::finish(self)
4139
}
4240
}
@@ -54,14 +52,14 @@ impl StableHasherResult for u64 {
5452
}
5553
}
5654

57-
impl<W> StableHasher<W> {
55+
impl StableHasher {
5856
#[inline]
5957
pub fn finalize(self) -> (u64, u64) {
6058
self.state.finish128()
6159
}
6260
}
6361

64-
impl<W> Hasher for StableHasher<W> {
62+
impl Hasher for StableHasher {
6563
fn finish(&self) -> u64 {
6664
panic!("use StableHasher::finalize instead");
6765
}
@@ -165,9 +163,7 @@ impl<W> Hasher for StableHasher<W> {
165163
/// `StableHasher` takes care of endianness and `isize`/`usize` platform
166164
/// differences.
167165
pub trait HashStable<CTX> {
168-
fn hash_stable<W: StableHasherResult>(&self,
169-
hcx: &mut CTX,
170-
hasher: &mut StableHasher<W>);
166+
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher);
171167
}
172168

173169
/// Implement this for types that can be turned into stable keys like, for

0 commit comments

Comments
 (0)