about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2020-03-18 21:02:02 +0100
committerCamille GILLOT <gillot.camille@gmail.com>2020-03-26 09:22:45 +0100
commita51ad889dd712e8b665656ebf08a2f85034f7415 (patch)
tree393f2da6a782c3ca10fd20337df101d23772b68d
parent2a52436619d94e42aa1e0ca57f412e5ce06ef561 (diff)
downloadrust-a51ad889dd712e8b665656ebf08a2f85034f7415.tar.gz
rust-a51ad889dd712e8b665656ebf08a2f85034f7415.zip
Decouple from DepKind.
-rw-r--r--src/librustc/dep_graph/mod.rs6
-rw-r--r--src/librustc/ty/query/config.rs3
-rw-r--r--src/librustc/ty/query/plumbing.rs21
-rw-r--r--src/librustc_query_system/dep_graph/mod.rs4
4 files changed, 22 insertions, 12 deletions
diff --git a/src/librustc/dep_graph/mod.rs b/src/librustc/dep_graph/mod.rs
index 3c39597584d..dfb962227ff 100644
--- a/src/librustc/dep_graph/mod.rs
+++ b/src/librustc/dep_graph/mod.rs
@@ -27,6 +27,8 @@ pub type PreviousDepGraph = rustc_query_system::dep_graph::PreviousDepGraph<DepK
 pub type SerializedDepGraph = rustc_query_system::dep_graph::SerializedDepGraph<DepKind>;
 
 impl rustc_query_system::dep_graph::DepKind for DepKind {
+    const NULL: Self = DepKind::Null;
+
     fn is_eval_always(&self) -> bool {
         DepKind::is_eval_always(self)
     }
@@ -82,6 +84,10 @@ impl rustc_query_system::dep_graph::DepKind for DepKind {
             op(icx.task_deps)
         })
     }
