mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Fix ICE on empty file with -Zquery-dep-graph
This commit is contained in:
@@ -826,7 +826,13 @@ pub(crate) fn register_dep_node_debug_str<F>(&self, dep_node: DepNode, debug_str
|
||||
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;
|
||||
|
||||
@@ -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.
|
||||
Reference in New Issue
Block a user