diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index e8cbd7b69fbe0..3f0eb65c4f600 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -101,8 +101,8 @@ impl PartialEq for Path { } } -impl HashStable for Path { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { +impl HashStable for Path { + fn hash_stable(&self, hcx: &mut Ctx, hasher: &mut StableHasher) { self.segments.len().hash_stable(hcx, hasher); for segment in &self.segments { segment.ident.hash_stable(hcx, hasher); @@ -1680,11 +1680,11 @@ impl AttrArgs { } } -impl HashStable for AttrArgs +impl HashStable for AttrArgs where - CTX: crate::HashStableContext, + Ctx: crate::HashStableContext, { - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { mem::discriminant(self).hash_stable(ctx, hasher); match self { AttrArgs::Empty => {} @@ -1716,11 +1716,11 @@ impl DelimArgs { } } -impl HashStable for DelimArgs +impl HashStable for DelimArgs where - CTX: crate::HashStableContext, + Ctx: crate::HashStableContext, { - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { let DelimArgs { dspan, delim, tokens } = self; dspan.hash_stable(ctx, hasher); delim.hash_stable(ctx, hasher); diff --git a/compiler/rustc_ast/src/ptr.rs b/compiler/rustc_ast/src/ptr.rs index 0140fb752bf92..b2bad7efaa90b 100644 --- a/compiler/rustc_ast/src/ptr.rs +++ b/compiler/rustc_ast/src/ptr.rs @@ -202,11 +202,11 @@ impl> Decodable for P<[T]> { } } -impl HashStable for P +impl HashStable for P where - T: ?Sized + HashStable, + T: ?Sized + HashStable, { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Ctx, hasher: &mut StableHasher) { (**self).hash_stable(hcx, hasher); } } diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index 09bfbd02198c0..c03ee53f36428 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -948,11 +948,11 @@ impl fmt::Debug for Nonterminal { } } -impl HashStable for Nonterminal +impl HashStable for Nonterminal where - CTX: crate::HashStableContext, + Ctx: crate::HashStableContext, { - fn hash_stable(&self, _hcx: &mut CTX, _hasher: &mut StableHasher) { + fn hash_stable(&self, _hcx: &mut Ctx, _hasher: &mut StableHasher) { panic!("interpolated tokens should not be present in the HIR") } } diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index 1e18b1232de76..a412ec49989c8 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -110,11 +110,11 @@ impl TokenTree { } } -impl HashStable for TokenStream +impl HashStable for TokenStream where - CTX: crate::HashStableContext, + Ctx: crate::HashStableContext, { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Ctx, hasher: &mut StableHasher) { for sub_tt in self.trees() { sub_tt.hash_stable(hcx, hasher); } @@ -166,8 +166,8 @@ impl Decodable for LazyAttrTokenStream { } } -impl HashStable for LazyAttrTokenStream { - fn hash_stable(&self, _hcx: &mut CTX, _hasher: &mut StableHasher) { +impl HashStable for LazyAttrTokenStream { + fn hash_stable(&self, _hcx: &mut Ctx, _hasher: &mut StableHasher) { panic!("Attempted to compute stable hash for LazyAttrTokenStream"); } } diff --git a/compiler/rustc_codegen_cranelift/src/driver/aot.rs b/compiler/rustc_codegen_cranelift/src/driver/aot.rs index cc2f5d7271460..06a00da9ad8da 100644 --- a/compiler/rustc_codegen_cranelift/src/driver/aot.rs +++ b/compiler/rustc_codegen_cranelift/src/driver/aot.rs @@ -33,8 +33,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 641ac3eb80872..cbf496d884a29 100644 --- a/compiler/rustc_codegen_ssa/src/common.rs +++ b/compiler/rustc_codegen_ssa/src/common.rs @@ -109,8 +109,8 @@ mod temp_stable_hash_impls { use crate::ModuleCodegen; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; - 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 e0f8c350c2a86..43b79e90cf811 100644 --- a/compiler/rustc_data_structures/src/intern.rs +++ b/compiler/rustc_data_structures/src/intern.rs @@ -99,11 +99,11 @@ impl<'a, T> Hash for Interned<'a, T> { } } -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 Ctx, hasher: &mut StableHasher) { self.0.hash_stable(hcx, hasher); } } diff --git a/compiler/rustc_data_structures/src/obligation_forest/mod.rs b/compiler/rustc_data_structures/src/obligation_forest/mod.rs index a47908648ba16..56c70d6590062 100644 --- a/compiler/rustc_data_structures/src/obligation_forest/mod.rs +++ b/compiler/rustc_data_structures/src/obligation_forest/mod.rs @@ -95,7 +95,7 @@ pub trait ForestObligation: Clone + Debug { pub trait ObligationProcessor { type Obligation: ForestObligation; type Error: Debug; - type OUT: OutcomeTrait>; + type Out: OutcomeTrait>; /// Implementations can provide a fast-path to obligation-processing /// by counting the prefix of the passed iterator for which @@ -416,11 +416,11 @@ impl ObligationForest { /// Performs a fixpoint computation over the obligation list. #[inline(never)] - pub fn process_obligations

(&mut self, processor: &mut P) -> P::OUT + pub fn process_obligations

(&mut self, processor: &mut P) -> P::Out where P: ObligationProcessor, { - let mut outcome = P::OUT::new(); + let mut outcome = P::Out::new(); // Fixpoint computation: we repeat until the inner loop stalls. loop { @@ -576,7 +576,7 @@ impl ObligationForest { /// Report cycles between all `Success` nodes, and convert all `Success` /// nodes to `Done`. This must be called after `mark_successes`. - fn process_cycles

(&mut self, processor: &mut P, outcome: &mut P::OUT) + fn process_cycles

(&mut self, processor: &mut P, outcome: &mut P::Out) where P: ObligationProcessor, { @@ -599,7 +599,7 @@ impl ObligationForest { stack: &mut Vec, processor: &mut P, index: usize, - outcome: &mut P::OUT, + outcome: &mut P::Out, ) where P: ObligationProcessor, { diff --git a/compiler/rustc_data_structures/src/obligation_forest/tests.rs b/compiler/rustc_data_structures/src/obligation_forest/tests.rs index bc252f772a168..e9b1feacf4434 100644 --- a/compiler/rustc_data_structures/src/obligation_forest/tests.rs +++ b/compiler/rustc_data_structures/src/obligation_forest/tests.rs @@ -64,7 +64,7 @@ where { type Obligation = O; type Error = E; - type OUT = TestOutcome; + type Out = TestOutcome; fn needs_process_obligation(&self, _obligation: &Self::Obligation) -> bool { true diff --git a/compiler/rustc_data_structures/src/profiling.rs b/compiler/rustc_data_structures/src/profiling.rs index e688feb5fe176..7a009f7a757da 100644 --- a/compiler/rustc_data_structures/src/profiling.rs +++ b/compiler/rustc_data_structures/src/profiling.rs @@ -622,7 +622,7 @@ impl SelfProfiler { /// Allocates a new string in the profiling data. Does not do any caching /// or deduplication. - pub fn alloc_string(&self, s: &STR) -> StringId { + pub fn alloc_string(&self, s: &Str) -> StringId { self.profiler.alloc_string(s) } diff --git a/compiler/rustc_data_structures/src/sorted_map.rs b/compiler/rustc_data_structures/src/sorted_map.rs index 60b343afbed9c..98de17650a217 100644 --- a/compiler/rustc_data_structures/src/sorted_map.rs +++ b/compiler/rustc_data_structures/src/sorted_map.rs @@ -306,9 +306,9 @@ impl FromIterator<(K, V)> for SortedMap { } } -impl + StableOrd, V: HashStable, CTX> HashStable for SortedMap { +impl + StableOrd, V: HashStable, Ctx> HashStable for SortedMap { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { self.data.hash_stable(ctx, hasher); } } diff --git a/compiler/rustc_data_structures/src/stable_hasher.rs b/compiler/rustc_data_structures/src/stable_hasher.rs index 6d75b0fb8a0ca..5c50b9b3b08d0 100644 --- a/compiler/rustc_data_structures/src/stable_hasher.rs +++ b/compiler/rustc_data_structures/src/stable_hasher.rs @@ -170,7 +170,7 @@ impl Hasher for 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 @@ -196,16 +196,16 @@ impl Hasher for StableHasher { /// - `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 Ctx, 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 @@ -256,9 +256,9 @@ unsafe impl StableOrd for &T { /// 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 Ctx, hasher: &mut $crate::stable_hasher::StableHasher) { ::std::hash::Hash::hash(self, hasher); } } @@ -290,61 +290,61 @@ impl_stable_traits_for_trivial_type!(()); impl_stable_traits_for_trivial_type!(Hash64); impl_stable_traits_for_trivial_type!(Hash128); -impl HashStable for ! { - fn hash_stable(&self, _ctx: &mut CTX, _hasher: &mut StableHasher) { +impl HashStable for ! { + fn hash_stable(&self, _ctx: &mut Ctx, _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, _ctx: &mut Ctx, _hasher: &mut StableHasher) {} } -impl HashStable for ::std::num::NonZeroU32 { +impl HashStable for ::std::num::NonZeroU32 { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { self.get().hash_stable(ctx, hasher) } } -impl HashStable for ::std::num::NonZeroUsize { +impl HashStable for ::std::num::NonZeroUsize { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { self.get().hash_stable(ctx, hasher) } } -impl HashStable for f32 { - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { +impl HashStable for f32 { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { let val: u32 = self.to_bits(); val.hash_stable(ctx, hasher); } } -impl HashStable for f64 { - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { +impl HashStable for f64 { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { let val: u64 = self.to_bits(); val.hash_stable(ctx, hasher); } } -impl HashStable for ::std::cmp::Ordering { +impl HashStable for ::std::cmp::Ordering { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { (*self as i8).hash_stable(ctx, hasher); } } -impl, CTX> HashStable for (T1,) { +impl, Ctx> HashStable for (T1,) { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { let (ref _0,) = *self; _0.hash_stable(ctx, hasher); } } -impl, T2: HashStable, CTX> HashStable for (T1, T2) { - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { +impl, T2: HashStable, Ctx> HashStable for (T1, T2) { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { let (ref _0, ref _1) = *self; _0.hash_stable(ctx, hasher); _1.hash_stable(ctx, hasher); @@ -355,13 +355,13 @@ unsafe impl StableOrd for (T1, T2) { const CAN_USE_UNSTABLE_SORT: bool = T1::CAN_USE_UNSTABLE_SORT && T2::CAN_USE_UNSTABLE_SORT; } -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, ctx: &mut Ctx, hasher: &mut StableHasher) { let (ref _0, ref _1, ref _2) = *self; _0.hash_stable(ctx, hasher); _1.hash_stable(ctx, hasher); @@ -374,14 +374,14 @@ unsafe impl StableOrd for (T1, T2, T1::CAN_USE_UNSTABLE_SORT && T2::CAN_USE_UNSTABLE_SORT && T3::CAN_USE_UNSTABLE_SORT; } -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, ctx: &mut Ctx, hasher: &mut StableHasher) { let (ref _0, ref _1, ref _2, ref _3) = *self; _0.hash_stable(ctx, hasher); _1.hash_stable(ctx, hasher); @@ -399,8 +399,8 @@ unsafe impl StableOr && T4::CAN_USE_UNSTABLE_SORT; } -impl, CTX> HashStable for [T] { - default fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { +impl, Ctx> HashStable for [T] { + default fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { self.len().hash_stable(ctx, hasher); for item in self { item.hash_stable(ctx, hasher); @@ -408,28 +408,28 @@ impl, CTX> HashStable for [T] { } } -impl HashStable for [u8] { - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { +impl HashStable for [u8] { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { self.len().hash_stable(ctx, hasher); hasher.write(self); } } -impl, CTX> HashStable for Vec { +impl, Ctx> HashStable for Vec { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { self[..].hash_stable(ctx, 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) { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { self.len().hash_stable(ctx, hasher); for kv in self { kv.hash_stable(ctx, hasher); @@ -437,13 +437,13 @@ where } } -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) { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { self.len().hash_stable(ctx, hasher); for key in self { key.hash_stable(ctx, hasher); @@ -451,40 +451,40 @@ where } } -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) { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { self[..].hash_stable(ctx, hasher); } } -impl, CTX> HashStable for Box { +impl, Ctx> HashStable for Box { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { (**self).hash_stable(ctx, hasher); } } -impl, CTX> HashStable for ::std::rc::Rc { +impl, Ctx> HashStable for ::std::rc::Rc { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { (**self).hash_stable(ctx, hasher); } } -impl, CTX> HashStable for ::std::sync::Arc { +impl, Ctx> HashStable for ::std::sync::Arc { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { (**self).hash_stable(ctx, hasher); } } -impl HashStable for str { +impl HashStable for str { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { self.as_bytes().hash_stable(ctx, hasher); } } @@ -493,9 +493,9 @@ unsafe impl StableOrd for &str { const CAN_USE_UNSTABLE_SORT: bool = true; } -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 Ctx, hasher: &mut StableHasher) { self[..].hash_stable(hcx, hasher); } } @@ -506,25 +506,25 @@ unsafe impl StableOrd for String { const CAN_USE_UNSTABLE_SORT: bool = true; } -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) { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { (if *self { 1u8 } else { 0u8 }).hash_stable(ctx, hasher); } } @@ -534,12 +534,12 @@ unsafe impl StableOrd for bool { const CAN_USE_UNSTABLE_SORT: bool = true; } -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, ctx: &mut Ctx, hasher: &mut StableHasher) { if let Some(ref value) = *self { 1u8.hash_stable(ctx, hasher); value.hash_stable(ctx, hasher); @@ -554,13 +554,13 @@ unsafe impl StableOrd for Option { const CAN_USE_UNSTABLE_SORT: bool = T::CAN_USE_UNSTABLE_SORT; } -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) { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { mem::discriminant(self).hash_stable(ctx, hasher); match *self { Ok(ref x) => x.hash_stable(ctx, hasher), @@ -569,39 +569,39 @@ where } } -impl<'a, T, CTX> HashStable for &'a T +impl<'a, T, Ctx> HashStable for &'a T where - T: HashStable + ?Sized, + T: HashStable + ?Sized, { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { (**self).hash_stable(ctx, 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 Ctx, 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) { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { self.start().hash_stable(ctx, hasher); self.end().hash_stable(ctx, hasher); } } -impl HashStable for IndexSlice +impl HashStable for IndexSlice where - T: HashStable, + T: HashStable, { - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { self.len().hash_stable(ctx, hasher); for v in &self.raw { v.hash_stable(ctx, hasher); @@ -609,11 +609,11 @@ where } } -impl HashStable for IndexVec +impl HashStable for IndexVec where - T: HashStable, + T: HashStable, { - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { self.len().hash_stable(ctx, hasher); for v in &self.raw { v.hash_stable(ctx, hasher); @@ -621,23 +621,23 @@ where } } -impl HashStable for BitSet { - fn hash_stable(&self, _ctx: &mut CTX, hasher: &mut StableHasher) { +impl HashStable for BitSet { + fn hash_stable(&self, _ctx: &mut Ctx, 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, _ctx: &mut Ctx, hasher: &mut StableHasher) { ::std::hash::Hash::hash(self, hasher); } } -impl HashStable for bit_set::FiniteBitSet +impl HashStable for bit_set::FiniteBitSet where - T: HashStable + bit_set::FiniteBitSetTy, + T: HashStable + bit_set::FiniteBitSetTy, { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Ctx, hasher: &mut StableHasher) { self.0.hash_stable(hcx, hasher); } } @@ -645,14 +645,14 @@ where impl_stable_traits_for_trivial_type!(::std::path::Path); impl_stable_traits_for_trivial_type!(::std::path::PathBuf); -impl HashStable for ::std::collections::HashMap +impl HashStable for ::std::collections::HashMap where - K: ToStableHashKey + Eq, - V: HashStable, + K: ToStableHashKey + Eq, + V: HashStable, R: BuildHasher, { #[inline] - fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { stable_hash_reduce(hcx, hasher, self.iter(), self.len(), |hasher, hcx, (key, value)| { let key = key.to_stable_hash_key(hcx); key.hash_stable(hcx, hasher); @@ -664,14 +664,14 @@ where // It is not safe to implement HashStable for HashSet 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::HashSet {} -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); @@ -679,11 +679,11 @@ where } } -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); @@ -691,15 +691,15 @@ where } } -fn stable_hash_reduce( - hcx: &mut HCX, +fn stable_hash_reduce( + hcx: &mut Hcx, hasher: &mut StableHasher, mut collection: C, length: usize, hash_function: F, ) where C: Iterator, - F: Fn(&mut StableHasher, &mut HCX, I), + F: Fn(&mut StableHasher, &mut Hcx, I), { length.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 c8921f6a7784f..23822ecdb1594 100644 --- a/compiler/rustc_data_structures/src/stable_hasher/tests.rs +++ b/compiler/rustc_data_structures/src/stable_hasher/tests.rs @@ -109,8 +109,8 @@ fn test_attribute_permutation() { 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 Ctx, 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 9a0fd52677d13..c8da3f45a2a28 100644 --- a/compiler/rustc_data_structures/src/steal.rs +++ b/compiler/rustc_data_structures/src/steal.rs @@ -53,8 +53,8 @@ impl Steal { } } -impl> HashStable for Steal { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { +impl> HashStable for Steal { + fn hash_stable(&self, hcx: &mut Ctx, hasher: &mut StableHasher) { self.borrow().hash_stable(hcx, hasher); } } diff --git a/compiler/rustc_data_structures/src/sync.rs b/compiler/rustc_data_structures/src/sync.rs index cca043ba0d18d..7df5bbbde6741 100644 --- a/compiler/rustc_data_structures/src/sync.rs +++ b/compiler/rustc_data_structures/src/sync.rs @@ -29,16 +29,16 @@ //! | `Lock` | `RefCell` | `RefCell` or | //! | | | `parking_lot::Mutex` | //! | `RwLock` | `RefCell` | `parking_lot::RwLock` | -//! | `MTLock` [^1] | `T` | `Lock` | -//! | `MTLockRef<'a, T>` [^2] | `&'a mut MTLock` | `&'a MTLock` | +//! | `MtLock` [^1] | `T` | `Lock` | +//! | `MtLockRef<'a, T>` [^2] | `&'a mut MtLock` | `&'a MtLock` | //! | | | | //! | `ParallelIterator` | `Iterator` | `rayon::iter::ParallelIterator` | //! -//! [^1] `MTLock` is similar to `Lock`, but the serial version avoids the cost +//! [^1] `MtLock` is similar to `Lock`, but the serial version avoids the cost //! of a `RefCell`. This is appropriate when interior mutability is not //! required. //! -//! [^2] `MTLockRef` is a typedef. +//! [^2] `MtLockRef` is a typedef. pub use crate::marker::*; use std::collections::HashMap; @@ -212,15 +212,15 @@ cfg_if! { use std::cell::RefCell as InnerRwLock; - pub type MTLockRef<'a, T> = &'a mut MTLock; + pub type MtLockRef<'a, T> = &'a mut MtLock; #[derive(Debug, Default)] - pub struct MTLock(T); + pub struct MtLock(T); - impl MTLock { + impl MtLock { #[inline(always)] pub fn new(inner: T) -> Self { - MTLock(inner) + MtLock(inner) } #[inline(always)] @@ -245,10 +245,10 @@ cfg_if! { } // FIXME: Probably a bad idea (in the threaded case) - impl Clone for MTLock { + impl Clone for MtLock { #[inline] fn clone(&self) -> Self { - MTLock(self.0.clone()) + MtLock(self.0.clone()) } } } else { @@ -269,15 +269,15 @@ cfg_if! { pub use std::sync::Arc as Lrc; pub use std::sync::Weak as Weak; - pub type MTLockRef<'a, T> = &'a MTLock; + pub type MtLockRef<'a, T> = &'a MtLock; #[derive(Debug, Default)] - pub struct MTLock(Lock); + pub struct MtLock(Lock); - impl MTLock { + impl MtLock { #[inline(always)] pub fn new(inner: T) -> Self { - MTLock(Lock::new(inner)) + MtLock(Lock::new(inner)) } #[inline(always)] diff --git a/compiler/rustc_data_structures/src/tagged_ptr.rs b/compiler/rustc_data_structures/src/tagged_ptr.rs index 2914eece6796b..2ccf1073aa26e 100644 --- a/compiler/rustc_data_structures/src/tagged_ptr.rs +++ b/compiler/rustc_data_structures/src/tagged_ptr.rs @@ -276,8 +276,8 @@ unsafe impl Tag for Tag2 { } #[cfg(test)] -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/tagged_ptr/copy.rs b/compiler/rustc_data_structures/src/tagged_ptr/copy.rs index e893a2c781346..723d65d2dc693 100644 --- a/compiler/rustc_data_structures/src/tagged_ptr/copy.rs +++ b/compiler/rustc_data_structures/src/tagged_ptr/copy.rs @@ -266,12 +266,12 @@ where } } -impl HashStable for CopyTaggedPtr +impl HashStable for CopyTaggedPtr where - P: Pointer + HashStable, - T: Tag + HashStable, + P: Pointer + HashStable, + T: Tag + HashStable, { - fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.with_pointer_ref(|ptr| ptr.hash_stable(hcx, hasher)); self.tag().hash_stable(hcx, hasher); } diff --git a/compiler/rustc_data_structures/src/tagged_ptr/drop.rs b/compiler/rustc_data_structures/src/tagged_ptr/drop.rs index 4e42b5b4afe8a..5f758dec7c4b2 100644 --- a/compiler/rustc_data_structures/src/tagged_ptr/drop.rs +++ b/compiler/rustc_data_structures/src/tagged_ptr/drop.rs @@ -138,12 +138,12 @@ where } } -impl HashStable for TaggedPtr +impl HashStable for TaggedPtr where - P: Pointer + HashStable, - T: Tag + HashStable, + P: Pointer + HashStable, + T: Tag + HashStable, { - fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.raw.hash_stable(hcx, hasher); } } diff --git a/compiler/rustc_data_structures/src/unord.rs b/compiler/rustc_data_structures/src/unord.rs index 47c56eba7adc8..24e19ac8d0f23 100644 --- a/compiler/rustc_data_structures/src/unord.rs +++ b/compiler/rustc_data_structures/src/unord.rs @@ -135,9 +135,9 @@ impl<'a, T: Copy + 'a, I: Iterator> UnordItems<&'a T, I> { } impl> UnordItems { - pub fn into_sorted(self, hcx: &HCX) -> Vec + pub fn into_sorted(self, hcx: &Hcx) -> Vec where - T: ToStableHashKey, + T: ToStableHashKey, { let mut items: Vec = self.0.collect(); items.sort_by_cached_key(|x| x.to_stable_hash_key(hcx)); @@ -158,9 +158,9 @@ impl> UnordItems { items } - pub fn into_sorted_small_vec(self, hcx: &HCX) -> SmallVec<[T; LEN]> + pub fn into_sorted_small_vec(self, hcx: &Hcx) -> SmallVec<[T; LEN]> where - T: ToStableHashKey, + T: ToStableHashKey, { let mut items: SmallVec<[T; LEN]> = self.0.collect(); items.sort_by_cached_key(|x| x.to_stable_hash_key(hcx)); @@ -260,9 +260,9 @@ impl UnordSet { /// `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) } @@ -288,9 +288,9 @@ impl UnordSet { /// `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) } @@ -346,9 +346,9 @@ impl> From> for UnordSet } } -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); } } @@ -476,9 +476,9 @@ impl UnordMap { /// `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) } @@ -503,9 +503,9 @@ impl UnordMap { /// `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) } @@ -518,9 +518,9 @@ impl UnordMap { /// `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() @@ -541,9 +541,9 @@ where } } -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); } } @@ -604,23 +604,23 @@ impl> From> for UnordBag { } } -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 { @@ -633,12 +633,12 @@ where } 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 3a4eb90f7f963..7a861a0d0ab2c 100644 --- a/compiler/rustc_hir/src/def.rs +++ b/compiler/rustc_hir/src/def.rs @@ -505,11 +505,11 @@ impl Namespace { } } -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, _: &Ctx) -> Namespace { *self } } diff --git a/compiler/rustc_hir/src/diagnostic_items.rs b/compiler/rustc_hir/src/diagnostic_items.rs index 243014b002703..4d2eb972fc47b 100644 --- a/compiler/rustc_hir/src/diagnostic_items.rs +++ b/compiler/rustc_hir/src/diagnostic_items.rs @@ -9,9 +9,9 @@ pub struct DiagnosticItems { pub name_to_id: FxHashMap, } -impl HashStable for DiagnosticItems { +impl HashStable for DiagnosticItems { #[inline] - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { self.name_to_id.hash_stable(ctx, hasher); } } diff --git a/compiler/rustc_hir/src/hir_id.rs b/compiler/rustc_hir/src/hir_id.rs index 34c6157793663..112f0ec96dec4 100644 --- a/compiler/rustc_hir/src/hir_id.rs +++ b/compiler/rustc_hir/src/hir_id.rs @@ -47,18 +47,18 @@ impl rustc_index::Idx for OwnerId { } } -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 Ctx, 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: &Ctx) -> DefPathHash { hcx.def_path_hash(self.to_def_id()) } } diff --git a/compiler/rustc_hir/src/lang_items.rs b/compiler/rustc_hir/src/lang_items.rs index 4a89a6f7e3926..9815d3b75ac6b 100644 --- a/compiler/rustc_hir/src/lang_items.rs +++ b/compiler/rustc_hir/src/lang_items.rs @@ -119,8 +119,8 @@ macro_rules! language_item_table { } } -impl HashStable for LangItem { - fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher) { +impl HashStable for LangItem { + fn hash_stable(&self, _: &mut Ctx, hasher: &mut StableHasher) { ::std::hash::Hash::hash(self, hasher); } } diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index d7a666aa72ba1..8d3987cd88f10 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -34,6 +34,7 @@ #![feature(control_flow_enum)] #![feature(if_let_guard)] #![feature(iter_intersperse)] +#![feature(iter_map_windows)] #![feature(iter_order_by)] #![feature(let_chains)] #![feature(min_specialization)] diff --git a/compiler/rustc_lint/src/nonstandard_style.rs b/compiler/rustc_lint/src/nonstandard_style.rs index 145de49483519..746a25ce15a75 100644 --- a/compiler/rustc_lint/src/nonstandard_style.rs +++ b/compiler/rustc_lint/src/nonstandard_style.rs @@ -89,10 +89,19 @@ fn is_camel_case(name: &str) -> bool { // ones (some scripts don't have a concept of upper/lowercase) !name.chars().next().unwrap().is_lowercase() && !name.contains("__") - && !name.chars().collect::>().array_windows().any(|&[fst, snd]| { + && !name.chars().map_windows(|&[fst, snd]| (fst, snd)).any(|(fst, snd)| { // contains a capitalisable character followed by, or preceded by, an underscore char_has_case(fst) && snd == '_' || char_has_case(snd) && fst == '_' }) + && !name.chars().map_windows(|&[fst, snd, thd]| (fst, snd, thd)).any(|(fst, snd, thd)| { + // three capitalized characters in a row + char_has_case(fst) + && char_has_case(snd) + && char_has_case(thd) + && fst.is_uppercase() + && snd.is_uppercase() + && thd.is_uppercase() + }) } fn to_camel_case(s: &str) -> String { diff --git a/compiler/rustc_lint/src/nonstandard_style/tests.rs b/compiler/rustc_lint/src/nonstandard_style/tests.rs index 39c525b8623d0..9e06bcb720b3b 100644 --- a/compiler/rustc_lint/src/nonstandard_style/tests.rs +++ b/compiler/rustc_lint/src/nonstandard_style/tests.rs @@ -18,4 +18,11 @@ fn camel_case() { assert!(!is_camel_case("ONE_TWO_THREE")); assert_eq!(to_camel_case("ONE_TWO_THREE"), "OneTwoThree"); + + assert!(!is_camel_case("ONE")); + assert_eq!(to_camel_case("ONE"), "One"); + + assert!(is_camel_case("AStr")); + + assert!(is_camel_case("Foo")); } diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index 7ba589c3b5a39..0c486078cfd14 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -136,9 +136,9 @@ impl LintExpectationId { } } -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, @@ -159,11 +159,11 @@ impl HashStable for LintExpectationId { } } -impl ToStableHashKey for LintExpectationId { +impl ToStableHashKey for LintExpectationId { type KeyType = (HirId, u16, u16); #[inline] - fn to_stable_hash_key(&self, _: &HCX) -> Self::KeyType { + fn to_stable_hash_key(&self, _: &Hcx) -> Self::KeyType { match self { LintExpectationId::Stable { hir_id, @@ -458,18 +458,18 @@ impl LintId { } } -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/mir/basic_blocks.rs b/compiler/rustc_middle/src/mir/basic_blocks.rs index 3ecd5b9cd3456..e5c9dd0b364eb 100644 --- a/compiler/rustc_middle/src/mir/basic_blocks.rs +++ b/compiler/rustc_middle/src/mir/basic_blocks.rs @@ -195,7 +195,7 @@ impl Decodable for Cache { } } -impl HashStable for Cache { +impl HashStable for Cache { #[inline] - fn hash_stable(&self, _: &mut CTX, _: &mut StableHasher) {} + fn hash_stable(&self, _: &mut Ctx, _: &mut StableHasher) {} } diff --git a/compiler/rustc_middle/src/ty/consts/int.rs b/compiler/rustc_middle/src/ty/consts/int.rs index 9d99344d5bdfb..46bb358fe3344 100644 --- a/compiler/rustc_middle/src/ty/consts/int.rs +++ b/compiler/rustc_middle/src/ty/consts/int.rs @@ -137,8 +137,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 Ctx, 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/consts/kind.rs b/compiler/rustc_middle/src/ty/consts/kind.rs index 749b54ca0befb..cfa52fc34a94a 100644 --- a/compiler/rustc_middle/src/ty/consts/kind.rs +++ b/compiler/rustc_middle/src/ty/consts/kind.rs @@ -92,8 +92,8 @@ pub enum InferConst<'tcx> { Fresh(u32), } -impl HashStable for InferConst<'_> { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { +impl HashStable for InferConst<'_> { + fn hash_stable(&self, hcx: &mut Ctx, hasher: &mut StableHasher) { match self { InferConst::Var(_) | InferConst::EffectVar(_) => { panic!("const variables should not be hashed: {self:?}") diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 6ea177bb6ea9a..c5d4c9e71bb3d 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -165,7 +165,7 @@ //! regardless of whether it is actually needed or not. use rustc_data_structures::fx::{FxHashMap, FxHashSet}; -use rustc_data_structures::sync::{par_for_each_in, MTLock, MTLockRef}; +use rustc_data_structures::sync::{par_for_each_in, MtLock, MtLockRef}; use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_hir::def_id::{DefId, DefIdMap, LocalDefId}; @@ -263,13 +263,13 @@ pub fn collect_crate_mono_items( debug!("building mono item graph, beginning at roots"); - let mut visited = MTLock::new(FxHashSet::default()); - let mut usage_map = MTLock::new(UsageMap::new()); + let mut visited = MtLock::new(FxHashSet::default()); + let mut usage_map = MtLock::new(UsageMap::new()); let recursion_limit = tcx.recursion_limit(); { - let visited: MTLockRef<'_, _> = &mut visited; - let usage_map: MTLockRef<'_, _> = &mut usage_map; + let visited: MtLockRef<'_, _> = &mut visited; + let usage_map: MtLockRef<'_, _> = &mut usage_map; tcx.sess.time("monomorphization_collector_graph_walk", || { par_for_each_in(roots, |root| { @@ -333,10 +333,10 @@ fn collect_roots(tcx: TyCtxt<'_>, mode: MonoItemCollectionMode) -> Vec( tcx: TyCtxt<'tcx>, starting_item: Spanned>, - visited: MTLockRef<'_, FxHashSet>>, + visited: MtLockRef<'_, FxHashSet>>, recursion_depths: &mut DefIdMap, recursion_limit: Limit, - usage_map: MTLockRef<'_, UsageMap<'tcx>>, + usage_map: MtLockRef<'_, UsageMap<'tcx>>, ) { if !visited.lock_mut().insert(starting_item.node) { // We've been here already, no need to search again. diff --git a/compiler/rustc_query_system/src/dep_graph/dep_node.rs b/compiler/rustc_query_system/src/dep_graph/dep_node.rs index 17f96896a504b..48b471c09a3cf 100644 --- a/compiler/rustc_query_system/src/dep_graph/dep_node.rs +++ b/compiler/rustc_query_system/src/dep_graph/dep_node.rs @@ -299,16 +299,16 @@ impl WorkProductId { } } -impl HashStable for WorkProductId { +impl HashStable for WorkProductId { #[inline] - fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.hash.hash_stable(hcx, hasher) } } -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_session/src/config.rs b/compiler/rustc_session/src/config.rs index 58461856eb1e7..3b3f1e2ebb7a1 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -443,10 +443,10 @@ unsafe impl StableOrd for OutputType { const CAN_USE_UNSTABLE_SORT: bool = true; } -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_smir/src/rustc_internal/mod.rs b/compiler/rustc_smir/src/rustc_internal/mod.rs index e3c84f06543ed..a7601cad09a5a 100644 --- a/compiler/rustc_smir/src/rustc_internal/mod.rs +++ b/compiler/rustc_smir/src/rustc_internal/mod.rs @@ -156,7 +156,7 @@ where (Ok(Ok(())), Some(ControlFlow::Break(value))) => Err(CompilerError::Interrupted(value)), (Ok(Ok(_)), None) => Err(CompilerError::Skipped), (Ok(Err(_)), _) => Err(CompilerError::CompilationFailed), - (Err(_), _) => Err(CompilerError::ICE), + (Err(_), _) => Err(CompilerError::Ice), } } } diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs index 595babc26ae68..ab91c279d980d 100644 --- a/compiler/rustc_span/src/def_id.rs +++ b/compiler/rustc_span/src/def_id.rs @@ -444,50 +444,50 @@ rustc_data_structures::define_id_collections!( 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 Ctx, hasher: &mut StableHasher) { self.to_stable_hash_key(hcx).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 Ctx, hasher: &mut StableHasher) { self.to_stable_hash_key(hcx).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 Ctx, hasher: &mut StableHasher) { self.to_stable_hash_key(hcx).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: &Ctx) -> 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: &Ctx) -> 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: &Ctx) -> DefPathHash { self.as_def_id().to_stable_hash_key(hcx) } } diff --git a/compiler/rustc_span/src/hygiene.rs b/compiler/rustc_span/src/hygiene.rs index 88081700c3b94..d91526d4e7f0b 100644 --- a/compiler/rustc_span/src/hygiene.rs +++ b/compiler/rustc_span/src/hygiene.rs @@ -100,7 +100,7 @@ impl !PartialOrd for LocalExpnId {} /// with a non-default mode. With this check in place, we can avoid the need /// to maintain separate versions of `ExpnData` hashes for each permutation /// of `HashingControls` settings. -fn assert_default_hashing_controls(ctx: &CTX, msg: &str) { +fn assert_default_hashing_controls(ctx: &Ctx, msg: &str) { match ctx.hashing_controls() { // Note that we require that `hash_spans` be set according to the global // `-Z incremental-ignore-spans` option. Normally, this option is disabled, @@ -1550,8 +1550,8 @@ 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) } -impl HashStable for SyntaxContext { - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { +impl HashStable for SyntaxContext { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { const TAG_EXPANSION: u8 = 0; const TAG_NO_EXPANSION: u8 = 1; @@ -1566,8 +1566,8 @@ impl HashStable for SyntaxContext { } } -impl HashStable for ExpnId { - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { +impl HashStable for ExpnId { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { assert_default_hashing_controls(ctx, "ExpnId"); let hash = if *self == ExpnId::root() { // Avoid fetching TLS storage for a trivial often-used value. diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index e62efab5793f2..b8261417c70e5 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -2167,9 +2167,9 @@ pub trait HashStableContext { fn hashing_controls(&self) -> HashingControls; } -impl HashStable for Span +impl HashStable for Span where - CTX: HashStableContext, + Ctx: HashStableContext, { /// Hashes a span in a stable way. We can't directly hash the span's `BytePos` /// fields (that would be similar to hashing pointers, since those are just @@ -2181,7 +2181,7 @@ where /// codepoint offsets. For the purpose of the hash that's sufficient. /// Also, hashing filenames is expensive so we avoid doing it twice when the /// span starts and ends in the same file, which is almost always the case. - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { const TAG_VALID_SPAN: u8 = 0; const TAG_INVALID_SPAN: u8 = 1; const TAG_RELATIVE_SPAN: u8 = 2; diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index ea261923c6541..15fba9d88b885 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -2050,17 +2050,17 @@ impl Decodable for Symbol { } } -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 Ctx, 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, _: &Ctx) -> String { self.as_str().to_string() } } diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 16f70cf43b3fb..b98c3ab28eb8a 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1199,8 +1199,8 @@ impl IntoIterator for SanitizerSet { } } -impl HashStable for SanitizerSet { - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { +impl HashStable for SanitizerSet { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { self.bits().hash_stable(ctx, hasher); } } diff --git a/compiler/rustc_trait_selection/src/traits/fulfill.rs b/compiler/rustc_trait_selection/src/traits/fulfill.rs index da357dac415fc..a723d8dde94b1 100644 --- a/compiler/rustc_trait_selection/src/traits/fulfill.rs +++ b/compiler/rustc_trait_selection/src/traits/fulfill.rs @@ -161,7 +161,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> { impl<'tcx> ObligationProcessor for DrainProcessor<'_, 'tcx> { type Obligation = PendingPredicateObligation<'tcx>; type Error = !; - type OUT = Outcome; + type Out = Outcome; fn needs_process_obligation(&self, pending_obligation: &Self::Obligation) -> bool { pending_obligation @@ -211,7 +211,7 @@ fn mk_pending(os: Vec>) -> Vec ObligationProcessor for FulfillProcessor<'a, 'tcx> { type Obligation = PendingPredicateObligation<'tcx>; type Error = FulfillmentErrorCode<'tcx>; - type OUT = Outcome; + type Out = Outcome; /// Compared to `needs_process_obligation` this and its callees /// contain some optimizations that come at the price of false negatives. diff --git a/compiler/rustc_type_ir/src/lib.rs b/compiler/rustc_type_ir/src/lib.rs index 5df068de1f849..3a16a8c79b3c1 100644 --- a/compiler/rustc_type_ir/src/lib.rs +++ b/compiler/rustc_type_ir/src/lib.rs @@ -747,8 +747,8 @@ impl Variance { } } -impl HashStable for InferTy { - fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { +impl HashStable for InferTy { + fn hash_stable(&self, ctx: &mut Ctx, hasher: &mut StableHasher) { use InferTy::*; discriminant(self).hash_stable(ctx, hasher); match self { diff --git a/compiler/rustc_type_ir/src/sty.rs b/compiler/rustc_type_ir/src/sty.rs index 091b51440a6e1..47f1ab5ad4e30 100644 --- a/compiler/rustc_type_ir/src/sty.rs +++ b/compiler/rustc_type_ir/src/sty.rs @@ -744,32 +744,32 @@ where // This is not a derived impl because a derive would require `I: HashStable` #[allow(rustc::usage_of_ty_tykind)] -impl HashStable for TyKind +impl HashStable for TyKind where - I::AdtDef: HashStable, - I::DefId: HashStable, - I::GenericArgsRef: HashStable, - I::Ty: HashStable, - I::Const: HashStable, - I::TypeAndMut: HashStable, - I::PolyFnSig: HashStable, - I::ListBinderExistentialPredicate: HashStable, - I::Region: HashStable, - I::Movability: HashStable, - I::Mutability: HashStable, - I::BinderListTy: HashStable, - I::ListTy: HashStable, - I::AliasTy: HashStable, - I::BoundTy: HashStable, - I::ParamTy: HashStable, - I::PlaceholderType: HashStable, - I::InferTy: HashStable, - I::ErrorGuaranteed: HashStable, + I::AdtDef: HashStable, + I::DefId: HashStable, + I::GenericArgsRef: HashStable, + I::Ty: HashStable, + I::Const: HashStable, + I::TypeAndMut: HashStable, + I::PolyFnSig: HashStable, + I::ListBinderExistentialPredicate: HashStable, + I::Region: HashStable, + I::Movability: HashStable, + I::Mutability: HashStable, + I::BinderListTy: HashStable, + I::ListTy: HashStable, + I::AliasTy: HashStable, + I::BoundTy: HashStable, + I::ParamTy: HashStable, + I::PlaceholderType: HashStable, + I::InferTy: HashStable, + I::ErrorGuaranteed: HashStable, { #[inline] fn hash_stable( &self, - __hcx: &mut CTX, + __hcx: &mut Ctx, __hasher: &mut rustc_data_structures::stable_hasher::StableHasher, ) { std::mem::discriminant(self).hash_stable(__hcx, __hasher); @@ -925,20 +925,20 @@ impl hash::Hash for ConstKind { } } -impl HashStable for ConstKind +impl HashStable for ConstKind where - I::ParamConst: HashStable, - I::InferConst: HashStable, - I::BoundConst: HashStable, - I::PlaceholderConst: HashStable, - I::AliasConst: HashStable, - I::ValueConst: HashStable, - I::ErrorGuaranteed: HashStable, - I::ExprConst: HashStable, + I::ParamConst: HashStable, + I::InferConst: HashStable, + I::BoundConst: HashStable, + I::PlaceholderConst: HashStable, + I::AliasConst: HashStable, + I::ValueConst: HashStable, + I::ErrorGuaranteed: HashStable, + I::ExprConst: HashStable, { fn hash_stable( &self, - hcx: &mut CTX, + hcx: &mut Ctx, hasher: &mut rustc_data_structures::stable_hasher::StableHasher, ) { const_kind_discriminant(self).hash_stable(hcx, hasher); @@ -1440,18 +1440,18 @@ where } // This is not a derived impl because a derive would require `I: HashStable` -impl HashStable for RegionKind +impl HashStable for RegionKind where - I::EarlyBoundRegion: HashStable, - I::BoundRegion: HashStable, - I::FreeRegion: HashStable, - I::RegionVid: HashStable, - I::PlaceholderRegion: HashStable, + I::EarlyBoundRegion: HashStable, + I::BoundRegion: HashStable, + I::FreeRegion: HashStable, + I::RegionVid: HashStable, + I::PlaceholderRegion: HashStable, { #[inline] fn hash_stable( &self, - hcx: &mut CTX, + hcx: &mut Ctx, hasher: &mut rustc_data_structures::stable_hasher::StableHasher, ) { std::mem::discriminant(self).hash_stable(hcx, hasher); diff --git a/compiler/rustc_type_ir/src/ty_info.rs b/compiler/rustc_type_ir/src/ty_info.rs index 4e5d424886ad8..80dad372eae74 100644 --- a/compiler/rustc_type_ir/src/ty_info.rs +++ b/compiler/rustc_type_ir/src/ty_info.rs @@ -94,8 +94,8 @@ impl Hash for WithCachedTypeInfo { } } -impl, CTX> HashStable for WithCachedTypeInfo { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { +impl, Ctx> HashStable for WithCachedTypeInfo { + fn hash_stable(&self, hcx: &mut Ctx, 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/stable_mir/src/lib.rs b/compiler/stable_mir/src/lib.rs index f371f46204fe4..ac2cf571a16c7 100644 --- a/compiler/stable_mir/src/lib.rs +++ b/compiler/stable_mir/src/lib.rs @@ -89,7 +89,7 @@ pub type ImplTraitDecls = Vec; #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum CompilerError { /// Internal compiler error (I.e.: Compiler crashed). - ICE, + Ice, /// Compilation failed. CompilationFailed, /// Compilation was interrupted. diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index 4bdd9639557d4..fb3ee99272b9c 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -16,7 +16,7 @@ use super::dedup_sorted_iter::DedupSortedIter; use super::navigate::{LazyLeafRange, LeafRange}; use super::node::{self, marker, ForceResult::*, Handle, NodeRef, Root}; use super::search::{SearchBound, SearchResult::*}; -use super::set_val::SetValZST; +use super::set_val::SetValZst; mod entry; @@ -288,7 +288,7 @@ impl Clone for BTreeMap { } } -impl super::Recover for BTreeMap +impl super::Recover for BTreeMap where K: Borrow + Ord, Q: Ord, @@ -335,7 +335,7 @@ where alloc: (*map.alloc).clone(), _marker: PhantomData, } - .insert(SetValZST::default()); + .insert(SetValZst::default()); None } } diff --git a/library/alloc/src/collections/btree/set.rs b/library/alloc/src/collections/btree/set.rs index 0e03551286e8a..e2240d1eedfd6 100644 --- a/library/alloc/src/collections/btree/set.rs +++ b/library/alloc/src/collections/btree/set.rs @@ -10,7 +10,7 @@ use core::ops::{BitAnd, BitOr, BitXor, RangeBounds, Sub}; use super::map::{BTreeMap, Keys}; use super::merge_iter::MergeIterInner; -use super::set_val::SetValZST; +use super::set_val::SetValZst; use super::Recover; use crate::alloc::{Allocator, Global}; @@ -76,7 +76,7 @@ pub struct BTreeSet< T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global, > { - map: BTreeMap, + map: BTreeMap, } #[stable(feature = "rust1", since = "1.0.0")] @@ -130,7 +130,7 @@ impl Clone for BTreeSet { #[must_use = "iterators are lazy and do nothing unless consumed"] #[stable(feature = "rust1", since = "1.0.0")] pub struct Iter<'a, T: 'a> { - iter: Keys<'a, T, SetValZST>, + iter: Keys<'a, T, SetValZst>, } #[stable(feature = "collection_debug", since = "1.17.0")] @@ -152,7 +152,7 @@ pub struct IntoIter< T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global, > { - iter: super::map::IntoIter, + iter: super::map::IntoIter, } /// An iterator over a sub-range of items in a `BTreeSet`. @@ -165,7 +165,7 @@ pub struct IntoIter< #[derive(Debug)] #[stable(feature = "btree_range", since = "1.17.0")] pub struct Range<'a, T: 'a> { - iter: super::map::Range<'a, T, SetValZST>, + iter: super::map::Range<'a, T, SetValZst>, } /// A lazy iterator producing elements in the difference of `BTreeSet`s. @@ -900,7 +900,7 @@ impl BTreeSet { where T: Ord, { - self.map.insert(value, SetValZST::default()).is_none() + self.map.insert(value, SetValZst::default()).is_none() } /// Adds a value to the set, replacing the existing element, if any, that is @@ -1197,7 +1197,7 @@ impl FromIterator for BTreeSet { impl BTreeSet { fn from_sorted_iter>(iter: I, alloc: A) -> BTreeSet { - let iter = iter.map(|k| (k, SetValZST::default())); + let iter = iter.map(|k| (k, SetValZst::default())); let map = BTreeMap::bulk_build_from_sorted_iter(iter, alloc); BTreeSet { map } } @@ -1221,7 +1221,7 @@ impl From<[T; N]> for BTreeSet { // use stable sort to preserve the insertion order. arr.sort(); - let iter = IntoIterator::into_iter(arr).map(|k| (k, SetValZST::default())); + let iter = IntoIterator::into_iter(arr).map(|k| (k, SetValZst::default())); let map = BTreeMap::bulk_build_from_sorted_iter(iter, Global); BTreeSet { map } } @@ -1272,7 +1272,7 @@ pub struct ExtractIf< F: 'a + FnMut(&T) -> bool, { pred: F, - inner: super::map::ExtractIfInner<'a, T, SetValZST>, + inner: super::map::ExtractIfInner<'a, T, SetValZst>, /// The BTreeMap will outlive this IntoIter so we don't care about drop order for `alloc`. alloc: A, } @@ -1297,7 +1297,7 @@ where fn next(&mut self) -> Option { let pred = &mut self.pred; - let mut mapped_pred = |k: &T, _v: &mut SetValZST| pred(k); + let mut mapped_pred = |k: &T, _v: &mut SetValZst| pred(k); self.inner.next(&mut mapped_pred, self.alloc.clone()).map(|(k, _)| k) } diff --git a/library/alloc/src/collections/btree/set_val.rs b/library/alloc/src/collections/btree/set_val.rs index 80c459bcf81db..e2abf53ab2f5f 100644 --- a/library/alloc/src/collections/btree/set_val.rs +++ b/library/alloc/src/collections/btree/set_val.rs @@ -3,7 +3,7 @@ /// * `BTreeMap` (possible user-defined map) /// * `BTreeMap` (internal set representation) #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Default)] -pub struct SetValZST; +pub struct SetValZst; /// A trait to differentiate between `BTreeMap` and `BTreeSet` values. /// Returns `true` only for type `SetValZST`, `false` for all other types (blanket implementation). @@ -22,7 +22,7 @@ impl IsSetVal for V { } // Specialization -impl IsSetVal for SetValZST { +impl IsSetVal for SetValZst { fn is_set_val() -> bool { true } diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index e4d6c2c2928d3..13a3698b54c81 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -2479,14 +2479,14 @@ extern "rust-intrinsic" { /// which violates the principle that a `const fn` must behave the same at /// compile-time and at run-time. The unsafe code in crate B is fine. #[rustc_const_unstable(feature = "const_eval_select", issue = "none")] - pub fn const_eval_select( - arg: ARG, + pub fn const_eval_select( + arg: Arg, called_in_const: F, called_at_rt: G, - ) -> RET + ) -> Ret where - G: FnOnce, - F: FnOnce; + G: FnOnce, + F: FnOnce; /// This method creates a pointer to any `Some` value. If the argument is /// `None`, an invalid within-bounds pointer (that is still acceptable for diff --git a/library/core/src/iter/mod.rs b/library/core/src/iter/mod.rs index ca977d1ef8240..668b92a405f79 100644 --- a/library/core/src/iter/mod.rs +++ b/library/core/src/iter/mod.rs @@ -368,6 +368,9 @@ macro_rules! impl_fold_via_try_fold { impl_fold_via_try_fold! { @internal spec_rfold -> spec_try_rfold } }; (@internal $fold:ident -> $try_fold:ident) => { + // `A` and `F` are already used as generic parameters in impls where this macro appears, + // hence the strange names + #[allow(non_camel_case_types)] #[inline] fn $fold(mut self, init: AAA, fold: FFF) -> AAA where diff --git a/library/std/src/path.rs b/library/std/src/path.rs index 60562f64c90d9..d81f3359bdade 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -153,6 +153,7 @@ pub enum Prefix<'a> { /// /// Verbatim UNC prefixes consist of `\\?\UNC\` immediately followed by the /// server's hostname and a share name. + #[allow(non_camel_case_types)] #[stable(feature = "rust1", since = "1.0.0")] VerbatimUNC( #[stable(feature = "rust1", since = "1.0.0")] &'a OsStr, @@ -177,6 +178,7 @@ pub enum Prefix<'a> { /// `\\server\share`. /// /// UNC prefixes consist of the server's hostname and a share name. + #[allow(non_camel_case_types)] #[stable(feature = "rust1", since = "1.0.0")] UNC( #[stable(feature = "rust1", since = "1.0.0")] &'a OsStr, diff --git a/library/std/src/sys/personality/dwarf/eh.rs b/library/std/src/sys/personality/dwarf/eh.rs index 79624703a4cf7..4e070e590d6bd 100644 --- a/library/std/src/sys/personality/dwarf/eh.rs +++ b/library/std/src/sys/personality/dwarf/eh.rs @@ -35,15 +35,17 @@ pub const DW_EH_PE_aligned: u8 = 0x50; pub const DW_EH_PE_indirect: u8 = 0x80; +#[allow(non_camel_case_types)] #[derive(Copy, Clone)] -pub struct EHContext<'a> { +pub struct EhContext<'a> { pub ip: usize, // Current instruction pointer pub func_start: usize, // Address of the current function pub get_text_start: &'a dyn Fn() -> usize, // Get address of the code section pub get_data_start: &'a dyn Fn() -> usize, // Get address of the data section } -pub enum EHAction { +#[allow(non_camel_case_types)] +pub enum EhAction { None, Cleanup(usize), Catch(usize), @@ -53,9 +55,9 @@ pub enum EHAction { pub const USING_SJLJ_EXCEPTIONS: bool = cfg!(all(target_os = "ios", target_arch = "arm")); -pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext<'_>) -> Result { +pub unsafe fn find_eh_action(lsda: *const u8, context: &EhContext<'_>) -> Result { if lsda.is_null() { - return Ok(EHAction::None); + return Ok(EhAction::None); } let func_start = context.func_start; @@ -93,7 +95,7 @@ pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext<'_>) -> Result } if ip < func_start + cs_start + cs_len { if cs_lpad == 0 { - return Ok(EHAction::None); + return Ok(EhAction::None); } else { let lpad = lpad_base + cs_lpad; return Ok(interpret_cs_action(action_table as *mut u8, cs_action_entry, lpad)); @@ -101,14 +103,14 @@ pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext<'_>) -> Result } } // Ip is not present in the table. This indicates a nounwind call. - Ok(EHAction::Terminate) + Ok(EhAction::Terminate) } else { // SjLj version: // The "IP" is an index into the call-site table, with two exceptions: // -1 means 'no-action', and 0 means 'terminate'. match ip as isize { - -1 => return Ok(EHAction::None), - 0 => return Ok(EHAction::Terminate), + -1 => return Ok(EhAction::None), + 0 => return Ok(EhAction::Terminate), _ => (), } let mut idx = ip; @@ -130,11 +132,11 @@ unsafe fn interpret_cs_action( action_table: *mut u8, cs_action_entry: u64, lpad: usize, -) -> EHAction { +) -> EhAction { if cs_action_entry == 0 { // If cs_action_entry is 0 then this is a cleanup (Drop::drop). We run these // for both Rust panics and foreign exceptions. - EHAction::Cleanup(lpad) + EhAction::Cleanup(lpad) } else { // If lpad != 0 and cs_action_entry != 0, we have to check ttype_index. // If ttype_index == 0 under the condition, we take cleanup action. @@ -142,12 +144,12 @@ unsafe fn interpret_cs_action( let mut action_reader = DwarfReader::new(action_record); let ttype_index = action_reader.read_sleb128(); if ttype_index == 0 { - EHAction::Cleanup(lpad) + EhAction::Cleanup(lpad) } else if ttype_index > 0 { // Stop unwinding Rust panics at catch_unwind. - EHAction::Catch(lpad) + EhAction::Catch(lpad) } else { - EHAction::Filter(lpad) + EhAction::Filter(lpad) } } } @@ -159,7 +161,7 @@ fn round_up(unrounded: usize, align: usize) -> Result { unsafe fn read_encoded_pointer( reader: &mut DwarfReader, - context: &EHContext<'_>, + context: &EhContext<'_>, encoding: u8, ) -> Result { if encoding == DW_EH_PE_omit { diff --git a/library/std/src/sys/personality/gcc.rs b/library/std/src/sys/personality/gcc.rs index 559d2c7db4717..8308ea84e3d9d 100644 --- a/library/std/src/sys/personality/gcc.rs +++ b/library/std/src/sys/personality/gcc.rs @@ -36,7 +36,7 @@ //! Once stack has been unwound down to the handler frame level, unwinding stops //! and the last personality routine transfers control to the catch block. -use super::dwarf::eh::{self, EHAction, EHContext}; +use super::dwarf::eh::{self, EhAction, EhContext}; use crate::ffi::c_int; use libc::uintptr_t; use unwind as uw; @@ -140,23 +140,23 @@ cfg_if::cfg_if! { }; if search_phase { match eh_action { - EHAction::None | EHAction::Cleanup(_) => { + EhAction::None | EhAction::Cleanup(_) => { return continue_unwind(exception_object, context); } - EHAction::Catch(_) | EHAction::Filter(_) => { + EhAction::Catch(_) | EhAction::Filter(_) => { // EHABI requires the personality routine to update the // SP value in the barrier cache of the exception object. (*exception_object).private[5] = uw::_Unwind_GetGR(context, uw::UNWIND_SP_REG); return uw::_URC_HANDLER_FOUND; } - EHAction::Terminate => return uw::_URC_FAILURE, + EhAction::Terminate => return uw::_URC_FAILURE, } } else { match eh_action { - EHAction::None => return continue_unwind(exception_object, context), - EHAction::Filter(_) if state & uw::_US_FORCE_UNWIND as c_int != 0 => return continue_unwind(exception_object, context), - EHAction::Cleanup(lpad) | EHAction::Catch(lpad) | EHAction::Filter(lpad) => { + EhAction::None => return continue_unwind(exception_object, context), + EhAction::Filter(_) if state & uw::_US_FORCE_UNWIND as c_int != 0 => return continue_unwind(exception_object, context), + EhAction::Cleanup(lpad) | EhAction::Catch(lpad) | EhAction::Filter(lpad) => { uw::_Unwind_SetGR( context, UNWIND_DATA_REG.0, @@ -166,7 +166,7 @@ cfg_if::cfg_if! { uw::_Unwind_SetIP(context, lpad); return uw::_URC_INSTALL_CONTEXT; } - EHAction::Terminate => return uw::_URC_FAILURE, + EhAction::Terminate => return uw::_URC_FAILURE, } } @@ -209,16 +209,16 @@ cfg_if::cfg_if! { }; if actions as i32 & uw::_UA_SEARCH_PHASE as i32 != 0 { match eh_action { - EHAction::None | EHAction::Cleanup(_) => uw::_URC_CONTINUE_UNWIND, - EHAction::Catch(_) | EHAction::Filter(_) => uw::_URC_HANDLER_FOUND, - EHAction::Terminate => uw::_URC_FATAL_PHASE1_ERROR, + EhAction::None | EhAction::Cleanup(_) => uw::_URC_CONTINUE_UNWIND, + EhAction::Catch(_) | EhAction::Filter(_) => uw::_URC_HANDLER_FOUND, + EhAction::Terminate => uw::_URC_FATAL_PHASE1_ERROR, } } else { match eh_action { - EHAction::None => uw::_URC_CONTINUE_UNWIND, + EhAction::None => uw::_URC_CONTINUE_UNWIND, // Forced unwinding hits a terminate action. - EHAction::Filter(_) if actions as i32 & uw::_UA_FORCE_UNWIND as i32 != 0 => uw::_URC_CONTINUE_UNWIND, - EHAction::Cleanup(lpad) | EHAction::Catch(lpad) | EHAction::Filter(lpad) => { + EhAction::Filter(_) if actions as i32 & uw::_UA_FORCE_UNWIND as i32 != 0 => uw::_URC_CONTINUE_UNWIND, + EhAction::Cleanup(lpad) | EhAction::Catch(lpad) | EhAction::Filter(lpad) => { uw::_Unwind_SetGR( context, UNWIND_DATA_REG.0, @@ -228,7 +228,7 @@ cfg_if::cfg_if! { uw::_Unwind_SetIP(context, lpad); uw::_URC_INSTALL_CONTEXT } - EHAction::Terminate => uw::_URC_FATAL_PHASE2_ERROR, + EhAction::Terminate => uw::_URC_FATAL_PHASE2_ERROR, } } } @@ -276,11 +276,11 @@ cfg_if::cfg_if! { } } -unsafe fn find_eh_action(context: *mut uw::_Unwind_Context) -> Result { +unsafe fn find_eh_action(context: *mut uw::_Unwind_Context) -> Result { let lsda = uw::_Unwind_GetLanguageSpecificData(context) as *const u8; let mut ip_before_instr: c_int = 0; let ip = uw::_Unwind_GetIPInfo(context, &mut ip_before_instr); - let eh_context = EHContext { + let eh_context = EhContext { // The return address points 1 byte past the call instruction, // which could be in the next IP range in LSDA range table. // diff --git a/library/test/src/term/win.rs b/library/test/src/term/win.rs index 55020141a827d..6d9be12d9c980 100644 --- a/library/test/src/term/win.rs +++ b/library/test/src/term/win.rs @@ -17,10 +17,15 @@ pub(crate) struct WinConsole { background: color::Color, } +#[allow(non_camel_case_types)] type SHORT = i16; +#[allow(non_camel_case_types)] type WORD = u16; +#[allow(non_camel_case_types)] type DWORD = u32; +#[allow(non_camel_case_types)] type BOOL = i32; +#[allow(non_camel_case_types)] type HANDLE = *mut u8; #[allow(non_snake_case)]