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

  1. 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.
  2. As a workaround, disable incremental compilation for the failing build (`CARGO_INCREMENTAL=0` or `-Zincremental=no`).
  3. 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

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


AI-assisted analysis of rust-lang/rust@22057b88b0 (2026-08-03). Data as JSON: /data/errors/1f8097280f112591.json. Report an issue: GitHub.