Skip to content

Commit 27e8a95

Browse files
committed
Generalise Query starting.
1 parent 4ac4ccd commit 27e8a95

File tree

4 files changed

+122
-76
lines changed

4 files changed

+122
-76
lines changed

src/librustc/dep_graph/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ impl<'tcx> DepContext for TyCtxt<'tcx> {
166166
self.queries.on_disk_cache.store_diagnostics(dep_node_index, diagnostics)
167167
}
168168

169+
fn store_diagnostics_for_anon_node(&self, dep_node_index: DepNodeIndex, diagnostics: ThinVec<Diagnostic>) {
170+
self.queries.on_disk_cache.store_diagnostics_for_anon_node(dep_node_index, diagnostics)
171+
}
172+
169173
fn profiler(&self) -> &SelfProfilerRef {
170174
&self.prof
171175
}

src/librustc/ty/query/config.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ use rustc_hir::def_id::DefId;
1111
use rustc_data_structures::fingerprint::Fingerprint;
1212
use rustc_data_structures::fx::FxHashMap;
1313
use rustc_data_structures::stable_hasher::HashStable;
14-
use rustc_query_system::dep_graph::{DepContext, DepNode};
14+
use rustc_data_structures::sync::Lock;
15+
use rustc_data_structures::thin_vec::ThinVec;
16+
use rustc_errors::Diagnostic;
17+
use rustc_query_system::dep_graph::{DepContext, DepGraph, DepNode};
1518
use rustc_session::Session;
1619
use std::borrow::Cow;
1720
use std::fmt::Debug;
@@ -34,12 +37,25 @@ pub trait QueryContext: DepContext {
3437
/// Get string representation from DefPath.
3538
fn def_path_str(&self, def_id: DefId) -> String;
3639

40+
/// Access the DepGraph.
41+
fn dep_graph(&self) -> &DepGraph<Self::DepKind>;
42+
3743
/// Get the query information from the TLS context.
3844
fn read_query_job<R>(&self, op: impl FnOnce(Option<QueryJobId<Self::DepKind>>) -> R) -> R;
3945

4046
fn try_collect_active_jobs(
4147
&self,
4248
) -> Option<FxHashMap<QueryJobId<Self::DepKind>, QueryJobInfo<Self>>>;
49+
50+
/// Executes a job by changing the `ImplicitCtxt` to point to the
51+
/// new query job while it executes. It returns the diagnostics
52+
/// captured during execution and the actual result.
53+
fn start_query<R>(
54+
&self,
55+
token: QueryJobId<Self::DepKind>,
56+
diagnostics: Option<&Lock<ThinVec<Diagnostic>>>,
57+
compute: impl FnOnce(Self) -> R,
58+
) -> R;
4359
}
4460

4561
pub(crate) trait QueryAccessors<CTX: QueryContext>: QueryConfig<CTX> {

0 commit comments

Comments
 (0)