Skip to content

Commit 1ab3b71

Browse files
Make sure to record deps from cached task in new solver on first run
1 parent a7077bf commit 1ab3b71

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

compiler/rustc_query_system/src/dep_graph/graph.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,11 @@ impl<D: Deps> DepGraph<D> {
302302
OP: FnOnce() -> R,
303303
{
304304
match self.data() {
305-
Some(data) => data.with_anon_task(cx, dep_kind, op),
305+
Some(data) => {
306+
let (result, index) = data.with_anon_task_inner(cx, dep_kind, op);
307+
self.read_index(index);
308+
(result, index)
309+
}
306310
None => (op(), self.next_virtual_depnode_index()),
307311
}
308312
}
@@ -397,7 +401,7 @@ impl<D: Deps> DepGraphData<D> {
397401

398402
/// Executes something within an "anonymous" task, that is, a task the
399403
/// `DepNode` of which is determined by the list of inputs it read from.
400-
pub(crate) fn with_anon_task<Tcx: DepContext<Deps = D>, OP, R>(
404+
pub(crate) fn with_anon_task_inner<Tcx: DepContext<Deps = D>, OP, R>(
401405
&self,
402406
cx: Tcx,
403407
dep_kind: DepKind,

compiler/rustc_query_system/src/query/plumbing.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,11 @@ where
520520
let (result, dep_node_index) =
521521
qcx.start_query(job_id, query.depth_limit(), Some(&diagnostics), || {
522522
if query.anon() {
523-
return dep_graph_data.with_anon_task(*qcx.dep_context(), query.dep_kind(), || {
524-
query.compute(qcx, key)
525-
});
523+
return dep_graph_data.with_anon_task_inner(
524+
*qcx.dep_context(),
525+
query.dep_kind(),
526+
|| query.compute(qcx, key),
527+
);
526528
}
527529

528530
// `to_dep_node` is expensive for some `DepKind`s.

compiler/rustc_trait_selection/src/traits/select/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1400,10 +1400,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
14001400
where
14011401
OP: FnOnce(&mut Self) -> R,
14021402
{
1403-
let (result, dep_node) =
1404-
self.tcx().dep_graph.with_anon_task(self.tcx(), dep_kinds::TraitSelect, || op(self));
1405-
self.tcx().dep_graph.read_index(dep_node);
1406-
(result, dep_node)
1403+
self.tcx().dep_graph.with_anon_task(self.tcx(), dep_kinds::TraitSelect, || op(self))
14071404
}
14081405

14091406
/// filter_impls filters candidates that have a positive impl for a negative

compiler/rustc_type_ir/src/search_graph/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
511511

512512
// This is for global caching, so we properly track query dependencies.
513513
// Everything that affects the `result` should be performed within this
514-
// `with_anon_task` closure. If computing this goal depends on something
514+
// `with_cached_task` closure. If computing this goal depends on something
515515
// not tracked by the cache key and from outside of this anon task, it
516516
// must not be added to the global cache. Notably, this is the case for
517517
// trait solver cycles participants.

0 commit comments

Comments
 (0)