diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-09-26 18:28:02 -0400 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-09-28 11:47:15 -0400 |
| commit | f60e58e57580d47e82a374bad73214b6bfec085a (patch) | |
| tree | 9e363de86f76a56490f2b4c30ca4d88c3b3c1620 | |
| parent | f3c8eba643a815d720e7f20699b3dca144c845c4 (diff) | |
| download | rust-f60e58e57580d47e82a374bad73214b6bfec085a.tar.gz rust-f60e58e57580d47e82a374bad73214b6bfec085a.zip | |
StableHasher does not need to be generic over the Result type
| -rw-r--r-- | src/librustc_data_structures/stable_hasher.rs | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/librustc_data_structures/stable_hasher.rs b/src/librustc_data_structures/stable_hasher.rs index 47dfc1d1688..7c54a092af0 100644 --- a/src/librustc_data_structures/stable_hasher.rs +++ b/src/librustc_data_structures/stable_hasher.rs @@ -13,12 +13,11 @@ use crate::bit_set; /// To that end we always convert integers to little-endian format before /// hashing and the architecture dependent `isize` and `usize` types are /// extended to 64 bits if needed. -pub struct StableHasher<W> { +pub struct StableHasher { state: SipHasher128, - width: PhantomData<W>, } -impl<W: StableHasherResult> ::std::fmt::Debug for StableHasher<W> { +impl ::std::fmt::Debug for StableHasher { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { write!(f, "{:?}", self.state) } @@ -28,15 +27,14 @@ pub trait StableHasherResult: Sized { fn finish(hasher: StableHasher<Self>) -> Self; } -impl<W: StableHasherResult> StableHasher<W> { +impl StableHasher { pub fn new() -> Self { StableHasher { state: SipHasher128::new_with_keys(0, 0), - width: PhantomData, } } - pub fn finish(self) -> W { + pub fn finish<W: StableHasherResult>(self) -> W { W::finish(self) } } @@ -54,14 +52,14 @@ impl StableHasherResult for u64 { } } -impl<W> StableHasher<W> { +impl StableHasher { #[inline] pub fn finalize(self) -> (u64, u64) { self.state.finish128() } } -impl<W> Hasher for StableHasher<W> { +impl Hasher for StableHasher { fn finish(&self) -> u64 { panic!("use StableHasher::finalize instead"); } @@ -165,9 +163,7 @@ impl<W> Hasher for StableHasher<W> { /// `StableHasher` takes care of endianness and `isize`/`usize` platform /// differences. pub trait HashStable<CTX> { - fn hash_stable<W: StableHasherResult>(&self, - hcx: &mut CTX, - hasher: &mut StableHasher<W>); + fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher); } /// Implement this for types that can be turned into stable keys like, for |
