Trait rustc_ap_rustc_data_structures::stable_hasher::HashStable [−][src]
pub trait HashStable<CTX> { fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher); }
Expand description
Something that implements HashStable<CTX>
can be hashed in a way that is
stable across multiple compilation sessions.
Note that HashStable
imposes rather more strict requirements than usual
hash functions:
-
Stable hashes are sometimes used as identifiers. Therefore they must conform to the corresponding
PartialEq
implementations:x == y
implieshash_stable(x) == hash_stable(y)
, andx != y
implieshash_stable(x) != hash_stable(y)
.
That second condition is usually not required for hash functions (e.g.
Hash
). In practice this means thathash_stable
must feed any information into the hasher that aPartialEq
comparison takes into account. See #49300 for an example where violating this invariant has caused trouble in the past. -
hash_stable()
must be independent of the current compilation session. E.g. they must not hash memory addresses or other things that are “randomly” assigned per compilation session. -
hash_stable()
must be independent of the host architecture. TheStableHasher
takes care of endianness andisize
/usize
platform differences.
Required methods
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher)
[src]
Implementations on Foreign Types
impl<CTX> HashStable<CTX> for i8
[src]
impl<CTX> HashStable<CTX> for i8
[src]fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)
[src]
impl<CTX> HashStable<CTX> for i16
[src]
impl<CTX> HashStable<CTX> for i16
[src]fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)
[src]
impl<CTX> HashStable<CTX> for i32
[src]
impl<CTX> HashStable<CTX> for i32
[src]fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)
[src]
impl<CTX> HashStable<CTX> for i64
[src]
impl<CTX> HashStable<CTX> for i64
[src]fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)
[src]
impl<CTX> HashStable<CTX> for isize
[src]
impl<CTX> HashStable<CTX> for isize
[src]fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)
[src]
impl<CTX> HashStable<CTX> for u8
[src]
impl<CTX> HashStable<CTX> for u8
[src]fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)
[src]
impl<CTX> HashStable<CTX> for u16
[src]
impl<CTX> HashStable<CTX> for u16
[src]fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)
[src]
impl<CTX> HashStable<CTX> for u32
[src]
impl<CTX> HashStable<CTX> for u32
[src]fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)
[src]
impl<CTX> HashStable<CTX> for u64
[src]
impl<CTX> HashStable<CTX> for u64
[src]fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)
[src]
impl<CTX> HashStable<CTX> for usize
[src]
impl<CTX> HashStable<CTX> for usize
[src]fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)
[src]
impl<CTX> HashStable<CTX> for u128
[src]
impl<CTX> HashStable<CTX> for u128
[src]fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)
[src]
impl<CTX> HashStable<CTX> for i128
[src]
impl<CTX> HashStable<CTX> for i128
[src]fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)
[src]
impl<CTX> HashStable<CTX> for char
[src]
impl<CTX> HashStable<CTX> for char
[src]fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)
[src]
impl<CTX> HashStable<CTX> for ()
[src]
impl<CTX> HashStable<CTX> for ()
[src]fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)
[src]
impl<CTX> HashStable<CTX> for NonZeroU32
[src]
impl<CTX> HashStable<CTX> for NonZeroU32
[src]fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<CTX> HashStable<CTX> for NonZeroUsize
[src]
impl<CTX> HashStable<CTX> for NonZeroUsize
[src]fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<CTX> HashStable<CTX> for f32
[src]
impl<CTX> HashStable<CTX> for f32
[src]fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<CTX> HashStable<CTX> for f64
[src]
impl<CTX> HashStable<CTX> for f64
[src]fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<CTX> HashStable<CTX> for Ordering
[src]
impl<CTX> HashStable<CTX> for Ordering
[src]fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<T1: HashStable<CTX>, CTX> HashStable<CTX> for (T1,)
[src]
impl<T1: HashStable<CTX>, CTX> HashStable<CTX> for (T1,)
[src]fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<T1: HashStable<CTX>, T2: HashStable<CTX>, CTX> HashStable<CTX> for (T1, T2)
[src]
impl<T1: HashStable<CTX>, T2: HashStable<CTX>, CTX> HashStable<CTX> for (T1, T2)
[src]fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<T1, T2, T3, CTX> HashStable<CTX> for (T1, T2, T3) where
T1: HashStable<CTX>,
T2: HashStable<CTX>,
T3: HashStable<CTX>,
[src]
impl<T1, T2, T3, CTX> HashStable<CTX> for (T1, T2, T3) where
T1: HashStable<CTX>,
T2: HashStable<CTX>,
T3: HashStable<CTX>,
[src]fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<T1, T2, T3, T4, CTX> HashStable<CTX> for (T1, T2, T3, T4) where
T1: HashStable<CTX>,
T2: HashStable<CTX>,
T3: HashStable<CTX>,
T4: HashStable<CTX>,
[src]
impl<T1, T2, T3, T4, CTX> HashStable<CTX> for (T1, T2, T3, T4) where
T1: HashStable<CTX>,
T2: HashStable<CTX>,
T3: HashStable<CTX>,
T4: HashStable<CTX>,
[src]fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<T: HashStable<CTX>, CTX> HashStable<CTX> for [T]
[src]
impl<T: HashStable<CTX>, CTX> HashStable<CTX> for [T]
[src]default fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<T: HashStable<CTX>, CTX> HashStable<CTX> for Vec<T>
[src]
impl<T: HashStable<CTX>, CTX> HashStable<CTX> for Vec<T>
[src]fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<K, V, R, CTX> HashStable<CTX> for IndexMap<K, V, R> where
K: HashStable<CTX> + Eq + Hash,
V: HashStable<CTX>,
R: BuildHasher,
[src]
impl<K, V, R, CTX> HashStable<CTX> for IndexMap<K, V, R> where
K: HashStable<CTX> + Eq + Hash,
V: HashStable<CTX>,
R: BuildHasher,
[src]fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<K, R, CTX> HashStable<CTX> for IndexSet<K, R> where
K: HashStable<CTX> + Eq + Hash,
R: BuildHasher,
[src]
impl<K, R, CTX> HashStable<CTX> for IndexSet<K, R> where
K: HashStable<CTX> + Eq + Hash,
R: BuildHasher,
[src]fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<A, CTX> HashStable<CTX> for SmallVec<[A; 1]> where
A: HashStable<CTX>,
[src]
impl<A, CTX> HashStable<CTX> for SmallVec<[A; 1]> where
A: HashStable<CTX>,
[src]fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<T: ?Sized + HashStable<CTX>, CTX> HashStable<CTX> for Box<T>
[src]
impl<T: ?Sized + HashStable<CTX>, CTX> HashStable<CTX> for Box<T>
[src]fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<T: ?Sized + HashStable<CTX>, CTX> HashStable<CTX> for Arc<T>
[src]
impl<T: ?Sized + HashStable<CTX>, CTX> HashStable<CTX> for Arc<T>
[src]fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<CTX> HashStable<CTX> for str
[src]
impl<CTX> HashStable<CTX> for str
[src]fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)
[src]
impl<CTX> HashStable<CTX> for String
[src]
impl<CTX> HashStable<CTX> for String
[src]fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<CTX> HashStable<CTX> for bool
[src]
impl<CTX> HashStable<CTX> for bool
[src]fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<T, CTX> HashStable<CTX> for Option<T> where
T: HashStable<CTX>,
[src]
impl<T, CTX> HashStable<CTX> for Option<T> where
T: HashStable<CTX>,
[src]fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<T1, T2, CTX> HashStable<CTX> for Result<T1, T2> where
T1: HashStable<CTX>,
T2: HashStable<CTX>,
[src]
impl<T1, T2, CTX> HashStable<CTX> for Result<T1, T2> where
T1: HashStable<CTX>,
T2: HashStable<CTX>,
[src]fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<'a, T: ?Sized, CTX> HashStable<CTX> for &'a T where
T: HashStable<CTX>,
[src]
impl<'a, T: ?Sized, CTX> HashStable<CTX> for &'a T where
T: HashStable<CTX>,
[src]fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<T, CTX> HashStable<CTX> for Discriminant<T>
[src]
impl<T, CTX> HashStable<CTX> for Discriminant<T>
[src]fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)
[src]
impl<T, CTX> HashStable<CTX> for RangeInclusive<T> where
T: HashStable<CTX>,
[src]
impl<T, CTX> HashStable<CTX> for RangeInclusive<T> where
T: HashStable<CTX>,
[src]fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<I: Idx, T, CTX> HashStable<CTX> for IndexVec<I, T> where
T: HashStable<CTX>,
[src]
impl<I: Idx, T, CTX> HashStable<CTX> for IndexVec<I, T> where
T: HashStable<CTX>,
[src]fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<I: Idx, CTX> HashStable<CTX> for BitSet<I>
[src]
impl<I: Idx, CTX> HashStable<CTX> for BitSet<I>
[src]fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<R: Idx, C: Idx, CTX> HashStable<CTX> for BitMatrix<R, C>
[src]
impl<R: Idx, C: Idx, CTX> HashStable<CTX> for BitMatrix<R, C>
[src]fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<T, CTX> HashStable<CTX> for FiniteBitSet<T> where
T: HashStable<CTX> + FiniteBitSetTy,
[src]
impl<T, CTX> HashStable<CTX> for FiniteBitSet<T> where
T: HashStable<CTX> + FiniteBitSetTy,
[src]fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<CTX> HashStable<CTX> for Path
[src]
impl<CTX> HashStable<CTX> for Path
[src]fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)
[src]
impl<CTX> HashStable<CTX> for PathBuf
[src]
impl<CTX> HashStable<CTX> for PathBuf
[src]fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)
[src]
impl<K, V, R, HCX> HashStable<HCX> for HashMap<K, V, R> where
K: ToStableHashKey<HCX> + Eq,
V: HashStable<HCX>,
R: BuildHasher,
[src]
impl<K, V, R, HCX> HashStable<HCX> for HashMap<K, V, R> where
K: ToStableHashKey<HCX> + Eq,
V: HashStable<HCX>,
R: BuildHasher,
[src]fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher)
[src]
impl<K, R, HCX> HashStable<HCX> for HashSet<K, R> where
K: ToStableHashKey<HCX> + Eq,
R: BuildHasher,
[src]
impl<K, R, HCX> HashStable<HCX> for HashSet<K, R> where
K: ToStableHashKey<HCX> + Eq,
R: BuildHasher,
[src]fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher)
[src]
impl<K, V, HCX> HashStable<HCX> for BTreeMap<K, V> where
K: ToStableHashKey<HCX>,
V: HashStable<HCX>,
[src]
impl<K, V, HCX> HashStable<HCX> for BTreeMap<K, V> where
K: ToStableHashKey<HCX>,
V: HashStable<HCX>,
[src]fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher)
[src]
impl<K, HCX> HashStable<HCX> for BTreeSet<K> where
K: ToStableHashKey<HCX>,
[src]
impl<K, HCX> HashStable<HCX> for BTreeSet<K> where
K: ToStableHashKey<HCX>,
[src]fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher)
[src]
Implementors
impl<CTX> HashStable<CTX> for Fingerprint
[src]
impl<CTX> HashStable<CTX> for Fingerprint
[src]fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher)
[src]
impl<CTX, T: HashStable<CTX>> HashStable<CTX> for Steal<T>
[src]
impl<CTX, T: HashStable<CTX>> HashStable<CTX> for Steal<T>
[src]fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<I: Idx, K, V, C> HashStable<C> for SortedIndexMultiMap<I, K, V> where
K: HashStable<C>,
V: HashStable<C>,
[src]
impl<I: Idx, K, V, C> HashStable<C> for SortedIndexMultiMap<I, K, V> where
K: HashStable<C>,
V: HashStable<C>,
[src]fn hash_stable(&self, ctx: &mut C, hasher: &mut StableHasher)
[src]
impl<P, T, HCX, const COMPARE_PACKED: bool> HashStable<HCX> for CopyTaggedPtr<P, T, COMPARE_PACKED> where
P: Pointer + HashStable<HCX>,
T: Tag + HashStable<HCX>,
[src]
impl<P, T, HCX, const COMPARE_PACKED: bool> HashStable<HCX> for CopyTaggedPtr<P, T, COMPARE_PACKED> where
P: Pointer + HashStable<HCX>,
T: Tag + HashStable<HCX>,
[src]fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher)
[src]
impl<P, T, HCX, const COMPARE_PACKED: bool> HashStable<HCX> for TaggedPtr<P, T, COMPARE_PACKED> where
P: Pointer + HashStable<HCX>,
T: Tag + HashStable<HCX>,
[src]
impl<P, T, HCX, const COMPARE_PACKED: bool> HashStable<HCX> for TaggedPtr<P, T, COMPARE_PACKED> where
P: Pointer + HashStable<HCX>,
T: Tag + HashStable<HCX>,
[src]fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher)
[src]
impl<T> HashStable<T> for Svh
[src]
impl<T> HashStable<T> for Svh
[src]fn hash_stable(&self, ctx: &mut T, hasher: &mut StableHasher)
[src]
impl<T: HashStable<CTX>, CTX> HashStable<CTX> for ThinVec<T>
[src]
impl<T: HashStable<CTX>, CTX> HashStable<CTX> for ThinVec<T>
[src]fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher)
[src]
impl<T: ?Sized + HashStable<CTX>, CTX> HashStable<CTX> for Rc<T>
[src]
impl<T: ?Sized + HashStable<CTX>, CTX> HashStable<CTX> for Rc<T>
[src]