about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2020-03-25 07:52:12 +0100
committerCamille GILLOT <gillot.camille@gmail.com>2020-03-26 09:40:52 +0100
commitd224e214e051a92c5313a2d4ec0c94d41c4ba01d (patch)
tree558289a754b8c9caceaaa62dcf0ce9bedb3a6896
parentfce0d37619736b0e56eabab8f9064fad471a2b5f (diff)
downloadrust-d224e214e051a92c5313a2d4ec0c94d41c4ba01d.tar.gz
rust-d224e214e051a92c5313a2d4ec0c94d41c4ba01d.zip
Rename read_query_job -> current_query_job and simplify it.
-rw-r--r--src/librustc/ty/query/plumbing.rs4
-rw-r--r--src/librustc_query_system/query/config.rs2
-rw-r--r--src/librustc_query_system/query/job.rs31
-rw-r--r--src/librustc_query_system/query/plumbing.rs3
4 files changed, 18 insertions, 22 deletions
diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs
index 8e34aba8a9e..8cdc1ae27ee 100644
--- a/src/librustc/ty/query/plumbing.rs
+++ b/src/librustc/ty/query/plumbing.rs
@@ -32,8 +32,8 @@ impl QueryContext for TyCtxt<'tcx> {
         &self.dep_graph
     }
 
-    fn read_query_job<R>(&self, op: impl FnOnce(Option<QueryJobId<Self::DepKind>>) -> R) -> R {
-        tls::with_related_context(*self, move |icx| op(icx.query))
+    fn current_query_job(&self) -> Option<QueryJobId<Self::DepKind>> {
+        tls::with_related_context(*self, |icx| icx.query)
     }
 
     fn try_collect_active_jobs(
diff --git a/src/librustc_query_system/query/config.rs b/src/librustc_query_system/query/config.rs
index 10338f65471..106688d2b54 100644
--- a/src/librustc_query_system/query/config.rs
+++ b/src/librustc_query_system/query/config.rs
@@ -43,7 +43,7 @@ pub trait QueryContext: DepContext {
     fn dep_graph(&self) -> &DepGraph<Self::DepKind>;
 
     /// Get the query information from the TLS context.
-    fn read_query_job<R>(&self, op: impl FnOnce(Option<QueryJobId<Self::DepKind>>) -> R) -> R;
+    fn current_query_job(&self) -> Option<QueryJobId<Self::DepKind>>;
 
     fn try_collect_active_jobs(
         &self,
diff --git a/src/librustc_query_system/query/job.rs b/src/librustc_query_system/query/job.rs
index 92ab97f210a..a7488b6fdff 100644
--- a/src/librustc_query_system/query/job.rs
+++ b/src/librustc_query_system/query/job.rs
@@ -150,7 +150,7 @@ impl<CTX: QueryContext> QueryLatch<CTX> {
         let query_map = tcx.try_collect_active_jobs().unwrap();
 
         // Get the current executing query (waiter) and find the waitee amongst its parents
-        let mut current_job = tcx.read_query_job(|query| query);
+        let mut current_job = tcx.current_query_job();
         let mut cycle = Vec::new();
 
         while let Some(job) = current_job {
@@ -222,23 +222,18 @@ impl<CTX: QueryContext> QueryLatch<CTX> {
 impl<CTX: QueryContext> QueryLatch<CTX> {
     /// Awaits for the query job to complete.
     pub(super) fn wait_on(&self, tcx: CTX, span: Span) -> Result<(), CycleError<CTX::Query>> {
-        tcx.read_query_job(move |query| {
-            let waiter = Lrc::new(QueryWaiter {
-                query,
-                span,
-                cycle: Lock::new(None),
-                condvar: Condvar::new(),
-            });
-            self.wait_on_inner(&waiter);
-            // FIXME: Get rid of this lock. We have ownership of the QueryWaiter
-            // although another thread may still have a Lrc reference so we cannot
-            // use Lrc::get_mut
-            let mut cycle = waiter.cycle.lock();
-            match cycle.take() {
-                None => Ok(()),
-                Some(cycle) => Err(cycle),
-            }
-        })
+        let query = tcx.current_query_job();
+        let waiter =
+            Lrc::new(QueryWaiter { query, span, cycle: Lock::new(None), condvar: Condvar::new() });
+        self.wait_on_inner(&waiter);
+        // FIXME: Get rid of this lock. We have ownership of the QueryWaiter
+        // although another thread may still have a Lrc reference so we cannot
+        // use Lrc::get_mut
+        let mut cycle = waiter.cycle.lock();
+        match cycle.take() {
+            None => Ok(()),
+            Some(cycle) => Err(cycle),
+        }
     }
 }
 
diff --git a/src/librustc_query_system/query/plumbing.rs b/src/librustc_query_system/query/plumbing.rs
index e1b86e55ce8..b3187ba9189 100644
--- a/src/librustc_query_system/query/plumbing.rs
+++ b/src/librustc_query_system/query/plumbing.rs
@@ -211,7 +211,8 @@ where
 
                 let global_id = QueryJobId::new(id, lookup.shard, Q::DEP_KIND);
 
-                let job = tcx.read_query_job(|query| QueryJob::new(id, span, query));
+                let job = tcx.current_query_job();
+                let job = QueryJob::new(id, span, job);
 
                 entry.insert(QueryResult::Started(job));