diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 55576b4e0d19d..38aebc81cd6b8 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -2459,6 +2459,11 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { let pretty = parse_pretty(&unstable_opts, error_format); + // query-dep-graph is required if dump-dep-graph is given #106736 + if unstable_opts.dump_dep_graph && !unstable_opts.query_dep_graph { + early_error(error_format, "can't dump dependency graph without `-Z query-dep-graph`"); + } + // Try to find a directory containing the Rust `src`, for more details see // the doc comment on the `real_rust_source_base_dir` field. let tmp_buf; diff --git a/tests/ui/dep-graph/dep-graph-dump.rs b/tests/ui/dep-graph/dep-graph-dump.rs new file mode 100644 index 0000000000000..cbc4def0e03aa --- /dev/null +++ b/tests/ui/dep-graph/dep-graph-dump.rs @@ -0,0 +1,6 @@ +// Test dump-dep-graph requires query-dep-graph enabled + +// incremental +// compile-flags: -Z dump-dep-graph + +fn main() {} diff --git a/tests/ui/dep-graph/dep-graph-dump.stderr b/tests/ui/dep-graph/dep-graph-dump.stderr new file mode 100644 index 0000000000000..ea44b8bb07509 --- /dev/null +++ b/tests/ui/dep-graph/dep-graph-dump.stderr @@ -0,0 +1,2 @@ +error: can't dump dependency graph without `-Z query-dep-graph` +