]> git.lizzy.rs Git - rust.git/commitdiff
Rename read_query_job -> current_query_job and simplify it.
authorCamille GILLOT <gillot.camille@gmail.com>
Wed, 25 Mar 2020 06:52:12 +0000 (07:52 +0100)
committerCamille GILLOT <gillot.camille@gmail.com>
Thu, 26 Mar 2020 08:40:52 +0000 (09:40 +0100)
src/librustc/ty/query/plumbing.rs
src/librustc_query_system/query/config.rs
src/librustc_query_system/query/job.rs
src/librustc_query_system/query/plumbing.rs

index 8e34aba8a9edd2bbf68342f4a77340ec38373ff6..8cdc1ae27ee002a22ca7536781c107ebbf5fff11 100644 (file)
@@ -32,8 +32,8 @@ fn dep_graph(&self) -> &DepGraph {
         &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(
index 10338f6547126befa69a7e8f08fd7e22c679eac0..106688d2b54ebe5fd9ae27084c26e5de785a6e75 100644 (file)
@@ -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,
index 92ab97f210a5deadd5cb90fdd7140e6ea654535d..a7488b6fdff10bc3227897d9f429676e6636e111 100644 (file)
@@ -150,7 +150,7 @@ pub(super) fn find_cycle_in_stack(&self, tcx: CTX, span: Span) -> CycleError<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 @@ fn new() -> Self {
 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),
+        }
     }
 }
 
index e1b86e55ce8cfa7abd273488e06640823d1a9d6a..b3187ba91899594a0aa8a554bb1463b89a0f7a6b 100644 (file)
@@ -211,7 +211,8 @@ fn try_start<'a, 'b, Q>(
 
                 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));