Skip to content

Commit

Permalink
combine both approaches
Browse files Browse the repository at this point in the history
  • Loading branch information
jyn514 committed Mar 9, 2023
1 parent bbed70c commit 6322be3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_query_impl/src/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl QueryContext for QueryCtxt<'_> {
token: QueryJobId,
depth_limit: bool,
diagnostics: Option<&Lock<ThinVec<Diagnostic>>>,
compute: impl FnOnce() -> R,
compute: &mut dyn FnMut() -> R,
) -> R {
// The `TyCtxt` stored in TLS has the same global interner lifetime
// as `self`, so we use `with_related_context` to relate the 'tcx lifetimes
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_query_system/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ pub trait QueryContext: HasDepContext {
token: QueryJobId,
depth_limit: bool,
diagnostics: Option<&Lock<ThinVec<Diagnostic>>>,
compute: impl FnOnce() -> R,
compute: &mut dyn FnMut() -> R,
) -> R;

fn depth_limit_error(self, job: QueryJobId);
Expand Down
7 changes: 4 additions & 3 deletions compiler/rustc_query_system/src/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,8 @@ where
}

let prof_timer = qcx.dep_context().profiler().query_provider();
let result = qcx.start_query(job_id, query.depth_limit(), None, || query.compute(qcx, key));
let result =
qcx.start_query(job_id, query.depth_limit(), None, &mut || query.compute(qcx, key));
let dep_node_index = dep_graph.next_virtual_depnode_index();
prof_timer.finish_with_query_invocation_id(dep_node_index.into());

Expand All @@ -445,7 +446,7 @@ where

// The diagnostics for this query will be promoted to the current session during
// `try_mark_green()`, so we can ignore them here.
if let Some(ret) = qcx.start_query(job_id, false, None, || {
if let Some(ret) = qcx.start_query(job_id, false, None, &mut || {
try_load_from_disk_and_cache_in_memory(query, qcx, &key, &dep_node)
}) {
return ret;
Expand All @@ -456,7 +457,7 @@ where
let diagnostics = Lock::new(ThinVec::new());

let (result, dep_node_index) =
qcx.start_query(job_id, query.depth_limit(), Some(&diagnostics), || {
qcx.start_query(job_id, query.depth_limit(), Some(&diagnostics), &mut || {
if query.anon() {
return dep_graph.with_anon_task(*qcx.dep_context(), query.dep_kind(), || {
query.compute(qcx, key)
Expand Down

0 comments on commit 6322be3

Please sign in to comment.