about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2020-03-07 00:43:17 +0100
committerCamille GILLOT <gillot.camille@gmail.com>2020-03-16 09:10:16 +0100
commitfc82376bc437d4494832b171d924e2f116174578 (patch)
tree8d18af9e9f11a75a08ed6d7ddad5319aef09d492
parent0bf5cae489e828a6678cab5144e638ae909d7b93 (diff)
downloadrust-fc82376bc437d4494832b171d924e2f116174578.tar.gz
rust-fc82376bc437d4494832b171d924e2f116174578.zip
Make QueryAccessor::dep_kind an associated const.
-rw-r--r--src/librustc/ty/query/config.rs3
-rw-r--r--src/librustc/ty/query/plumbing.rs14
2 files changed, 6 insertions, 11 deletions
diff --git a/src/librustc/ty/query/config.rs b/src/librustc/ty/query/config.rs
index 178c2362def..5a05acc90e4 100644
--- a/src/librustc/ty/query/config.rs
+++ b/src/librustc/ty/query/config.rs
@@ -28,6 +28,7 @@ pub trait QueryConfig<'tcx> {
 pub(crate) trait QueryAccessors<'tcx>: QueryConfig<'tcx> {
     const ANON: bool;
     const EVAL_ALWAYS: bool;
+    const DEP_KIND: DepKind;
 
     type Cache: QueryCache<Self::Key, Self::Value>;
 
@@ -38,8 +39,6 @@ pub(crate) trait QueryAccessors<'tcx>: QueryConfig<'tcx> {
 
     fn to_dep_node(tcx: TyCtxt<'tcx>, key: &Self::Key) -> DepNode;
 
-    fn dep_kind() -> DepKind;
-
     // Don't use this method to compute query results, instead use the methods on TyCtxt
     fn compute(tcx: TyCtxt<'tcx>, key: Self::Key) -> Self::Value;
 
diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs
index bfae0075c8d..603c4fd9b72 100644
--- a/src/librustc/ty/query/plumbing.rs
+++ b/src/librustc/ty/query/plumbing.rs
@@ -154,7 +154,7 @@ impl<'tcx, Q: QueryDescription<'tcx>> JobOwner<'tcx, Q> {
                         };
 
                         // Create the id of the job we're waiting for
-                        let id = QueryJobId::new(job.id, lookup.shard, Q::dep_kind());
+                        let id = QueryJobId::new(job.id, lookup.shard, Q::DEP_KIND);
 
                         (job.latch(id), _query_blocked_prof_timer)
                     }
@@ -169,7 +169,7 @@ impl<'tcx, Q: QueryDescription<'tcx>> JobOwner<'tcx, Q> {
                 lock.jobs = id;
                 let id = QueryShardJobId(NonZeroU32::new(id).unwrap());
 
-                let global_id = QueryJobId::new(id, lookup.shard, Q::dep_kind());
+                let global_id = QueryJobId::new(id, lookup.shard, Q::DEP_KIND);
 
                 let job = tls::with_related_context(tcx, |icx| QueryJob::new(id, span, icx.query));
 
@@ -498,7 +498,7 @@ impl<'tcx> TyCtxt<'tcx> {
 
             let ((result, dep_node_index), diagnostics) = with_diagnostics(|diagnostics| {
                 self.start_query(job.id, diagnostics, |tcx| {
-                    tcx.dep_graph.with_anon_task(Q::dep_kind(), || Q::compute(tcx, key))
+                    tcx.dep_graph.with_anon_task(Q::DEP_KIND, || Q::compute(tcx, key))
                 })
             });
 
@@ -873,7 +873,7 @@ macro_rules! define_queries_inner {
                                     job: job.id,
                                     shard:  u16::try_from(shard_id).unwrap(),
                                     kind:
-                                        <queries::$name<'tcx> as QueryAccessors<'tcx>>::dep_kind(),
+                                        <queries::$name<'tcx> as QueryAccessors<'tcx>>::DEP_KIND,
                                 };
                                 let info = QueryInfo {
                                     span: job.span,
@@ -961,6 +961,7 @@ macro_rules! define_queries_inner {
         impl<$tcx> QueryAccessors<$tcx> for queries::$name<$tcx> {
             const ANON: bool = is_anon!([$($modifiers)*]);
             const EVAL_ALWAYS: bool = is_eval_always!([$($modifiers)*]);
+            const DEP_KIND: dep_graph::DepKind = dep_graph::DepKind::$node;
 
             type Cache = query_storage!([$($modifiers)*][$K, $V]);
 
@@ -980,11 +981,6 @@ macro_rules! define_queries_inner {
                 DepConstructor::$node(tcx, *key)
             }
 
-            #[inline(always)]
-            fn dep_kind() -> dep_graph::DepKind {
-                dep_graph::DepKind::$node
-            }
-
             #[inline]
             fn compute(tcx: TyCtxt<'tcx>, key: Self::Key) -> Self::Value {
                 let provider = tcx.queries.providers.get(key.query_crate())