Skip to content
Merged
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
8 changes: 7 additions & 1 deletion compiler/rustc_middle/src/dep_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,13 @@ impl DepGraph {
where
F: FnOnce() -> String,
{
let dep_node_debug = &self.data.as_ref().unwrap().dep_node_debug;
// Early queries (e.g., `-Z query-dep-graph` on empty crates) can reach here
// before the graph is initialized. Return early to prevent an ICE.
let data = match &self.data {
Some(d) => d,
None => return,
};
let dep_node_debug = &data.dep_node_debug;

if dep_node_debug.borrow().contains_key(&dep_node) {
return;
Expand Down
7 changes: 7 additions & 0 deletions tests/ui/dep-graph/query-dep-graph-empty.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//@ build-pass
//@ compile-flags: -Zquery-dep-graph --crate-type lib
//@ edition: 2021

// This file is intentionally left empty to reproduce issue #153199.
// rustc used to ICE when generating a dependency graph for an empty file
// because early queries would panic when unwrapping an uninitialized graph.
Loading