diff options
Diffstat (limited to 'src/librustc_data_structures')
| -rw-r--r-- | src/librustc_data_structures/stable_hasher.rs | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/librustc_data_structures/stable_hasher.rs b/src/librustc_data_structures/stable_hasher.rs index 0d0cf672489..f80cbfadf2e 100644 --- a/src/librustc_data_structures/stable_hasher.rs +++ b/src/librustc_data_structures/stable_hasher.rs @@ -192,6 +192,28 @@ impl<W> Hasher for StableHasher<W> { } +/// Something that can provide a stable hashing context. +pub trait StableHashingContextProvider { + type ContextType; + fn create_stable_hashing_context(&self) -> Self::ContextType; +} + +impl<'a, T: StableHashingContextProvider> StableHashingContextProvider for &'a T { + type ContextType = T::ContextType; + + fn create_stable_hashing_context(&self) -> Self::ContextType { + (**self).create_stable_hashing_context() + } +} + +impl<'a, T: StableHashingContextProvider> StableHashingContextProvider for &'a mut T { + type ContextType = T::ContextType; + + fn create_stable_hashing_context(&self) -> Self::ContextType { + (**self).create_stable_hashing_context() + } +} + /// Something that implements `HashStable<CTX>` can be hashed in a way that is /// stable across multiple compilation sessions. pub trait HashStable<CTX> { @@ -292,7 +314,7 @@ impl<T: HashStable<CTX>, CTX> HashStable<CTX> for Vec<T> { } } -impl<T: HashStable<CTX>, CTX> HashStable<CTX> for Box<T> { +impl<T: ?Sized + HashStable<CTX>, CTX> HashStable<CTX> for Box<T> { #[inline] fn hash_stable<W: StableHasherResult>(&self, ctx: &mut CTX, @@ -301,7 +323,7 @@ impl<T: HashStable<CTX>, CTX> HashStable<CTX> for Box<T> { } } -impl<T: HashStable<CTX>, CTX> HashStable<CTX> for ::std::rc::Rc<T> { +impl<T: ?Sized + HashStable<CTX>, CTX> HashStable<CTX> for ::std::rc::Rc<T> { #[inline] fn hash_stable<W: StableHasherResult>(&self, ctx: &mut CTX, @@ -310,7 +332,7 @@ impl<T: HashStable<CTX>, CTX> HashStable<CTX> for ::std::rc::Rc<T> { } } -impl<T: HashStable<CTX>, CTX> HashStable<CTX> for ::std::sync::Arc<T> { +impl<T: ?Sized + HashStable<CTX>, CTX> HashStable<CTX> for ::std::sync::Arc<T> { #[inline] fn hash_stable<W: StableHasherResult>(&self, ctx: &mut CTX, |
