Skip to content

Commit d7e9a30

Browse files
committed
Turn write_dep_info into a regular function
It has side-effects and as such can't be cached.
1 parent 365a580 commit d7e9a30

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

compiler/rustc_driver_impl/src/lib.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,7 @@ fn run_compiler(
401401
Ok(())
402402
})?;
403403

404-
// Make sure the `write_dep_info` query is run for its side
405-
// effects of writing the dep-info and reporting errors.
406-
queries.global_ctxt()?.enter(|tcx| tcx.write_dep_info(()));
404+
queries.write_dep_info()?;
407405
} else {
408406
let krate = queries.parse()?;
409407
pretty::print(
@@ -431,9 +429,7 @@ fn run_compiler(
431429
return early_exit();
432430
}
433431

434-
// Make sure the `write_dep_info` query is run for its side
435-
// effects of writing the dep-info and reporting errors.
436-
queries.global_ctxt()?.enter(|tcx| tcx.write_dep_info(()));
432+
queries.write_dep_info()?;
437433

438434
if sess.opts.output_types.contains_key(&OutputType::DepInfo)
439435
&& sess.opts.output_types.len() == 1

compiler/rustc_interface/src/passes.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ fn resolver_for_lowering<'tcx>(
553553
tcx.arena.alloc(Steal::new((untracked_resolver_for_lowering, Lrc::new(krate))))
554554
}
555555

556-
fn write_dep_info(tcx: TyCtxt<'_>, (): ()) {
556+
pub(crate) fn write_dep_info(tcx: TyCtxt<'_>) {
557557
// Make sure name resolution and macro expansion is run for
558558
// the side-effect of providing a complete set of all
559559
// accessed files and env vars.
@@ -606,7 +606,6 @@ pub static DEFAULT_QUERY_PROVIDERS: LazyLock<Providers> = LazyLock::new(|| {
606606
let providers = &mut Providers::default();
607607
providers.analysis = analysis;
608608
providers.hir_crate = rustc_ast_lowering::lower_to_hir;
609-
providers.write_dep_info = write_dep_info;
610609
providers.resolver_for_lowering = resolver_for_lowering;
611610
providers.early_lint_checks = early_lint_checks;
612611
proc_macro_decls::provide(providers);

compiler/rustc_interface/src/queries.rs

+7
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,13 @@ impl<'tcx> Queries<'tcx> {
176176
})
177177
}
178178

179+
pub fn write_dep_info(&'tcx self) -> Result<()> {
180+
self.global_ctxt()?.enter(|tcx| {
181+
passes::write_dep_info(tcx);
182+
});
183+
Ok(())
184+
}
185+
179186
/// Check for the `#[rustc_error]` annotation, which forces an error in codegen. This is used
180187
/// to write UI tests that actually test that compilation succeeds without reporting
181188
/// an error.

compiler/rustc_middle/src/query/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -1916,11 +1916,6 @@ rustc_queries! {
19161916
arena_cache
19171917
}
19181918

1919-
/// Write the dep-info file.
1920-
query write_dep_info(_: ()) -> () {
1921-
desc { "writing the dep-info file" }
1922-
}
1923-
19241919
/// Do not call this query directly: invoke `normalize` instead.
19251920
query normalize_projection_ty(
19261921
goal: CanonicalProjectionGoal<'tcx>

0 commit comments

Comments
 (0)