rust-lang/rust · critical
Cannot summarize when dependencies are not recorded.
Error message
Cannot summarize when dependencies are not recorded.
What it means
In `with_task` (graph.rs:652), after running a query the dep graph summarizes the task's recorded reads to allocate a dep node. The read-deps closure must handle every `TaskDepsRef` variant; `Forbid` means dependencies were explicitly disallowed for this task, so summarization is impossible and the compiler panics rather than silently dropping the node.
Source
Thrown at compiler/rustc_middle/src/dep_graph/graph.rs:652
);
}
return dep_node_index;
}
}
// `read_deps` calls the closure exactly once, with the current task's deps.
let mut reads = SmallVec::<[DepNodeIndex; SMALL_READS_MAX]>::new();
read_deps(|task_deps| match task_deps {
TaskDepsRef::Allow(deps) => {
reads = SmallVec::from_slice(deps.lock().edges());
}
TaskDepsRef::EvalAlways => {
reads.push(DepNodeIndex::FOREVER_RED_NODE);
}
TaskDepsRef::Ignore => {}
TaskDepsRef::Forbid => {
panic!("Cannot summarize when dependencies are not recorded.")
}
});
data.hash_result_and_alloc_node(tcx, node, &reads, result, hash_result)
} else {
// Incremental compilation is turned off. We just execute the task
// without tracking. We still provide a dep-node index that uniquely
// identifies the task so that we have a cheap way of referring to
// the query for self-profiling.
self.next_virtual_depnode_index()
}
}
}
impl DepGraphData {
fn assert_dep_node_not_yet_allocated_in_current_session<S: std::fmt::Display>(
&self,
sess: &Session,View on GitHub (pinned to 22057b88b0)
Solutions
- If you hit this as an end user, treat it as an internal compiler bug: capture the ICE note and file a rustc issue with the repro.
- As a workaround, disable incremental compilation for the failing build (`CARGO_INCREMENTAL=0` or `-Zincremental=no`).
- If developing rustc, audit the query's TaskDeps assignment — a `Forbid` task should not reach the summarization/alloc path.
Defensive patterns
Strategy: validation
Validate before calling
// Summarization requires that dependency edges were recorded; check first.
fn can_summarize(g: &DepGraph) -> Result<(), String> {
if g.dep_edges_recorded() {
Ok(())
} else {
Err("Cannot summarize when dependencies are not recorded.".into())
}
} Type guard
fn deps_recorded(g: &DepGraph) -> bool {
g.dep_edges_recorded()
} Prevention
- Only call summarize/serialize on a dep-graph built with dependency recording enabled (e.g. not in the 'no-dep-graph' or anonymous query mode).
- Confirm the compilation mode actually populates the dep graph before consuming it; release/no-dep builds skip recording.
- Do not reuse a graph handle after disabling recording for a sub-task.
When it happens
Trigger: An internal rustc invariant breach: a query ran under `TaskDepsRef::Forbid` (no dep recording allowed) yet execution reached the dep-node allocation path that requires summarizing reads. This indicates a bug in how a query's TaskDeps was configured versus the context it actually ran in.
Common situations: Developing/modifying rustc query plumbing; extremely rare in normal builds. Not triggered by user source code or configuration.
Related errors
- try_mark_previous_green() - forcing failed to set a color
- Invalid DepKind {u}
- local id should be u32, found {local_id:?}
- forbidden edge {:?} -> {:?} created
- Query label {label} does not exist
AI-assisted analysis of rust-lang/rust@22057b88b0 (2026-08-03).
Data as JSON: /data/errors/1f8097280f112591.json.
Report an issue: GitHub.