Don't require a QueryContext to access the DepGraph.
This commit is contained in:
parent
7794fbb478
commit
211b05aef3
|
@ -111,6 +111,11 @@ impl<'tcx> DepContext for TyCtxt<'tcx> {
|
|||
|| self.sess.opts.debugging_opts.query_dep_graph
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn dep_graph(&self) -> &DepGraph {
|
||||
&self.dep_graph
|
||||
}
|
||||
|
||||
fn try_force_from_dep_node(&self, dep_node: &DepNode) -> bool {
|
||||
// FIXME: This match is just a workaround for incremental bugs and should
|
||||
// be removed. https://github.com/rust-lang/rust/issues/62649 is one such
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
//! generate the actual methods on tcx which find and execute the provider,
|
||||
//! manage the caches, and so forth.
|
||||
|
||||
use crate::dep_graph::DepGraph;
|
||||
use crate::ty::query::Query;
|
||||
use crate::ty::tls::{self, ImplicitCtxt};
|
||||
use crate::ty::{self, TyCtxt};
|
||||
|
@ -30,10 +29,6 @@ impl QueryContext for TyCtxt<'tcx> {
|
|||
TyCtxt::def_path_str(*self, def_id)
|
||||
}
|
||||
|
||||
fn dep_graph(&self) -> &DepGraph {
|
||||
&self.dep_graph
|
||||
}
|
||||
|
||||
fn current_query_job(&self) -> Option<QueryJobId<Self::DepKind>> {
|
||||
tls::with_related_context(*self, |icx| icx.query)
|
||||
}
|
||||
|
|
|
@ -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…
Reference in New Issue