diff --git a/compiler/rustc_middle/src/dep_graph/mod.rs b/compiler/rustc_middle/src/dep_graph/mod.rs index b88ffa2bb73..eaf414ccaa6 100644 --- a/compiler/rustc_middle/src/dep_graph/mod.rs +++ b/compiler/rustc_middle/src/dep_graph/mod.rs @@ -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 diff --git a/compiler/rustc_middle/src/ty/query/plumbing.rs b/compiler/rustc_middle/src/ty/query/plumbing.rs index 1cb705c251c..891da797b34 100644 --- a/compiler/rustc_middle/src/ty/query/plumbing.rs +++ b/compiler/rustc_middle/src/ty/query/plumbing.rs @@ -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> { tls::with_related_context(*self, |icx| icx.query) } 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 Cache { } impl Cache { - pub fn get(&self, key: &Key, tcx: CTX) -> Option { + pub fn get(&self, key: &Key, tcx: CTX) -> Option { Some(self.hashmap.borrow().get(key)?.get(tcx)) } @@ -55,7 +54,7 @@ impl WithDepNode { WithDepNode { dep_node, cached_value } } - pub fn get(&self, tcx: CTX) -> T { + pub fn get(&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 DepNode { pub fn construct(tcx: Ctxt, kind: K, arg: &Key) -> DepNode where - Ctxt: crate::query::QueryContext, + Ctxt: super::DepContext, Key: DepNodeParams, { 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; + /// Try to force a dep node to execute and see if it's green. fn try_force_from_dep_node(&self, dep_node: &DepNode) -> 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; - /// Get the query information from the TLS context. fn current_query_job(&self) -> Option>;