diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 024624cd3bb8..71ec1c5042fd 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -120,8 +120,8 @@ fn eq(&self, names: &&[Symbol]) -> bool { } } -impl HashStable for Path { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { +impl HashStable for Path { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.segments.len().hash_stable(hcx, hasher); for segment in &self.segments { segment.ident.hash_stable(hcx, hasher); diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index 8d8e8ffc562f..8953391ac58b 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -138,8 +138,8 @@ fn decode(_d: &mut D) -> Self { } } -impl HashStable for LazyAttrTokenStream { - fn hash_stable(&self, _hcx: &mut CTX, _hasher: &mut StableHasher) { +impl HashStable for LazyAttrTokenStream { + fn hash_stable(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) { panic!("Attempted to compute stable hash for LazyAttrTokenStream"); } } @@ -824,11 +824,11 @@ fn from_iter>(iter: I) -> Self { } } -impl HashStable for TokenStream +impl HashStable for TokenStream where - CTX: crate::HashStableContext, + Hcx: crate::HashStableContext, { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { for sub_tt in self.iter() { sub_tt.hash_stable(hcx, hasher); } diff --git a/compiler/rustc_codegen_cranelift/src/driver/aot.rs b/compiler/rustc_codegen_cranelift/src/driver/aot.rs index 79a321456808..b855e1fa4b78 100644 --- a/compiler/rustc_codegen_cranelift/src/driver/aot.rs +++ b/compiler/rustc_codegen_cranelift/src/driver/aot.rs @@ -45,8 +45,8 @@ enum OngoingModuleCodegen { Async(JoinHandle>), } -impl HashStable for OngoingModuleCodegen { - fn hash_stable(&self, _: &mut HCX, _: &mut StableHasher) { +impl HashStable for OngoingModuleCodegen { + fn hash_stable(&self, _: &mut Hcx, _: &mut StableHasher) { // do nothing } } diff --git a/compiler/rustc_codegen_ssa/src/common.rs b/compiler/rustc_codegen_ssa/src/common.rs index fe4d1da4329d..de79acd165f0 100644 --- a/compiler/rustc_codegen_ssa/src/common.rs +++ b/compiler/rustc_codegen_ssa/src/common.rs @@ -102,8 +102,8 @@ mod temp_stable_hash_impls { use crate::ModuleCodegen; - impl HashStable for ModuleCodegen { - fn hash_stable(&self, _: &mut HCX, _: &mut StableHasher) { + impl HashStable for ModuleCodegen { + fn hash_stable(&self, _: &mut Hcx, _: &mut StableHasher) { // do nothing } } diff --git a/compiler/rustc_data_structures/src/intern.rs b/compiler/rustc_data_structures/src/intern.rs index 8079212fac55..e196ff094159 100644 --- a/compiler/rustc_data_structures/src/intern.rs +++ b/compiler/rustc_data_structures/src/intern.rs @@ -103,11 +103,11 @@ fn hash(&self, s: &mut H) { } } -impl HashStable for Interned<'_, T> +impl HashStable for Interned<'_, T> where - T: HashStable, + T: HashStable, { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.0.hash_stable(hcx, hasher); } } diff --git a/compiler/rustc_data_structures/src/packed.rs b/compiler/rustc_data_structures/src/packed.rs index c8921536530a..eef25331987d 100644 --- a/compiler/rustc_data_structures/src/packed.rs +++ b/compiler/rustc_data_structures/src/packed.rs @@ -60,10 +60,10 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { } } -impl HashStable for Pu128 { +impl HashStable for Pu128 { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { - { self.0 }.hash_stable(ctx, hasher) + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + { self.0 }.hash_stable(hcx, hasher) } } diff --git a/compiler/rustc_data_structures/src/sorted_map.rs b/compiler/rustc_data_structures/src/sorted_map.rs index 15e3e6ea4c32..49c5272bd856 100644 --- a/compiler/rustc_data_structures/src/sorted_map.rs +++ b/compiler/rustc_data_structures/src/sorted_map.rs @@ -347,10 +347,10 @@ fn from_iter>(iter: T) -> Self { } } -impl + StableOrd, V: HashStable, CTX> HashStable for SortedMap { +impl + StableOrd, V: HashStable, Hcx> HashStable for SortedMap { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { - self.data.hash_stable(ctx, hasher); + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.data.hash_stable(hcx, hasher); } } diff --git a/compiler/rustc_data_structures/src/stable_hasher.rs b/compiler/rustc_data_structures/src/stable_hasher.rs index f8e72d66d07e..c9993d106d6d 100644 --- a/compiler/rustc_data_structures/src/stable_hasher.rs +++ b/compiler/rustc_data_structures/src/stable_hasher.rs @@ -15,7 +15,7 @@ FromStableHash, SipHasher128Hash as StableHasherHash, StableSipHasher128 as StableHasher, }; -/// Something that implements `HashStable` can be hashed in a way that is +/// Something that implements `HashStable` can be hashed in a way that is /// stable across multiple compilation sessions. /// /// Note that `HashStable` imposes rather more strict requirements than usual @@ -41,16 +41,16 @@ /// - `hash_stable()` must be independent of the host architecture. The /// `StableHasher` takes care of endianness and `isize`/`usize` platform /// differences. -pub trait HashStable { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher); +pub trait HashStable { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher); } /// Implement this for types that can be turned into stable keys like, for /// example, for DefId that can be converted to a DefPathHash. This is used for /// bringing maps into a predictable order before hashing them. -pub trait ToStableHashKey { - type KeyType: Ord + Sized + HashStable; - fn to_stable_hash_key(&self, hcx: &HCX) -> Self::KeyType; +pub trait ToStableHashKey { + type KeyType: Ord + Sized + HashStable; + fn to_stable_hash_key(&self, hcx: &Hcx) -> Self::KeyType; } /// Trait for marking a type as having a sort order that is @@ -136,9 +136,9 @@ fn stable_cmp(&self, other: &Self) -> std::cmp::Ordering { /// Use `#[derive(HashStable_Generic)]` instead. macro_rules! impl_stable_traits_for_trivial_type { ($t:ty) => { - impl $crate::stable_hasher::HashStable for $t { + impl $crate::stable_hasher::HashStable for $t { #[inline] - fn hash_stable(&self, _: &mut CTX, hasher: &mut $crate::stable_hasher::StableHasher) { + fn hash_stable(&self, _: &mut Hcx, hasher: &mut $crate::stable_hasher::StableHasher) { ::std::hash::Hash::hash(self, hasher); } } @@ -177,9 +177,9 @@ impl $crate::stable_hasher::StableOrd for $t { // We need a custom impl as the default hash function will only hash half the bits. For stable // hashing we want to hash the full 128-bit hash. -impl HashStable for Hash128 { +impl HashStable for Hash128 { #[inline] - fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, _: &mut Hcx, hasher: &mut StableHasher) { self.as_u128().hash(hasher); } } @@ -192,64 +192,64 @@ impl StableOrd for Hash128 { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl HashStable for ! { - fn hash_stable(&self, _ctx: &mut CTX, _hasher: &mut StableHasher) { +impl HashStable for ! { + fn hash_stable(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) { unreachable!() } } -impl HashStable for PhantomData { - fn hash_stable(&self, _ctx: &mut CTX, _hasher: &mut StableHasher) {} +impl HashStable for PhantomData { + fn hash_stable(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) {} } -impl HashStable for NonZero { +impl HashStable for NonZero { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { - self.get().hash_stable(ctx, hasher) + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.get().hash_stable(hcx, hasher) } } -impl HashStable for NonZero { +impl HashStable for NonZero { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { - self.get().hash_stable(ctx, hasher) + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.get().hash_stable(hcx, hasher) } } -impl HashStable for f32 { - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { +impl HashStable for f32 { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let val: u32 = self.to_bits(); - val.hash_stable(ctx, hasher); + val.hash_stable(hcx, hasher); } } -impl HashStable for f64 { - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { +impl HashStable for f64 { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let val: u64 = self.to_bits(); - val.hash_stable(ctx, hasher); + val.hash_stable(hcx, hasher); } } -impl HashStable for ::std::cmp::Ordering { +impl HashStable for ::std::cmp::Ordering { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { - (*self as i8).hash_stable(ctx, hasher); + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + (*self as i8).hash_stable(hcx, hasher); } } -impl, CTX> HashStable for (T1,) { +impl, Hcx> HashStable for (T1,) { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let (ref _0,) = *self; - _0.hash_stable(ctx, hasher); + _0.hash_stable(hcx, hasher); } } -impl, T2: HashStable, CTX> HashStable for (T1, T2) { - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { +impl, T2: HashStable, Hcx> HashStable for (T1, T2) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let (ref _0, ref _1) = *self; - _0.hash_stable(ctx, hasher); - _1.hash_stable(ctx, hasher); + _0.hash_stable(hcx, hasher); + _1.hash_stable(hcx, hasher); } } @@ -261,17 +261,17 @@ impl StableOrd for (T1, T2) { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl HashStable for (T1, T2, T3) +impl HashStable for (T1, T2, T3) where - T1: HashStable, - T2: HashStable, - T3: HashStable, + T1: HashStable, + T2: HashStable, + T3: HashStable, { - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let (ref _0, ref _1, ref _2) = *self; - _0.hash_stable(ctx, hasher); - _1.hash_stable(ctx, hasher); - _2.hash_stable(ctx, hasher); + _0.hash_stable(hcx, hasher); + _1.hash_stable(hcx, hasher); + _2.hash_stable(hcx, hasher); } } @@ -284,19 +284,19 @@ impl StableOrd for (T1, T2, T3) { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl HashStable for (T1, T2, T3, T4) +impl HashStable for (T1, T2, T3, T4) where - T1: HashStable, - T2: HashStable, - T3: HashStable, - T4: HashStable, + T1: HashStable, + T2: HashStable, + T3: HashStable, + T4: HashStable, { - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let (ref _0, ref _1, ref _2, ref _3) = *self; - _0.hash_stable(ctx, hasher); - _1.hash_stable(ctx, hasher); - _2.hash_stable(ctx, hasher); - _3.hash_stable(ctx, hasher); + _0.hash_stable(hcx, hasher); + _1.hash_stable(hcx, hasher); + _2.hash_stable(hcx, hasher); + _3.hash_stable(hcx, hasher); } } @@ -311,93 +311,93 @@ impl StableOrd for ( const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl, CTX> HashStable for [T] { - default fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { - self.len().hash_stable(ctx, hasher); +impl, Hcx> HashStable for [T] { + default fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.len().hash_stable(hcx, hasher); for item in self { - item.hash_stable(ctx, hasher); + item.hash_stable(hcx, hasher); } } } -impl HashStable for [u8] { - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { - self.len().hash_stable(ctx, hasher); +impl HashStable for [u8] { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.len().hash_stable(hcx, hasher); hasher.write(self); } } -impl, CTX> HashStable for Vec { +impl, Hcx> HashStable for Vec { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { - self[..].hash_stable(ctx, hasher); + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self[..].hash_stable(hcx, hasher); } } -impl HashStable for indexmap::IndexMap +impl HashStable for indexmap::IndexMap where - K: HashStable + Eq + Hash, - V: HashStable, + K: HashStable + Eq + Hash, + V: HashStable, R: BuildHasher, { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { - self.len().hash_stable(ctx, hasher); + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.len().hash_stable(hcx, hasher); for kv in self { - kv.hash_stable(ctx, hasher); + kv.hash_stable(hcx, hasher); } } } -impl HashStable for indexmap::IndexSet +impl HashStable for indexmap::IndexSet where - K: HashStable + Eq + Hash, + K: HashStable + Eq + Hash, R: BuildHasher, { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { - self.len().hash_stable(ctx, hasher); + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.len().hash_stable(hcx, hasher); for key in self { - key.hash_stable(ctx, hasher); + key.hash_stable(hcx, hasher); } } } -impl HashStable for SmallVec<[A; N]> +impl HashStable for SmallVec<[A; N]> where - A: HashStable, + A: HashStable, { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { - self[..].hash_stable(ctx, hasher); + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self[..].hash_stable(hcx, hasher); } } -impl, CTX> HashStable for Box { +impl, Hcx> HashStable for Box { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { - (**self).hash_stable(ctx, hasher); + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + (**self).hash_stable(hcx, hasher); } } -impl, CTX> HashStable for ::std::rc::Rc { +impl, Hcx> HashStable for ::std::rc::Rc { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { - (**self).hash_stable(ctx, hasher); + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + (**self).hash_stable(hcx, hasher); } } -impl, CTX> HashStable for ::std::sync::Arc { +impl, Hcx> HashStable for ::std::sync::Arc { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { - (**self).hash_stable(ctx, hasher); + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + (**self).hash_stable(hcx, hasher); } } -impl HashStable for str { +impl HashStable for str { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { - self.as_bytes().hash_stable(ctx, hasher); + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.as_bytes().hash_stable(hcx, hasher); } } @@ -409,9 +409,9 @@ impl StableOrd for &str { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl HashStable for String { +impl HashStable for String { #[inline] - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self[..].hash_stable(hcx, hasher); } } @@ -424,26 +424,26 @@ impl StableOrd for String { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl ToStableHashKey for String { +impl ToStableHashKey for String { type KeyType = String; #[inline] - fn to_stable_hash_key(&self, _: &HCX) -> Self::KeyType { + fn to_stable_hash_key(&self, _: &Hcx) -> Self::KeyType { self.clone() } } -impl, T2: ToStableHashKey> ToStableHashKey for (T1, T2) { +impl, T2: ToStableHashKey> ToStableHashKey for (T1, T2) { type KeyType = (T1::KeyType, T2::KeyType); #[inline] - fn to_stable_hash_key(&self, hcx: &HCX) -> Self::KeyType { + fn to_stable_hash_key(&self, hcx: &Hcx) -> Self::KeyType { (self.0.to_stable_hash_key(hcx), self.1.to_stable_hash_key(hcx)) } } -impl HashStable for bool { +impl HashStable for bool { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { - (if *self { 1u8 } else { 0u8 }).hash_stable(ctx, hasher); + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + (if *self { 1u8 } else { 0u8 }).hash_stable(hcx, hasher); } } @@ -454,17 +454,17 @@ impl StableOrd for bool { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl HashStable for Option +impl HashStable for Option where - T: HashStable, + T: HashStable, { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { if let Some(ref value) = *self { - 1u8.hash_stable(ctx, hasher); - value.hash_stable(ctx, hasher); + 1u8.hash_stable(hcx, hasher); + value.hash_stable(hcx, hasher); } else { - 0u8.hash_stable(ctx, hasher); + 0u8.hash_stable(hcx, hasher); } } } @@ -476,81 +476,81 @@ impl StableOrd for Option { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl HashStable for Result +impl HashStable for Result where - T1: HashStable, - T2: HashStable, + T1: HashStable, + T2: HashStable, { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { - mem::discriminant(self).hash_stable(ctx, hasher); + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + mem::discriminant(self).hash_stable(hcx, hasher); match *self { - Ok(ref x) => x.hash_stable(ctx, hasher), - Err(ref x) => x.hash_stable(ctx, hasher), + Ok(ref x) => x.hash_stable(hcx, hasher), + Err(ref x) => x.hash_stable(hcx, hasher), } } } -impl<'a, T, CTX> HashStable for &'a T +impl<'a, T, Hcx> HashStable for &'a T where - T: HashStable + ?Sized, + T: HashStable + ?Sized, { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { - (**self).hash_stable(ctx, hasher); + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + (**self).hash_stable(hcx, hasher); } } -impl HashStable for ::std::mem::Discriminant { +impl HashStable for ::std::mem::Discriminant { #[inline] - fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, _: &mut Hcx, hasher: &mut StableHasher) { ::std::hash::Hash::hash(self, hasher); } } -impl HashStable for ::std::ops::RangeInclusive +impl HashStable for ::std::ops::RangeInclusive where - T: HashStable, + T: HashStable, { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { - self.start().hash_stable(ctx, hasher); - self.end().hash_stable(ctx, hasher); + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.start().hash_stable(hcx, hasher); + self.end().hash_stable(hcx, hasher); } } -impl HashStable for IndexSlice +impl HashStable for IndexSlice where - T: HashStable, + T: HashStable, { - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { - self.len().hash_stable(ctx, hasher); + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.len().hash_stable(hcx, hasher); for v in &self.raw { - v.hash_stable(ctx, hasher); + v.hash_stable(hcx, hasher); } } } -impl HashStable for IndexVec +impl HashStable for IndexVec where - T: HashStable, + T: HashStable, { - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { - self.len().hash_stable(ctx, hasher); + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.len().hash_stable(hcx, hasher); for v in &self.raw { - v.hash_stable(ctx, hasher); + v.hash_stable(hcx, hasher); } } } -impl HashStable for DenseBitSet { - fn hash_stable(&self, _ctx: &mut CTX, hasher: &mut StableHasher) { +impl HashStable for DenseBitSet { + fn hash_stable(&self, _hcx: &mut Hcx, hasher: &mut StableHasher) { ::std::hash::Hash::hash(self, hasher); } } -impl HashStable for bit_set::BitMatrix { - fn hash_stable(&self, _ctx: &mut CTX, hasher: &mut StableHasher) { +impl HashStable for bit_set::BitMatrix { + fn hash_stable(&self, _hcx: &mut Hcx, hasher: &mut StableHasher) { ::std::hash::Hash::hash(self, hasher); } } @@ -563,15 +563,15 @@ fn hash_stable(&self, _ctx: &mut CTX, hasher: &mut StableHasher) { // It is not safe to implement HashStable for HashSet, HashMap or any other collection type // with unstable but observable iteration order. // See https://github.com/rust-lang/compiler-team/issues/533 for further information. -impl !HashStable for std::collections::HashSet {} -impl !HashStable for std::collections::HashMap {} +impl !HashStable for std::collections::HashSet {} +impl !HashStable for std::collections::HashMap {} -impl HashStable for ::std::collections::BTreeMap +impl HashStable for ::std::collections::BTreeMap where - K: HashStable + StableOrd, - V: HashStable, + K: HashStable + StableOrd, + V: HashStable, { - fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.len().hash_stable(hcx, hasher); for entry in self.iter() { entry.hash_stable(hcx, hasher); @@ -579,11 +579,11 @@ fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) { } } -impl HashStable for ::std::collections::BTreeSet +impl HashStable for ::std::collections::BTreeSet where - K: HashStable + StableOrd, + K: HashStable + StableOrd, { - fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.len().hash_stable(hcx, hasher); for entry in self.iter() { entry.hash_stable(hcx, hasher); diff --git a/compiler/rustc_data_structures/src/stable_hasher/tests.rs b/compiler/rustc_data_structures/src/stable_hasher/tests.rs index 635f241847c4..55a666d2d0fc 100644 --- a/compiler/rustc_data_structures/src/stable_hasher/tests.rs +++ b/compiler/rustc_data_structures/src/stable_hasher/tests.rs @@ -44,8 +44,8 @@ struct Foo { b: $ty, } - impl HashStable for Foo { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { + impl HashStable for Foo { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.a.hash_stable(hcx, hasher); self.b.hash_stable(hcx, hasher); } diff --git a/compiler/rustc_data_structures/src/steal.rs b/compiler/rustc_data_structures/src/steal.rs index afa9bc36f2c5..184acfe8ca1a 100644 --- a/compiler/rustc_data_structures/src/steal.rs +++ b/compiler/rustc_data_structures/src/steal.rs @@ -71,8 +71,8 @@ pub fn is_stolen(&self) -> bool { } } -impl> HashStable for Steal { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { +impl> HashStable for Steal { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.borrow().hash_stable(hcx, hasher); } } diff --git a/compiler/rustc_data_structures/src/tagged_ptr.rs b/compiler/rustc_data_structures/src/tagged_ptr.rs index 71e5e0b412e8..32f813811089 100644 --- a/compiler/rustc_data_structures/src/tagged_ptr.rs +++ b/compiler/rustc_data_structures/src/tagged_ptr.rs @@ -262,12 +262,12 @@ fn hash(&self, state: &mut H) { } } -impl<'a, P, T, HCX> HashStable for TaggedRef<'a, P, T> +impl<'a, P, T, Hcx> HashStable for TaggedRef<'a, P, T> where - P: HashStable + Aligned + ?Sized, - T: Tag + HashStable, + P: HashStable + Aligned + ?Sized, + T: Tag + HashStable, { - fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.pointer().hash_stable(hcx, hasher); self.tag().hash_stable(hcx, hasher); } diff --git a/compiler/rustc_data_structures/src/tagged_ptr/tests.rs b/compiler/rustc_data_structures/src/tagged_ptr/tests.rs index 85b21a7c8ecd..e663df5105f9 100644 --- a/compiler/rustc_data_structures/src/tagged_ptr/tests.rs +++ b/compiler/rustc_data_structures/src/tagged_ptr/tests.rs @@ -32,8 +32,8 @@ unsafe fn from_usize(tag: usize) -> Self { } } -impl crate::stable_hasher::HashStable for Tag2 { - fn hash_stable(&self, hcx: &mut HCX, hasher: &mut crate::stable_hasher::StableHasher) { +impl crate::stable_hasher::HashStable for Tag2 { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut crate::stable_hasher::StableHasher) { (*self as u8).hash_stable(hcx, hasher); } } diff --git a/compiler/rustc_data_structures/src/unord.rs b/compiler/rustc_data_structures/src/unord.rs index eb29ef3b4d0a..8a3b3e2e98cd 100644 --- a/compiler/rustc_data_structures/src/unord.rs +++ b/compiler/rustc_data_structures/src/unord.rs @@ -143,9 +143,9 @@ pub fn copied(self) -> UnordItems> { impl> UnordItems { #[inline] - pub fn into_sorted(self, hcx: &HCX) -> Vec + pub fn into_sorted(self, hcx: &Hcx) -> Vec where - T: ToStableHashKey, + T: ToStableHashKey, { self.collect_sorted(hcx, true) } @@ -168,9 +168,9 @@ pub fn into_sorted_stable_ord_by_key(self, project_to_key: C) -> Vec } #[inline] - pub fn collect_sorted(self, hcx: &HCX, cache_sort_key: bool) -> C + pub fn collect_sorted(self, hcx: &Hcx, cache_sort_key: bool) -> C where - T: ToStableHashKey, + T: ToStableHashKey, C: FromIterator + BorrowMut<[T]>, { let mut items: C = self.0.collect(); @@ -315,9 +315,9 @@ pub fn into_items(self) -> UnordItems> { /// `cache_sort_key` when the [ToStableHashKey::to_stable_hash_key] implementation /// for `V` is expensive (e.g. a `DefId -> DefPathHash` lookup). #[inline] - pub fn to_sorted(&self, hcx: &HCX, cache_sort_key: bool) -> Vec<&V> + pub fn to_sorted(&self, hcx: &Hcx, cache_sort_key: bool) -> Vec<&V> where - V: ToStableHashKey, + V: ToStableHashKey, { to_sorted_vec(hcx, self.inner.iter(), cache_sort_key, |&x| x) } @@ -357,9 +357,9 @@ pub fn into_sorted_stable_ord(self) -> Vec /// `cache_sort_key` when the [ToStableHashKey::to_stable_hash_key] implementation /// for `V` is expensive (e.g. a `DefId -> DefPathHash` lookup). #[inline] - pub fn into_sorted(self, hcx: &HCX, cache_sort_key: bool) -> Vec + pub fn into_sorted(self, hcx: &Hcx, cache_sort_key: bool) -> Vec where - V: ToStableHashKey, + V: ToStableHashKey, { to_sorted_vec(hcx, self.inner.into_iter(), cache_sort_key, |x| x) } @@ -415,9 +415,9 @@ fn from(value: UnordItems) -> Self { } } -impl> HashStable for UnordSet { +impl> HashStable for UnordSet { #[inline] - fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { hash_iter_order_independent(self.inner.iter(), hcx, hasher); } } @@ -555,9 +555,9 @@ pub fn keys(&self) -> UnordItems<&K, impl Iterator> { /// `cache_sort_key` when the [ToStableHashKey::to_stable_hash_key] implementation /// for `K` is expensive (e.g. a `DefId -> DefPathHash` lookup). #[inline] - pub fn to_sorted(&self, hcx: &HCX, cache_sort_key: bool) -> Vec<(&K, &V)> + pub fn to_sorted(&self, hcx: &Hcx, cache_sort_key: bool) -> Vec<(&K, &V)> where - K: ToStableHashKey, + K: ToStableHashKey, { to_sorted_vec(hcx, self.inner.iter(), cache_sort_key, |&(k, _)| k) } @@ -582,9 +582,9 @@ pub fn to_sorted_stable_ord(&self) -> Vec<(&K, &V)> /// `cache_sort_key` when the [ToStableHashKey::to_stable_hash_key] implementation /// for `K` is expensive (e.g. a `DefId -> DefPathHash` lookup). #[inline] - pub fn into_sorted(self, hcx: &HCX, cache_sort_key: bool) -> Vec<(K, V)> + pub fn into_sorted(self, hcx: &Hcx, cache_sort_key: bool) -> Vec<(K, V)> where - K: ToStableHashKey, + K: ToStableHashKey, { to_sorted_vec(hcx, self.inner.into_iter(), cache_sort_key, |(k, _)| k) } @@ -610,9 +610,9 @@ pub fn into_sorted_stable_ord(self) -> Vec<(K, V)> /// `cache_sort_key` when the [ToStableHashKey::to_stable_hash_key] implementation /// for `K` is expensive (e.g. a `DefId -> DefPathHash` lookup). #[inline] - pub fn values_sorted(&self, hcx: &HCX, cache_sort_key: bool) -> impl Iterator + pub fn values_sorted(&self, hcx: &Hcx, cache_sort_key: bool) -> impl Iterator where - K: ToStableHashKey, + K: ToStableHashKey, { to_sorted_vec(hcx, self.inner.iter(), cache_sort_key, |&(k, _)| k) .into_iter() @@ -638,9 +638,9 @@ fn index(&self, key: &Q) -> &V { } } -impl, V: HashStable> HashStable for UnordMap { +impl, V: HashStable> HashStable for UnordMap { #[inline] - fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { hash_iter_order_independent(self.inner.iter(), hcx, hasher); } } @@ -701,23 +701,23 @@ fn from(value: UnordItems) -> Self { } } -impl> HashStable for UnordBag { +impl> HashStable for UnordBag { #[inline] - fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { hash_iter_order_independent(self.inner.iter(), hcx, hasher); } } #[inline] -fn to_sorted_vec( - hcx: &HCX, +fn to_sorted_vec( + hcx: &Hcx, iter: I, cache_sort_key: bool, extract_key: fn(&T) -> &K, ) -> Vec where I: Iterator, - K: ToStableHashKey, + K: ToStableHashKey, { let mut items: Vec = iter.collect(); if cache_sort_key { @@ -730,12 +730,12 @@ fn to_sorted_vec( } fn hash_iter_order_independent< - HCX, - T: HashStable, + Hcx, + T: HashStable, I: Iterator + ExactSizeIterator, >( mut it: I, - hcx: &mut HCX, + hcx: &mut Hcx, hasher: &mut StableHasher, ) { let len = it.len(); diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs index 2156c987906c..78bd709dd484 100644 --- a/compiler/rustc_hir/src/def.rs +++ b/compiler/rustc_hir/src/def.rs @@ -712,11 +712,11 @@ fn into_diag_arg(self, _: &mut Option) -> DiagArgValue { } } -impl ToStableHashKey for Namespace { +impl ToStableHashKey for Namespace { type KeyType = Namespace; #[inline] - fn to_stable_hash_key(&self, _: &CTX) -> Namespace { + fn to_stable_hash_key(&self, _: &Hcx) -> Namespace { *self } } diff --git a/compiler/rustc_hir/src/lang_items.rs b/compiler/rustc_hir/src/lang_items.rs index 80f0af9d663c..c144f0b7dbc5 100644 --- a/compiler/rustc_hir/src/lang_items.rs +++ b/compiler/rustc_hir/src/lang_items.rs @@ -144,8 +144,8 @@ pub fn $method(&self) -> Option { } } -impl HashStable for LangItem { - fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher) { +impl HashStable for LangItem { + fn hash_stable(&self, _: &mut Hcx, hasher: &mut StableHasher) { ::std::hash::Hash::hash(self, hasher); } } diff --git a/compiler/rustc_hir_id/src/lib.rs b/compiler/rustc_hir_id/src/lib.rs index d6deed59b625..ffff3f979f9e 100644 --- a/compiler/rustc_hir_id/src/lib.rs +++ b/compiler/rustc_hir_id/src/lib.rs @@ -54,18 +54,18 @@ fn index(self) -> usize { } } -impl HashStable for OwnerId { +impl HashStable for OwnerId { #[inline] - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.to_stable_hash_key(hcx).hash_stable(hcx, hasher); } } -impl ToStableHashKey for OwnerId { +impl ToStableHashKey for OwnerId { type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, hcx: &CTX) -> DefPathHash { + fn to_stable_hash_key(&self, hcx: &Hcx) -> DefPathHash { hcx.def_path_hash(self.to_def_id()) } } @@ -176,21 +176,21 @@ impl StableOrd for ItemLocalId { pub const CRATE_OWNER_ID: OwnerId = OwnerId { def_id: CRATE_DEF_ID }; -impl ToStableHashKey for HirId { +impl ToStableHashKey for HirId { type KeyType = (DefPathHash, ItemLocalId); #[inline] - fn to_stable_hash_key(&self, hcx: &CTX) -> (DefPathHash, ItemLocalId) { + fn to_stable_hash_key(&self, hcx: &Hcx) -> (DefPathHash, ItemLocalId) { let def_path_hash = self.owner.def_id.to_stable_hash_key(hcx); (def_path_hash, self.local_id) } } -impl ToStableHashKey for ItemLocalId { +impl ToStableHashKey for ItemLocalId { type KeyType = ItemLocalId; #[inline] - fn to_stable_hash_key(&self, _: &CTX) -> ItemLocalId { + fn to_stable_hash_key(&self, _: &Hcx) -> ItemLocalId { *self } } diff --git a/compiler/rustc_index_macros/src/newtype.rs b/compiler/rustc_index_macros/src/newtype.rs index 282403294db9..b6ee283e736c 100644 --- a/compiler/rustc_index_macros/src/newtype.rs +++ b/compiler/rustc_index_macros/src/newtype.rs @@ -174,8 +174,8 @@ fn hash_stable(&self, hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx } else if stable_hash_generic || stable_hash_no_context { quote! { #gate_rustc_only - impl ::rustc_data_structures::stable_hasher::HashStable for #name { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut ::rustc_data_structures::stable_hasher::StableHasher) { + impl ::rustc_data_structures::stable_hasher::HashStable for #name { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut ::rustc_data_structures::stable_hasher::StableHasher) { self.as_u32().hash_stable(hcx, hasher) } } diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index 0528a0d69324..af1d1854fa5a 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -138,9 +138,9 @@ pub fn set_lint_index(&mut self, new_lint_index: Option) { } } -impl HashStable for LintExpectationId { +impl HashStable for LintExpectationId { #[inline] - fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { match self { LintExpectationId::Stable { hir_id, attr_index, lint_index: Some(lint_index) } => { hir_id.hash_stable(hcx, hasher); @@ -156,11 +156,11 @@ fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) { } } -impl ToStableHashKey for LintExpectationId { +impl ToStableHashKey for LintExpectationId { type KeyType = (DefPathHash, ItemLocalId, u16, u16); #[inline] - fn to_stable_hash_key(&self, hcx: &HCX) -> Self::KeyType { + fn to_stable_hash_key(&self, hcx: &Hcx) -> Self::KeyType { match self { LintExpectationId::Stable { hir_id, attr_index, lint_index: Some(lint_index) } => { let (def_path_hash, lint_idx) = hir_id.to_stable_hash_key(hcx); @@ -621,18 +621,18 @@ pub fn to_string(&self) -> String { } } -impl HashStable for LintId { +impl HashStable for LintId { #[inline] - fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.lint_name_raw().hash_stable(hcx, hasher); } } -impl ToStableHashKey for LintId { +impl ToStableHashKey for LintId { type KeyType = &'static str; #[inline] - fn to_stable_hash_key(&self, _: &HCX) -> &'static str { + fn to_stable_hash_key(&self, _: &Hcx) -> &'static str { self.lint_name_raw() } } diff --git a/compiler/rustc_middle/src/dep_graph/dep_node.rs b/compiler/rustc_middle/src/dep_graph/dep_node.rs index b5f0692b61ce..987aa3e2a2c2 100644 --- a/compiler/rustc_middle/src/dep_graph/dep_node.rs +++ b/compiler/rustc_middle/src/dep_graph/dep_node.rs @@ -251,10 +251,10 @@ pub fn from_cgu_name(cgu_name: &str) -> WorkProductId { WorkProductId { hash: hasher.finish() } } } -impl ToStableHashKey for WorkProductId { +impl ToStableHashKey for WorkProductId { type KeyType = Fingerprint; #[inline] - fn to_stable_hash_key(&self, _: &HCX) -> Self::KeyType { + fn to_stable_hash_key(&self, _: &Hcx) -> Self::KeyType { self.hash } } diff --git a/compiler/rustc_middle/src/mir/basic_blocks.rs b/compiler/rustc_middle/src/mir/basic_blocks.rs index bd8c022ef42a..1d394525c0f7 100644 --- a/compiler/rustc_middle/src/mir/basic_blocks.rs +++ b/compiler/rustc_middle/src/mir/basic_blocks.rs @@ -171,7 +171,7 @@ fn decode(_: &mut D) -> Self { } } -impl HashStable for Cache { +impl HashStable for Cache { #[inline] - fn hash_stable(&self, _: &mut CTX, _: &mut StableHasher) {} + fn hash_stable(&self, _: &mut Hcx, _: &mut StableHasher) {} } diff --git a/compiler/rustc_middle/src/ty/consts/int.rs b/compiler/rustc_middle/src/ty/consts/int.rs index 180ccd9301c4..25ad8a5e0820 100644 --- a/compiler/rustc_middle/src/ty/consts/int.rs +++ b/compiler/rustc_middle/src/ty/consts/int.rs @@ -151,8 +151,8 @@ pub struct ScalarInt { // Cannot derive these, as the derives take references to the fields, and we // can't take references to fields of packed structs. -impl crate::ty::HashStable for ScalarInt { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut crate::ty::StableHasher) { +impl crate::ty::HashStable for ScalarInt { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut crate::ty::StableHasher) { // Using a block `{self.data}` here to force a copy instead of using `self.data` // directly, because `hash_stable` takes `&self` and would thus borrow `self.data`. // Since `Self` is a packed struct, that would create a possibly unaligned reference, diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 28688bcbfafc..a81697cc96db 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -607,7 +607,7 @@ pub struct TyCtxtFeed<'tcx, KEY: Copy> { /// Never return a `Feed` from a query. Only queries that create a `DefId` are /// allowed to feed queries for that `DefId`. -impl !HashStable for TyCtxtFeed<'_, KEY> {} +impl !HashStable for TyCtxtFeed<'_, KEY> {} /// The same as `TyCtxtFeed`, but does not contain a `TyCtxt`. /// Use this to pass around when you have a `TyCtxt` elsewhere. @@ -622,7 +622,7 @@ pub struct Feed<'tcx, KEY: Copy> { /// Never return a `Feed` from a query. Only queries that create a `DefId` are /// allowed to feed queries for that `DefId`. -impl !HashStable for Feed<'_, KEY> {} +impl !HashStable for Feed<'_, KEY> {} impl fmt::Debug for Feed<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 42d5a50df699..e37247d7dd83 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -636,10 +636,10 @@ impl StableOrd for OutputType { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } - impl ToStableHashKey for OutputType { + impl ToStableHashKey for OutputType { type KeyType = Self; - fn to_stable_hash_key(&self, _: &HCX) -> Self::KeyType { + fn to_stable_hash_key(&self, _: &Hcx) -> Self::KeyType { *self } } diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs index 82d455ab54f0..8c313c7f8b3a 100644 --- a/compiler/rustc_span/src/def_id.rs +++ b/compiler/rustc_span/src/def_id.rs @@ -402,59 +402,59 @@ fn decode(d: &mut D) -> LocalDefId { LocalDefId ); -impl HashStable for DefId { +impl HashStable for DefId { #[inline] - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { hcx.def_path_hash(*self).hash_stable(hcx, hasher); } } -impl HashStable for LocalDefId { +impl HashStable for LocalDefId { #[inline] - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { hcx.def_path_hash(self.to_def_id()).local_hash().hash_stable(hcx, hasher); } } -impl HashStable for CrateNum { +impl HashStable for CrateNum { #[inline] - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.as_def_id().to_stable_hash_key(hcx).stable_crate_id().hash_stable(hcx, hasher); } } -impl ToStableHashKey for DefId { +impl ToStableHashKey for DefId { type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, hcx: &CTX) -> DefPathHash { + fn to_stable_hash_key(&self, hcx: &Hcx) -> DefPathHash { hcx.def_path_hash(*self) } } -impl ToStableHashKey for LocalDefId { +impl ToStableHashKey for LocalDefId { type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, hcx: &CTX) -> DefPathHash { + fn to_stable_hash_key(&self, hcx: &Hcx) -> DefPathHash { hcx.def_path_hash(self.to_def_id()) } } -impl ToStableHashKey for CrateNum { +impl ToStableHashKey for CrateNum { type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, hcx: &CTX) -> DefPathHash { + fn to_stable_hash_key(&self, hcx: &Hcx) -> DefPathHash { self.as_def_id().to_stable_hash_key(hcx) } } -impl ToStableHashKey for DefPathHash { +impl ToStableHashKey for DefPathHash { type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, _: &CTX) -> DefPathHash { + fn to_stable_hash_key(&self, _: &Hcx) -> DefPathHash { *self } } diff --git a/compiler/rustc_span/src/hygiene.rs b/compiler/rustc_span/src/hygiene.rs index 25834f03af5e..e7b98cc91097 100644 --- a/compiler/rustc_span/src/hygiene.rs +++ b/compiler/rustc_span/src/hygiene.rs @@ -207,9 +207,9 @@ pub fn fresh_empty() -> LocalExpnId { }) } - pub fn fresh(mut expn_data: ExpnData, ctx: impl HashStableContext) -> LocalExpnId { + pub fn fresh(mut expn_data: ExpnData, hcx: impl HashStableContext) -> LocalExpnId { debug_assert_eq!(expn_data.parent.krate, LOCAL_CRATE); - let expn_hash = update_disambiguator(&mut expn_data, ctx); + let expn_hash = update_disambiguator(&mut expn_data, hcx); HygieneData::with(|data| { let expn_id = data.local_expn_data.push(Some(expn_data)); let _eid = data.local_expn_hashes.push(expn_hash); @@ -231,9 +231,9 @@ pub fn to_expn_id(self) -> ExpnId { } #[inline] - pub fn set_expn_data(self, mut expn_data: ExpnData, ctx: impl HashStableContext) { + pub fn set_expn_data(self, mut expn_data: ExpnData, hcx: impl HashStableContext) { debug_assert_eq!(expn_data.parent.krate, LOCAL_CRATE); - let expn_hash = update_disambiguator(&mut expn_data, ctx); + let expn_hash = update_disambiguator(&mut expn_data, hcx); HygieneData::with(|data| { let old_expn_data = &mut data.local_expn_data[self]; assert!(old_expn_data.is_none(), "expansion data is reset for an expansion ID"); @@ -950,13 +950,13 @@ pub fn mark_with_reason( allow_internal_unstable: Option>, reason: DesugaringKind, edition: Edition, - ctx: impl HashStableContext, + hcx: impl HashStableContext, ) -> Span { let expn_data = ExpnData { allow_internal_unstable, ..ExpnData::default(ExpnKind::Desugaring(reason), self, edition, None, None) }; - let expn_id = LocalExpnId::fresh(expn_data, ctx); + let expn_id = LocalExpnId::fresh(expn_data, hcx); self.apply_mark(expn_id.to_expn_id(), Transparency::Transparent) } } @@ -1102,9 +1102,9 @@ pub fn is_root(&self) -> bool { } #[inline] - fn hash_expn(&self, ctx: &mut impl HashStableContext) -> Hash64 { + fn hash_expn(&self, hcx: &mut impl HashStableContext) -> Hash64 { let mut hasher = StableHasher::new(); - self.hash_stable(ctx, &mut hasher); + self.hash_stable(hcx, &mut hasher); hasher.finish() } } @@ -1482,11 +1482,11 @@ pub fn raw_encode_syntax_context( /// `set_expn_data`). It is *not* called for foreign `ExpnId`s deserialized /// from another crate's metadata - since `ExpnHash` includes the stable crate id, /// collisions are only possible between `ExpnId`s within the same crate. -fn update_disambiguator(expn_data: &mut ExpnData, mut ctx: impl HashStableContext) -> ExpnHash { +fn update_disambiguator(expn_data: &mut ExpnData, mut hcx: impl HashStableContext) -> ExpnHash { // This disambiguator should not have been set yet. assert_eq!(expn_data.disambiguator, 0, "Already set disambiguator for ExpnData: {expn_data:?}"); - ctx.assert_default_hashing_controls("ExpnData (disambiguator)"); - let mut expn_hash = expn_data.hash_expn(&mut ctx); + hcx.assert_default_hashing_controls("ExpnData (disambiguator)"); + let mut expn_hash = expn_data.hash_expn(&mut hcx); let disambiguator = HygieneData::with(|data| { // If this is the first ExpnData with a given hash, then keep our @@ -1501,7 +1501,7 @@ fn update_disambiguator(expn_data: &mut ExpnData, mut ctx: impl HashStableContex debug!("Set disambiguator for expn_data={:?} expn_hash={:?}", expn_data, expn_hash); expn_data.disambiguator = disambiguator; - expn_hash = expn_data.hash_expn(&mut ctx); + expn_hash = expn_data.hash_expn(&mut hcx); // Verify that the new disambiguator makes the hash unique #[cfg(debug_assertions)] @@ -1514,28 +1514,28 @@ fn update_disambiguator(expn_data: &mut ExpnData, mut ctx: impl HashStableContex }); } - ExpnHash::new(ctx.def_path_hash(LOCAL_CRATE.as_def_id()).stable_crate_id(), expn_hash) + ExpnHash::new(hcx.def_path_hash(LOCAL_CRATE.as_def_id()).stable_crate_id(), expn_hash) } -impl HashStable for SyntaxContext { - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { +impl HashStable for SyntaxContext { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { const TAG_EXPANSION: u8 = 0; const TAG_NO_EXPANSION: u8 = 1; if self.is_root() { - TAG_NO_EXPANSION.hash_stable(ctx, hasher); + TAG_NO_EXPANSION.hash_stable(hcx, hasher); } else { - TAG_EXPANSION.hash_stable(ctx, hasher); + TAG_EXPANSION.hash_stable(hcx, hasher); let (expn_id, transparency) = self.outer_mark(); - expn_id.hash_stable(ctx, hasher); - transparency.hash_stable(ctx, hasher); + expn_id.hash_stable(hcx, hasher); + transparency.hash_stable(hcx, hasher); } } } -impl HashStable for ExpnId { - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { - ctx.assert_default_hashing_controls("ExpnId"); +impl HashStable for ExpnId { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + hcx.assert_default_hashing_controls("ExpnId"); let hash = if *self == ExpnId::root() { // Avoid fetching TLS storage for a trivial often-used value. Fingerprint::ZERO @@ -1543,12 +1543,12 @@ fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { self.expn_hash().0 }; - hash.hash_stable(ctx, hasher); + hash.hash_stable(hcx, hasher); } } -impl HashStable for LocalExpnId { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { +impl HashStable for LocalExpnId { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.to_expn_id().hash_stable(hcx, hasher); } } diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index d7d2ecb5bbe7..6794ffb311e3 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -2812,13 +2812,13 @@ pub trait HashStableContext { fn assert_default_hashing_controls(&self, msg: &str); } -impl HashStable for Span +impl HashStable for Span where - CTX: HashStableContext, + Hcx: HashStableContext, { - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { // `span_hash_stable` does all the work. - ctx.span_hash_stable(*self, hasher) + hcx.span_hash_stable(*self, hasher) } } diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index ccd4516372d2..179b784623e1 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -2598,17 +2598,17 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { } } -impl HashStable for Symbol { +impl HashStable for Symbol { #[inline] - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.as_str().hash_stable(hcx, hasher); } } -impl ToStableHashKey for Symbol { +impl ToStableHashKey for Symbol { type KeyType = String; #[inline] - fn to_stable_hash_key(&self, _: &CTX) -> String { + fn to_stable_hash_key(&self, _: &Hcx) -> String { self.as_str().to_string() } } @@ -2658,9 +2658,9 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { } } -impl HashStable for ByteSymbol { +impl HashStable for ByteSymbol { #[inline] - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.as_byte_str().hash_stable(hcx, hasher); } } diff --git a/compiler/rustc_type_ir/src/const_kind.rs b/compiler/rustc_type_ir/src/const_kind.rs index 49fb94c830e2..9786608ab4bc 100644 --- a/compiler/rustc_type_ir/src/const_kind.rs +++ b/compiler/rustc_type_ir/src/const_kind.rs @@ -117,8 +117,8 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { } #[cfg(feature = "nightly")] -impl HashStable for InferConst { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { +impl HashStable for InferConst { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { match self { InferConst::Var(_) => { panic!("const variables should not be hashed: {self:?}") diff --git a/compiler/rustc_type_ir/src/fast_reject.rs b/compiler/rustc_type_ir/src/fast_reject.rs index ed6416a7f55f..5e24e53c62d9 100644 --- a/compiler/rustc_type_ir/src/fast_reject.rs +++ b/compiler/rustc_type_ir/src/fast_reject.rs @@ -50,13 +50,13 @@ pub enum SimplifiedType { } #[cfg(feature = "nightly")] -impl> ToStableHashKey for SimplifiedType { +impl> ToStableHashKey for SimplifiedType { type KeyType = Fingerprint; #[inline] - fn to_stable_hash_key(&self, hcx: &HCX) -> Fingerprint { + fn to_stable_hash_key(&self, hcx: &Hcx) -> Fingerprint { let mut hasher = StableHasher::new(); - let mut hcx: HCX = hcx.clone(); + let mut hcx: Hcx = hcx.clone(); self.hash_stable(&mut hcx, &mut hasher); hasher.finish() } diff --git a/compiler/rustc_type_ir/src/region_kind.rs b/compiler/rustc_type_ir/src/region_kind.rs index 4c1b0700da58..d1076be20bae 100644 --- a/compiler/rustc_type_ir/src/region_kind.rs +++ b/compiler/rustc_type_ir/src/region_kind.rs @@ -217,15 +217,15 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { #[cfg(feature = "nightly")] // This is not a derived impl because a derive would require `I: HashStable` -impl HashStable for RegionKind +impl HashStable for RegionKind where - I::EarlyParamRegion: HashStable, - I::LateParamRegion: HashStable, - I::DefId: HashStable, - I::Symbol: HashStable, + I::EarlyParamRegion: HashStable, + I::LateParamRegion: HashStable, + I::DefId: HashStable, + I::Symbol: HashStable, { #[inline] - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { std::mem::discriminant(self).hash_stable(hcx, hasher); match self { ReErased | ReStatic | ReError(_) => { diff --git a/compiler/rustc_type_ir/src/ty_info.rs b/compiler/rustc_type_ir/src/ty_info.rs index 53994b5dbf63..5e297a51f0ce 100644 --- a/compiler/rustc_type_ir/src/ty_info.rs +++ b/compiler/rustc_type_ir/src/ty_info.rs @@ -97,8 +97,8 @@ fn hash(&self, s: &mut H) { } #[cfg(feature = "nightly")] -impl, CTX> HashStable for WithCachedTypeInfo { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { +impl, Hcx> HashStable for WithCachedTypeInfo { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { if self.stable_hash == Fingerprint::ZERO || cfg!(debug_assertions) { // No cached hash available. This can only mean that incremental is disabled. // We don't cache stable hashes in non-incremental mode, because they are used diff --git a/compiler/rustc_type_ir/src/ty_kind.rs b/compiler/rustc_type_ir/src/ty_kind.rs index 983d8f0820b6..9afd39e2c762 100644 --- a/compiler/rustc_type_ir/src/ty_kind.rs +++ b/compiler/rustc_type_ir/src/ty_kind.rs @@ -687,15 +687,15 @@ fn tag() -> &'static str { } #[cfg(feature = "nightly")] -impl HashStable for InferTy { - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { +impl HashStable for InferTy { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { use InferTy::*; - std::mem::discriminant(self).hash_stable(ctx, hasher); + std::mem::discriminant(self).hash_stable(hcx, hasher); match self { TyVar(_) | IntVar(_) | FloatVar(_) => { panic!("type variables should not be hashed: {self:?}") } - FreshTy(v) | FreshIntTy(v) | FreshFloatTy(v) => v.hash_stable(ctx, hasher), + FreshTy(v) | FreshIntTy(v) | FreshFloatTy(v) => v.hash_stable(hcx, hasher), } } }