+
+    fn can_reconstruct_query_key(&self) -> bool {
+        DepKind::can_reconstruct_query_key(self)
+    }
 }
 
 impl<'tcx> DepContext for TyCtxt<'tcx> {
diff --git a/src/librustc/ty/query/config.rs b/src/librustc/ty/query/config.rs
index 77feb7f4df3..c3b0103cc0c 100644
--- a/src/librustc/ty/query/config.rs
+++ b/src/librustc/ty/query/config.rs
@@ -1,6 +1,5 @@
 //! Query configuration and description traits.
 
-use crate::dep_graph::DepKind;
 use crate::dep_graph::SerializedDepNodeIndex;
 use crate::ty::query::caches::QueryCache;
 use crate::ty::query::plumbing::CycleError;
@@ -23,7 +22,7 @@ pub trait QueryConfig<CTX> {
     type Value: Clone;
 }
 
-pub trait QueryContext: DepContext<DepKind = DepKind> {
+pub trait QueryContext: DepContext {
     type Query;
 
     /// Access the session.
diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs
index 2d1614d6ccd..ede1ccdbc04 100644
--- a/src/librustc/ty/query/plumbing.rs
+++ b/src/librustc/ty/query/plumbing.rs
@@ -2,7 +2,7 @@
 //! generate the actual methods on tcx which find and execute the provider,
 //! manage the caches, and so forth.
 
-use crate::dep_graph::{DepKind, DepNode, DepNodeIndex, SerializedDepNodeIndex};
+use crate::dep_graph::{DepNodeIndex, SerializedDepNodeIndex};
 use crate::ty::query::caches::QueryCache;
 use crate::ty::query::config::{QueryContext, QueryDescription};
 use crate::ty::query::job::{QueryInfo, QueryJob, QueryJobId, QueryJobInfo, QueryShardJobId};
@@ -17,6 +17,7 @@ use rustc_data_structures::sharded::Sharded;
 use rustc_data_structures::sync::{Lock, LockGuard};
 use rustc_data_structures::thin_vec::ThinVec;
 use rustc_errors::{struct_span_err, Diagnostic, DiagnosticBuilder, FatalError, Handler, Level};
+use rustc_query_system::dep_graph::{DepKind, DepNode};
 use rustc_session::Session;
 use rustc_span::def_id::DefId;
 use rustc_span::source_map::DUMMY_SP;
@@ -102,7 +103,7 @@ impl<CTX: QueryContext, C: QueryCache<CTX>> QueryState<CTX, C> {
 
     pub(super) fn try_collect_active_jobs(
         &self,
-        kind: DepKind,
+        kind: CTX::DepKind,
         make_query: fn(C::Key) -> CTX::Query,
         jobs: &mut FxHashMap<QueryJobId<CTX::DepKind>, QueryJobInfo<CTX>>,
     ) -> Option<()>
@@ -375,7 +376,7 @@ impl<'tcx> TyCtxt<'tcx> {
     #[inline(always)]
     fn start_query<F, R>(
         self,
-        token: QueryJobId<DepKind>,
+        token: QueryJobId<crate::dep_graph::DepKind>,
         diagnostics: Option<&Lock<ThinVec<Diagnostic>>>,
         compute: F,
     ) -> R
@@ -570,7 +571,7 @@ impl<'tcx> TyCtxt<'tcx> {
         // Fast path for when incr. comp. is off. `to_dep_node` is
         // expensive for some `DepKind`s.
         if !self.dep_graph.is_fully_enabled() {
-            let null_dep_node = DepNode::new_no_params(crate::dep_graph::DepKind::Null);
+            let null_dep_node = DepNode::new_no_params(DepKind::NULL);
             return self.force_query_with_job::<Q>(key, job, null_dep_node).0;
         }
 
@@ -634,7 +635,7 @@ impl<'tcx> TyCtxt<'tcx> {
         key: Q::Key,
         prev_dep_node_index: SerializedDepNodeIndex,
         dep_node_index: DepNodeIndex,
-        dep_node: &DepNode,
+        dep_node: &DepNode<crate::dep_graph::DepKind>,
     ) -> Q::Value {
         // Note this function can be called concurrently from the same query
         // We must ensure that this is handled correctly.
@@ -689,7 +690,7 @@ impl<'tcx> TyCtxt<'tcx> {
     fn incremental_verify_ich<Q: QueryDescription<TyCtxt<'tcx>>>(
         self,
         result: &Q::Value,
-        dep_node: &DepNode,
+        dep_node: &DepNode<crate::dep_graph::DepKind>,
         dep_node_index: DepNodeIndex,
     ) {
         use rustc_data_structures::fingerprint::Fingerprint;
@@ -716,8 +717,8 @@ impl<'tcx> TyCtxt<'tcx> {
     fn force_query_with_job<Q: QueryDescription<TyCtxt<'tcx>> + 'tcx>(
         self,
         key: Q::Key,
-        job: JobOwner<'tcx, TyCtxt<'tcx>, Q::Cache>,
-        dep_node: DepNode,
+        job: JobOwner<'tcx, Self, Q::Cache>,
+        dep_node: DepNode<crate::dep_graph::DepKind>,
     ) -> (Q::Value, DepNodeIndex) {
         // If the following assertion triggers, it can have two reasons:
         // 1. Something is wrong with DepNode creation, either here or
@@ -754,7 +755,7 @@ impl<'tcx> TyCtxt<'tcx> {
         prof_timer.finish_with_query_invocation_id(dep_node_index.into());
 
         if unlikely!(!diagnostics.is_empty()) {
-            if dep_node.kind != crate::dep_graph::DepKind::Null {
+            if dep_node.kind != DepKind::NULL {
                 self.queries.on_disk_cache.store_diagnostics(dep_node_index, diagnostics);
             }
         }
@@ -803,7 +804,7 @@ impl<'tcx> TyCtxt<'tcx> {
         self,
         key: Q::Key,
         span: Span,
-        dep_node: DepNode,
+        dep_node: DepNode<crate::dep_graph::DepKind>,
     ) {
         // We may be concurrently trying both execute and force a query.
         // Ensure that only one of them runs the query.
diff --git a/src/librustc_query_system/dep_graph/mod.rs b/src/librustc_query_system/dep_graph/mod.rs
index 825b341cd14..888151782c7 100644
--- a/src/librustc_query_system/dep_graph/mod.rs
+++ b/src/librustc_query_system/dep_graph/mod.rs
@@ -54,6 +54,8 @@ pub trait DepContext: Copy {
 
 /// Describe the different families of dependency nodes.
 pub trait DepKind: Copy + fmt::Debug + Eq + Ord + Hash {
+    const NULL: Self;
+
     /// Return whether this kind always require evaluation.
     fn is_eval_always(&self) -> bool;
 
@@ -72,4 +74,6 @@ pub trait DepKind: Copy + fmt::Debug + Eq + Ord + Hash {
     fn read_deps<OP>(op: OP) -> ()
     where
         OP: for<'a> FnOnce(Option<&'a Lock<TaskDeps<Self>>>) -> ();
+
+    fn can_reconstruct_query_key(&self) -> bool;
 }