diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2021-09-26 01:40:17 +0200 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2021-10-03 16:08:55 +0200 |
| commit | fedd7785fe61754bd3a2678cf2277e0d0b217454 (patch) | |
| tree | b631241c771973ac6a9893f173a4cdf6e37dcf31 | |
| parent | 471cb5c149b8f843278a148c03a370e791d45cb9 (diff) | |
Access StableHashingContext in rustc_query_system.
| -rw-r--r-- | compiler/rustc_middle/src/dep_graph/mod.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_query_impl/src/plumbing.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/dep_graph/dep_node.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/dep_graph/graph.rs | 12 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/dep_graph/mod.rs | 11 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/query/config.rs | 11 |
6 files changed, 17 insertions, 25 deletions
diff --git a/compiler/rustc_middle/src/dep_graph/mod.rs b/compiler/rustc_middle/src/dep_graph/mod.rs index d70c2808e94..70895f7b98e 100644 --- a/compiler/rustc_middle/src/dep_graph/mod.rs +++ b/compiler/rustc_middle/src/dep_graph/mod.rs @@ -90,10 +90,9 @@ impl rustc_query_system::dep_graph::DepKind for DepKind { impl<'tcx> DepContext for TyCtxt<'tcx> { type DepKind = DepKind; - type StableHashingContext = StableHashingContext<'tcx>; #[inline] - fn create_stable_hashing_context(&self) -> Self::StableHashingContext { + fn create_stable_hashing_context(&self) -> StableHashingContext<'_> { TyCtxt::create_stable_hashing_context(*self) } diff --git a/compiler/rustc_query_impl/src/plumbing.rs b/compiler/rustc_query_impl/src/plumbing.rs index ad757029ec3..f02fe91dfb1 100644 --- a/compiler/rustc_query_impl/src/plumbing.rs +++ b/compiler/rustc_query_impl/src/plumbing.rs @@ -36,7 +36,6 @@ impl<'tcx> std::ops::Deref for QueryCtxt<'tcx> { impl HasDepContext for QueryCtxt<'tcx> { type DepKind = rustc_middle::dep_graph::DepKind; - type StableHashingContext = rustc_query_system::ich::StableHashingContext<'tcx>; type DepContext = TyCtxt<'tcx>; #[inline] 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 46dc0c720ce..dd500015374 100644 --- a/compiler/rustc_query_system/src/dep_graph/dep_node.rs +++ b/compiler/rustc_query_system/src/dep_graph/dep_node.rs @@ -43,10 +43,10 @@ //! lost during fingerprint computation. use super::{DepContext, DepKind}; +use crate::ich::StableHashingContext; use rustc_data_structures::fingerprint::{Fingerprint, PackedFingerprint}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; - use std::fmt; use std::hash::Hash; @@ -119,7 +119,7 @@ pub trait DepNodeParams<Ctxt: DepContext>: fmt::Debug + Sized { impl<Ctxt: DepContext, T> DepNodeParams<Ctxt> for T where - T: HashStable<Ctxt::StableHashingContext> + fmt::Debug, + T: for<'a> HashStable<StableHashingContext<'a>> + fmt::Debug, { #[inline] default fn can_reconstruct_query_key() -> bool { diff --git a/compiler/rustc_query_system/src/dep_graph/graph.rs b/compiler/rustc_query_system/src/dep_graph/graph.rs index 23a43771842..114d12fb90b 100644 --- a/compiler/rustc_query_system/src/dep_graph/graph.rs +++ b/compiler/rustc_query_system/src/dep_graph/graph.rs @@ -1,3 +1,4 @@ +use parking_lot::Mutex; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::profiling::{EventId, QueryInvocationId, SelfProfilerRef}; @@ -7,8 +8,6 @@ use rustc_data_structures::steal::Steal; use rustc_data_structures::sync::{AtomicU32, AtomicU64, Lock, Lrc, Ordering}; use rustc_index::vec::IndexVec; use rustc_serialize::opaque::{FileEncodeResult, FileEncoder}; - -use parking_lot::Mutex; use smallvec::{smallvec, SmallVec}; use std::collections::hash_map::Entry; use std::fmt::Debug; @@ -19,6 +18,7 @@ use std::sync::atomic::Ordering::Relaxed; use super::query::DepGraphQuery; use super::serialized::{GraphEncoder, SerializedDepGraph, SerializedDepNodeIndex}; use super::{DepContext, DepKind, DepNode, HasDepContext, WorkProductId}; +use crate::ich::StableHashingContext; use crate::query::{QueryContext, QuerySideEffects}; #[cfg(debug_assertions)] @@ -96,9 +96,9 @@ struct DepGraphData<K: DepKind> { dep_node_debug: Lock<FxHashMap<DepNode<K>, String>>, } -pub fn hash_result<HashCtxt, R>(hcx: &mut HashCtxt, result: &R) -> Option<Fingerprint> +pub fn hash_result<R>(hcx: &mut StableHashingContext<'_>, result: &R) -> Option<Fingerprint> where - R: HashStable<HashCtxt>, + R: for<'a> HashStable<StableHashingContext<'a>>, { let mut stable_hasher = StableHasher::new(); result.hash_stable(hcx, &mut stable_hasher); @@ -215,7 +215,7 @@ impl<K: DepKind> DepGraph<K> { cx: Ctxt, arg: A, task: fn(Ctxt, A) -> R, - hash_result: fn(&mut Ctxt::StableHashingContext, &R) -> Option<Fingerprint>, + hash_result: fn(&mut StableHashingContext<'_>, &R) -> Option<Fingerprint>, ) -> (R, DepNodeIndex) { if self.is_fully_enabled() { self.with_task_impl(key, cx, arg, task, hash_result) @@ -234,7 +234,7 @@ impl<K: DepKind> DepGraph<K> { cx: Ctxt, arg: A, task: fn(Ctxt, A) -> R, - hash_result: fn(&mut Ctxt::StableHashingContext, &R) -> Option<Fingerprint>, + hash_result: fn(&mut StableHashingContext<'_>, &R) -> Option<Fingerprint>, ) -> (R, DepNodeIndex) { // This function is only called when the graph is enabled. let data = self.data.as_ref().unwrap(); diff --git a/compiler/rustc_query_system/src/dep_graph/mod.rs b/compiler/rustc_query_system/src/dep_graph/mod.rs index b5be1192ce7..2afef210254 100644 --- a/compiler/rustc_query_system/src/dep_graph/mod.rs +++ b/compiler/rustc_query_system/src/dep_graph/mod.rs @@ -9,6 +9,7 @@ pub use graph::{hash_result, DepGraph, DepNodeColor, DepNodeIndex, TaskDeps, Wor pub use query::DepGraphQuery; pub use serialized::{SerializedDepGraph, SerializedDepNodeIndex}; +use crate::ich::StableHashingContext; use rustc_data_structures::profiling::SelfProfilerRef; use rustc_data_structures::sync::Lock; use rustc_serialize::{opaque::FileEncoder, Encodable}; @@ -19,10 +20,9 @@ use std::hash::Hash; pub trait DepContext: Copy { type DepKind: self::DepKind; - type StableHashingContext; /// Create a hashing context for hashing new results. - fn create_stable_hashing_context(&self) -> Self::StableHashingContext; + fn create_stable_hashing_context(&self) -> StableHashingContext<'_>; /// Access the DepGraph. fn dep_graph(&self) -> &DepGraph<Self::DepKind>; @@ -36,18 +36,13 @@ pub trait DepContext: Copy { pub trait HasDepContext: Copy { type DepKind: self::DepKind; - type StableHashingContext; - type DepContext: self::DepContext< - DepKind = Self::DepKind, - StableHashingContext = Self::StableHashingContext, - >; + type DepContext: self::DepContext<DepKind = Self::DepKind>; fn dep_context(&self) -> &Self::DepContext; } impl<T: DepContext> HasDepContext for T { type DepKind = T::DepKind; - type StableHashingContext = T::StableHashingContext; type DepContext = Self; fn dep_context(&self) -> &Self::DepContext { diff --git a/compiler/rustc_query_system/src/query/config.rs b/compiler/rustc_query_system/src/query/config.rs index d1e527dff98..76a165ed8e6 100644 --- a/compiler/rustc_query_system/src/query/config.rs +++ b/compiler/rustc_query_system/src/query/config.rs @@ -2,6 +2,7 @@ use crate::dep_graph::DepNode; use crate::dep_graph::SerializedDepNodeIndex; +use crate::ich::StableHashingContext; use crate::query::caches::QueryCache; use crate::query::{QueryCacheStore, QueryContext, QueryState}; @@ -23,7 +24,7 @@ pub(crate) struct QueryVtable<CTX: QueryContext, K, V> { pub dep_kind: CTX::DepKind, pub eval_always: bool, - pub hash_result: fn(&mut CTX::StableHashingContext, &V) -> Option<Fingerprint>, + pub hash_result: fn(&mut StableHashingContext<'_>, &V) -> Option<Fingerprint>, pub handle_cycle_error: fn(CTX, DiagnosticBuilder<'_>) -> V, pub cache_on_disk: fn(CTX, &K, Option<&V>) -> bool, pub try_load_from_disk: fn(CTX, SerializedDepNodeIndex) -> Option<V>, @@ -39,7 +40,7 @@ impl<CTX: QueryContext, K, V> QueryVtable<CTX, K, V> { pub(crate) fn hash_result( &self, - hcx: &mut CTX::StableHashingContext, + hcx: &mut StableHashingContext<'_>, value: &V, ) -> Option<Fingerprint> { (self.hash_result)(hcx, value) @@ -74,10 +75,8 @@ pub trait QueryAccessors<CTX: QueryContext>: QueryConfig { // Don't use this method to compute query results, instead use the methods on TyCtxt fn compute_fn(tcx: CTX, key: &Self::Key) -> fn(CTX::DepContext, Self::Key) -> Self::Value; - fn hash_result( - hcx: &mut CTX::StableHashingContext, - result: &Self::Value, - ) -> Option<Fingerprint>; + fn hash_result(hcx: &mut StableHashingContext<'_>, result: &Self::Value) + -> Option<Fingerprint>; fn handle_cycle_error(tcx: CTX, diag: DiagnosticBuilder<'_>) -> Self::Value; } |
