diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2020-10-11 10:34:50 +0200 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2021-02-19 17:51:49 +0100 |
| commit | 211b05aef3d71fab0df7aa2f9616286a693a5cd7 (patch) | |
| tree | e94d4e8bf3a054b84b4eba96c0724cb025c24ee1 /compiler/rustc_query_system | |
| parent | 7794fbb47839ed0749647be343c4e52e6564123b (diff) | |
| download | rust-211b05aef3d71fab0df7aa2f9616286a693a5cd7.tar.gz rust-211b05aef3d71fab0df7aa2f9616286a693a5cd7.zip | |
Don't require a QueryContext to access the DepGraph.
Diffstat (limited to 'compiler/rustc_query_system')
| -rw-r--r-- | compiler/rustc_query_system/src/cache.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/dep_graph/dep_node.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/dep_graph/mod.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/query/mod.rs | 5 |
4 files changed, 8 insertions, 9 deletions
diff --git a/compiler/rustc_query_system/src/cache.rs b/compiler/rustc_query_system/src/cache.rs index be3d3607728..c6dc7b4fe28 100644 --- a/compiler/rustc_query_system/src/cache.rs +++ b/compiler/rustc_query_system/src/cache.rs @@ -1,7 +1,6 @@ //! Cache for candidate selection. -use crate::dep_graph::DepNodeIndex; -use crate::query::QueryContext; +use crate::dep_graph::{DepContext, DepNodeIndex}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::HashMapExt; @@ -28,7 +27,7 @@ impl<Key, Value> Cache<Key, Value> { } impl<Key: Eq + Hash, Value: Clone> Cache<Key, Value> { - pub fn get<CTX: QueryContext>(&self, key: &Key, tcx: CTX) -> Option<Value> { + pub fn get<CTX: DepContext>(&self, key: &Key, tcx: CTX) -> Option<Value> { Some(self.hashmap.borrow().get(key)?.get(tcx)) } @@ -55,7 +54,7 @@ impl<T: Clone> WithDepNode<T> { WithDepNode { dep_node, cached_value } } - pub fn get<CTX: QueryContext>(&self, tcx: CTX) -> T { + pub fn get<CTX: DepContext>(&self, tcx: CTX) -> T { tcx.dep_graph().read_index(self.dep_node); self.cached_value.clone() } 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 64aba870502..1319a31b8f5 100644 --- a/compiler/rustc_query_system/src/dep_graph/dep_node.rs +++ b/compiler/rustc_query_system/src/dep_graph/dep_node.rs @@ -79,7 +79,7 @@ impl<K: DepKind> DepNode<K> { pub fn construct<Ctxt, Key>(tcx: Ctxt, kind: K, arg: &Key) -> DepNode<K> where - Ctxt: crate::query::QueryContext<DepKind = K>, + Ctxt: super::DepContext<DepKind = K>, Key: DepNodeParams<Ctxt>, { let hash = arg.to_fingerprint(tcx); diff --git a/compiler/rustc_query_system/src/dep_graph/mod.rs b/compiler/rustc_query_system/src/dep_graph/mod.rs index b1c901633a7..5c1444ad6c4 100644 --- a/compiler/rustc_query_system/src/dep_graph/mod.rs +++ b/compiler/rustc_query_system/src/dep_graph/mod.rs @@ -29,6 +29,9 @@ pub trait DepContext: Copy { fn debug_dep_tasks(&self) -> bool; fn debug_dep_node(&self) -> bool; + /// Access the DepGraph. + fn dep_graph(&self) -> &DepGraph<Self::DepKind>; + /// Try to force a dep node to execute and see if it's green. fn try_force_from_dep_node(&self, dep_node: &DepNode<Self::DepKind>) -> bool; diff --git a/compiler/rustc_query_system/src/query/mod.rs b/compiler/rustc_query_system/src/query/mod.rs index da45565dbe6..84d4b406c84 100644 --- a/compiler/rustc_query_system/src/query/mod.rs +++ b/compiler/rustc_query_system/src/query/mod.rs @@ -14,7 +14,7 @@ pub use self::caches::{ mod config; pub use self::config::{QueryAccessors, QueryConfig, QueryDescription}; -use crate::dep_graph::{DepContext, DepGraph}; +use crate::dep_graph::DepContext; use crate::query::job::QueryMap; use rustc_data_structures::stable_hasher::HashStable; @@ -32,9 +32,6 @@ pub trait QueryContext: DepContext { /// Get string representation from DefPath. fn def_path_str(&self, def_id: DefId) -> String; - /// Access the DepGraph. - fn dep_graph(&self) -> &DepGraph<Self::DepKind>; - /// Get the query information from the TLS context. fn current_query_job(&self) -> Option<QueryJobId<Self::DepKind>>; |
