diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index 3269fc5c9c1d..687ec7ca059d 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -175,8 +175,8 @@ fn exported_non_generic_symbols_provider_local<'tcx>( // FIXME: Sorting this is unnecessary since we are sorting later anyway. // Can we skip the later sorting? - let sorted = tcx.with_stable_hashing_context(|hcx| { - tcx.reachable_non_generics(LOCAL_CRATE).to_sorted(&hcx, true) + let sorted = tcx.with_stable_hashing_context(|mut hcx| { + tcx.reachable_non_generics(LOCAL_CRATE).to_sorted(&mut hcx, true) }); let mut symbols: Vec<_> = diff --git a/compiler/rustc_data_structures/src/stable_hasher.rs b/compiler/rustc_data_structures/src/stable_hasher.rs index c9993d106d6d..ce3d78171251 100644 --- a/compiler/rustc_data_structures/src/stable_hasher.rs +++ b/compiler/rustc_data_structures/src/stable_hasher.rs @@ -50,7 +50,7 @@ pub trait HashStable { /// 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; + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Self::KeyType; } /// Trait for marking a type as having a sort order that is @@ -427,7 +427,7 @@ impl StableOrd 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, _: &mut Hcx) -> Self::KeyType { self.clone() } } @@ -435,7 +435,7 @@ fn to_stable_hash_key(&self, _: &Hcx) -> Self::KeyType { 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: &mut Hcx) -> Self::KeyType { (self.0.to_stable_hash_key(hcx), self.1.to_stable_hash_key(hcx)) } } diff --git a/compiler/rustc_data_structures/src/unord.rs b/compiler/rustc_data_structures/src/unord.rs index 8a3b3e2e98cd..b0550f0a4f69 100644 --- a/compiler/rustc_data_structures/src/unord.rs +++ b/compiler/rustc_data_structures/src/unord.rs @@ -143,7 +143,7 @@ pub fn copied(self) -> UnordItems> { impl> UnordItems { #[inline] - pub fn into_sorted(self, hcx: &Hcx) -> Vec + pub fn into_sorted(self, hcx: &mut Hcx) -> Vec where T: ToStableHashKey, { @@ -168,7 +168,7 @@ 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: &mut Hcx, cache_sort_key: bool) -> C where T: ToStableHashKey, C: FromIterator + BorrowMut<[T]>, @@ -315,7 +315,7 @@ 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: &mut Hcx, cache_sort_key: bool) -> Vec<&V> where V: ToStableHashKey, { @@ -357,7 +357,7 @@ 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: &mut Hcx, cache_sort_key: bool) -> Vec where V: ToStableHashKey, { @@ -555,7 +555,7 @@ 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: &mut Hcx, cache_sort_key: bool) -> Vec<(&K, &V)> where K: ToStableHashKey, { @@ -582,7 +582,7 @@ 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: &mut Hcx, cache_sort_key: bool) -> Vec<(K, V)> where K: ToStableHashKey, { @@ -610,7 +610,11 @@ 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: &mut Hcx, + cache_sort_key: bool, + ) -> impl Iterator where K: ToStableHashKey, { @@ -710,7 +714,7 @@ fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { #[inline] fn to_sorted_vec( - hcx: &Hcx, + hcx: &mut Hcx, iter: I, cache_sort_key: bool, extract_key: fn(&T) -> &K, diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs index cae8bb89233b..ec701cbe9a46 100644 --- a/compiler/rustc_hir/src/def.rs +++ b/compiler/rustc_hir/src/def.rs @@ -716,7 +716,7 @@ impl ToStableHashKey for Namespace { type KeyType = Namespace; #[inline] - fn to_stable_hash_key(&self, _: &Hcx) -> Namespace { + fn to_stable_hash_key(&self, _: &mut Hcx) -> Namespace { *self } } diff --git a/compiler/rustc_hir/src/stable_hash_impls.rs b/compiler/rustc_hir/src/stable_hash_impls.rs index a157fc0ccbb0..f2cfeaf027f3 100644 --- a/compiler/rustc_hir/src/stable_hash_impls.rs +++ b/compiler/rustc_hir/src/stable_hash_impls.rs @@ -13,7 +13,7 @@ impl ToStableHashKey for BodyId { type KeyType = (DefPathHash, ItemLocalId); #[inline] - fn to_stable_hash_key(&self, hcx: &Hcx) -> (DefPathHash, ItemLocalId) { + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> (DefPathHash, ItemLocalId) { let BodyId { hir_id } = *self; hir_id.to_stable_hash_key(hcx) } @@ -23,7 +23,7 @@ impl ToStableHashKey for ItemId { type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, hcx: &Hcx) -> DefPathHash { + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash { self.owner_id.def_id.to_stable_hash_key(hcx) } } @@ -32,7 +32,7 @@ impl ToStableHashKey for TraitItemId { type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, hcx: &Hcx) -> DefPathHash { + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash { self.owner_id.def_id.to_stable_hash_key(hcx) } } @@ -41,7 +41,7 @@ impl ToStableHashKey for ImplItemId { type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, hcx: &Hcx) -> DefPathHash { + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash { self.owner_id.def_id.to_stable_hash_key(hcx) } } @@ -50,7 +50,7 @@ impl ToStableHashKey for ForeignItemId { type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, hcx: &Hcx) -> DefPathHash { + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash { self.owner_id.def_id.to_stable_hash_key(hcx) } } diff --git a/compiler/rustc_hir_id/src/lib.rs b/compiler/rustc_hir_id/src/lib.rs index 064ce4ed4caf..f37a19e9c1fe 100644 --- a/compiler/rustc_hir_id/src/lib.rs +++ b/compiler/rustc_hir_id/src/lib.rs @@ -65,7 +65,7 @@ impl ToStableHashKey for OwnerId { type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, hcx: &Hcx) -> DefPathHash { + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash { hcx.def_path_hash(self.to_def_id()) } } @@ -180,7 +180,7 @@ impl ToStableHashKey for HirId { type KeyType = (DefPathHash, ItemLocalId); #[inline] - fn to_stable_hash_key(&self, hcx: &Hcx) -> (DefPathHash, ItemLocalId) { + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> (DefPathHash, ItemLocalId) { let def_path_hash = self.owner.def_id.to_stable_hash_key(hcx); (def_path_hash, self.local_id) } @@ -190,7 +190,7 @@ impl ToStableHashKey for ItemLocalId { type KeyType = ItemLocalId; #[inline] - fn to_stable_hash_key(&self, _: &Hcx) -> ItemLocalId { + fn to_stable_hash_key(&self, _: &mut Hcx) -> ItemLocalId { *self } } diff --git a/compiler/rustc_hir_typeck/src/writeback.rs b/compiler/rustc_hir_typeck/src/writeback.rs index afb20b3c7cd0..5c87a1c0a9ab 100644 --- a/compiler/rustc_hir_typeck/src/writeback.rs +++ b/compiler/rustc_hir_typeck/src/writeback.rs @@ -375,12 +375,12 @@ fn visit_infer( impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { fn eval_closure_size(&mut self) { - self.tcx().with_stable_hashing_context(|ref hcx| { + self.tcx().with_stable_hashing_context(|mut hcx| { let fcx_typeck_results = self.fcx.typeck_results.borrow(); self.typeck_results.closure_size_eval = fcx_typeck_results .closure_size_eval - .to_sorted(hcx, false) + .to_sorted(&mut hcx, false) .into_iter() .map(|(&closure_def_id, data)| { let closure_hir_id = self.tcx().local_def_id_to_hir_id(closure_def_id); @@ -392,12 +392,12 @@ fn eval_closure_size(&mut self) { } fn visit_min_capture_map(&mut self) { - self.tcx().with_stable_hashing_context(|ref hcx| { + self.tcx().with_stable_hashing_context(|mut hcx| { let fcx_typeck_results = self.fcx.typeck_results.borrow(); self.typeck_results.closure_min_captures = fcx_typeck_results .closure_min_captures - .to_sorted(hcx, false) + .to_sorted(&mut hcx, false) .into_iter() .map(|(&closure_def_id, root_min_captures)| { let root_var_map_wb = root_min_captures @@ -423,12 +423,12 @@ fn visit_min_capture_map(&mut self) { } fn visit_fake_reads_map(&mut self) { - self.tcx().with_stable_hashing_context(move |ref hcx| { + self.tcx().with_stable_hashing_context(move |mut hcx| { let fcx_typeck_results = self.fcx.typeck_results.borrow(); self.typeck_results.closure_fake_reads = fcx_typeck_results .closure_fake_reads - .to_sorted(hcx, true) + .to_sorted(&mut hcx, true) .into_iter() .map(|(&closure_def_id, fake_reads)| { let resolved_fake_reads = fake_reads diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index 1c86d553f9b6..12a716493de9 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -160,7 +160,7 @@ 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: &mut 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); @@ -632,7 +632,7 @@ impl ToStableHashKey for LintId { type KeyType = &'static str; #[inline] - fn to_stable_hash_key(&self, _: &Hcx) -> &'static str { + fn to_stable_hash_key(&self, _: &mut 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 987aa3e2a2c2..6bf2863fe071 100644 --- a/compiler/rustc_middle/src/dep_graph/dep_node.rs +++ b/compiler/rustc_middle/src/dep_graph/dep_node.rs @@ -254,7 +254,7 @@ pub fn from_cgu_name(cgu_name: &str) -> WorkProductId { impl ToStableHashKey for WorkProductId { type KeyType = Fingerprint; #[inline] - fn to_stable_hash_key(&self, _: &Hcx) -> Self::KeyType { + fn to_stable_hash_key(&self, _: &mut Hcx) -> Self::KeyType { self.hash } } diff --git a/compiler/rustc_middle/src/ich/hcx.rs b/compiler/rustc_middle/src/ich/hcx.rs index 0e1cee2970f7..e316cbc81beb 100644 --- a/compiler/rustc_middle/src/ich/hcx.rs +++ b/compiler/rustc_middle/src/ich/hcx.rs @@ -10,7 +10,6 @@ // Very often, we are hashing something that does not need the `CachingSourceMapView`, so we // initialize it lazily. -#[derive(Clone)] enum CachingSourceMap<'a> { Unused(&'a SourceMap), InUse(CachingSourceMapView<'a>), @@ -20,7 +19,6 @@ enum CachingSourceMap<'a> { /// enough information to transform `DefId`s and `HirId`s into stable `DefPath`s (i.e., /// a reference to the `TyCtxt`) and it holds a few caches for speeding up various /// things (e.g., each `DefId`/`DefPath` is only hashed once). -#[derive(Clone)] pub struct StableHashingContext<'a> { untracked: &'a Untracked, // The value of `-Z incremental-ignore-spans`. diff --git a/compiler/rustc_middle/src/mir/mono.rs b/compiler/rustc_middle/src/mir/mono.rs index acebf91b1cbf..3909db8bfce6 100644 --- a/compiler/rustc_middle/src/mir/mono.rs +++ b/compiler/rustc_middle/src/mir/mono.rs @@ -328,9 +328,9 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { impl ToStableHashKey> for MonoItem<'_> { type KeyType = Fingerprint; - fn to_stable_hash_key(&self, hcx: &StableHashingContext<'_>) -> Self::KeyType { + fn to_stable_hash_key(&self, hcx: &mut StableHashingContext<'_>) -> Self::KeyType { let mut hasher = StableHasher::new(); - self.hash_stable(&mut hcx.clone(), &mut hasher); + self.hash_stable(hcx, &mut hasher); hasher.finish() } } @@ -584,7 +584,7 @@ pub fn codegen_dep_node(&self, tcx: TyCtxt<'tcx>) -> DepNode { impl ToStableHashKey> for CodegenUnit<'_> { type KeyType = String; - fn to_stable_hash_key(&self, _: &StableHashingContext<'_>) -> Self::KeyType { + fn to_stable_hash_key(&self, _: &mut StableHashingContext<'_>) -> Self::KeyType { // Codegen unit names are conceptually required to be stable across // compilation session so that object file names match up. self.name.to_string() diff --git a/compiler/rustc_middle/src/ty/impls_ty.rs b/compiler/rustc_middle/src/ty/impls_ty.rs index f06ce7324d4c..883739e19347 100644 --- a/compiler/rustc_middle/src/ty/impls_ty.rs +++ b/compiler/rustc_middle/src/ty/impls_ty.rs @@ -53,10 +53,9 @@ impl<'a, 'tcx, H, T> ToStableHashKey> for &'tcx ty::lis type KeyType = Fingerprint; #[inline] - fn to_stable_hash_key(&self, hcx: &StableHashingContext<'a>) -> Fingerprint { + fn to_stable_hash_key(&self, hcx: &mut StableHashingContext<'a>) -> Fingerprint { let mut hasher = StableHasher::new(); - let mut hcx: StableHashingContext<'a> = hcx.clone(); - self.hash_stable(&mut hcx, &mut hasher); + self.hash_stable(hcx, &mut hasher); hasher.finish() } } @@ -88,7 +87,7 @@ impl<'a> ToStableHashKey> for region::Scope { type KeyType = region::Scope; #[inline] - fn to_stable_hash_key(&self, _: &StableHashingContext<'a>) -> region::Scope { + fn to_stable_hash_key(&self, _: &mut StableHashingContext<'a>) -> region::Scope { *self } } diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 4698e054daf6..cab87daff5aa 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -1824,8 +1824,8 @@ pub(crate) fn collect_crate_mono_items<'tcx>( // The set of MonoItems was created in an inherently indeterministic order because // of parallelism. We sort it here to ensure that the output is deterministic. - let mono_items = tcx.with_stable_hashing_context(move |ref hcx| { - state.visited.into_inner().into_sorted(hcx, true) + let mono_items = tcx.with_stable_hashing_context(move |mut hcx| { + state.visited.into_inner().into_sorted(&mut hcx, true) }); (mono_items, state.usage_map.into_inner()) diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs index d8f4e0194507..fb3fb1b0918a 100644 --- a/compiler/rustc_monomorphize/src/partitioning.rs +++ b/compiler/rustc_monomorphize/src/partitioning.rs @@ -286,8 +286,8 @@ fn place_mono_items<'tcx, I>(cx: &PartitioningCx<'_, 'tcx>, mono_items: I) -> Pl codegen_units.insert(cgu_name, CodegenUnit::new(cgu_name)); } - let mut codegen_units: Vec<_> = cx.tcx.with_stable_hashing_context(|ref hcx| { - codegen_units.into_items().map(|(_, cgu)| cgu).collect_sorted(hcx, true) + let mut codegen_units: Vec<_> = cx.tcx.with_stable_hashing_context(|mut hcx| { + codegen_units.into_items().map(|(_, cgu)| cgu).collect_sorted(&mut hcx, true) }); for cgu in codegen_units.iter_mut() { diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 7539e3c4f499..d3aec252d125 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -1535,9 +1535,10 @@ fn detect_missing_binding_available_from_pattern( let [segment] = path else { return }; let None = following_seg else { return }; for rib in self.ribs[ValueNS].iter().rev() { - let patterns_with_skipped_bindings = self.r.tcx.with_stable_hashing_context(|hcx| { - rib.patterns_with_skipped_bindings.to_sorted(&hcx, true) - }); + let patterns_with_skipped_bindings = + self.r.tcx.with_stable_hashing_context(|mut hcx| { + rib.patterns_with_skipped_bindings.to_sorted(&mut hcx, true) + }); for (def_id, spans) in patterns_with_skipped_bindings { if let DefKind::Struct | DefKind::Variant = self.r.tcx.def_kind(*def_id) && let Some(fields) = self.r.field_idents(*def_id) diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 1e95482a8c7e..e4ef1d40d72d 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -640,7 +640,7 @@ impl StableOrd for OutputType { impl ToStableHashKey for OutputType { type KeyType = Self; - fn to_stable_hash_key(&self, _: &Hcx) -> Self::KeyType { + fn to_stable_hash_key(&self, _: &mut Hcx) -> Self::KeyType { *self } } diff --git a/compiler/rustc_span/src/caching_source_map_view.rs b/compiler/rustc_span/src/caching_source_map_view.rs index d9aa73cefc57..3a3f238a7e55 100644 --- a/compiler/rustc_span/src/caching_source_map_view.rs +++ b/compiler/rustc_span/src/caching_source_map_view.rs @@ -9,7 +9,6 @@ /// succession, and this avoids expensive `SourceMap` lookups each time the cache is hit. We used /// to cache multiple code positions, but caching a single position ended up being simpler and /// faster. -#[derive(Clone)] pub struct CachingSourceMapView<'sm> { source_map: &'sm SourceMap, file: Arc, diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs index 8c313c7f8b3a..8a56d716a300 100644 --- a/compiler/rustc_span/src/def_id.rs +++ b/compiler/rustc_span/src/def_id.rs @@ -427,7 +427,7 @@ impl ToStableHashKey for DefId { type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, hcx: &Hcx) -> DefPathHash { + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash { hcx.def_path_hash(*self) } } @@ -436,7 +436,7 @@ impl ToStableHashKey for LocalDefId { type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, hcx: &Hcx) -> DefPathHash { + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash { hcx.def_path_hash(self.to_def_id()) } } @@ -445,7 +445,7 @@ impl ToStableHashKey for CrateNum { type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, hcx: &Hcx) -> DefPathHash { + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash { self.as_def_id().to_stable_hash_key(hcx) } } @@ -454,7 +454,7 @@ impl ToStableHashKey for DefPathHash { type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, _: &Hcx) -> DefPathHash { + fn to_stable_hash_key(&self, _: &mut Hcx) -> DefPathHash { *self } } diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 53e2527057bc..3ba981ee485a 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -2611,7 +2611,7 @@ fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { impl ToStableHashKey for Symbol { type KeyType = String; #[inline] - fn to_stable_hash_key(&self, _: &Hcx) -> String { + fn to_stable_hash_key(&self, _: &mut Hcx) -> String { self.as_str().to_string() } } diff --git a/compiler/rustc_type_ir/src/fast_reject.rs b/compiler/rustc_type_ir/src/fast_reject.rs index 5e24e53c62d9..a8a04f18d549 100644 --- a/compiler/rustc_type_ir/src/fast_reject.rs +++ b/compiler/rustc_type_ir/src/fast_reject.rs @@ -50,14 +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: &mut Hcx) -> Fingerprint { let mut hasher = StableHasher::new(); - let mut hcx: Hcx = hcx.clone(); - self.hash_stable(&mut hcx, &mut hasher); + self.hash_stable(hcx, &mut hasher); hasher.finish() } } diff --git a/src/tools/miri/src/bin/miri.rs b/src/tools/miri/src/bin/miri.rs index e73c870508bd..36cf640cb844 100644 --- a/src/tools/miri/src/bin/miri.rs +++ b/src/tools/miri/src/bin/miri.rs @@ -310,7 +310,7 @@ fn config(&mut self, config: &mut Config) { // FIXME handle this somehow in rustc itself to avoid this hack. local_providers.queries.exported_non_generic_symbols = |tcx, LocalCrate| { let reachable_set = tcx - .with_stable_hashing_context(|hcx| tcx.reachable_set(()).to_sorted(&hcx, true)); + .with_stable_hashing_context(|mut hcx| tcx.reachable_set(()).to_sorted(&mut hcx, true)); tcx.arena.alloc_from_iter( // This is based on: // https://github.com/rust-lang/rust/blob/2962e7c0089d5c136f4e9600b7abccfbbde4973d/compiler/rustc_codegen_ssa/src/back/symbol_export.rs#L62-L63