Skip to content

Don't monomorphize ty::tls closures in rustc_query_impl #106311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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