Don't require a QueryContext to access the DepGraph.
This commit is contained in:
parent
7794fbb478
commit
211b05aef3
6 changed files with 13 additions and 14 deletions
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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>>;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue