Skip to content

Commit 4acaa02

Browse files
committed
Feed the output filenames into the TyCtxt
Since the introduction of the crate attribute pre-expansion pass we don't need access to the TyCtxt to compute it.
1 parent 98a6eaa commit 4acaa02

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

compiler/rustc_driver_impl/src/lib.rs

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

404-
// Make sure the `output_filenames` query is run for its side
404+
// Make sure the `write_dep_info` query is run for its side
405405
// effects of writing the dep-info and reporting errors.
406-
queries.global_ctxt()?.enter(|tcx| tcx.output_filenames(()));
406+
queries.global_ctxt()?.enter(|tcx| tcx.write_dep_info(()));
407407
} else {
408408
let krate = queries.parse()?;
409409
pretty::print(
@@ -431,9 +431,9 @@ fn run_compiler(
431431
return early_exit();
432432
}
433433

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

438438
if sess.opts.output_types.contains_key(&OutputType::DepInfo)
439439
&& sess.opts.output_types.len() == 1

compiler/rustc_interface/src/passes.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use std::any::Any;
3939
use std::ffi::OsString;
4040
use std::io::{self, BufWriter, Write};
4141
use std::path::{Path, PathBuf};
42-
use std::sync::{Arc, LazyLock};
42+
use std::sync::LazyLock;
4343
use std::{env, fs, iter};
4444

4545
pub fn parse<'a>(sess: &'a Session) -> PResult<'a, ast::Crate> {
@@ -553,12 +553,12 @@ fn resolver_for_lowering<'tcx>(
553553
tcx.arena.alloc(Steal::new((untracked_resolver_for_lowering, Lrc::new(krate))))
554554
}
555555

556-
fn output_filenames(tcx: TyCtxt<'_>, (): ()) -> Arc<OutputFilenames> {
556+
fn write_dep_info(tcx: TyCtxt<'_>, (): ()) {
557557
let sess = tcx.sess;
558-
let _timer = sess.timer("prepare_outputs");
558+
let _timer = sess.timer("write_dep_info");
559559
let crate_name = tcx.crate_name(LOCAL_CRATE);
560560

561-
let outputs = util::build_output_filenames(sess, crate_name.to_string());
561+
let outputs = tcx.output_filenames(());
562562
let output_paths =
563563
generated_output_paths(tcx, &outputs, sess.io.output_file.is_some(), crate_name);
564564

@@ -595,15 +595,13 @@ fn output_filenames(tcx: TyCtxt<'_>, (): ()) -> Arc<OutputFilenames> {
595595
}
596596
}
597597
}
598-
599-
outputs.into()
600598
}
601599

602600
pub static DEFAULT_QUERY_PROVIDERS: LazyLock<Providers> = LazyLock::new(|| {
603601
let providers = &mut Providers::default();
604602
providers.analysis = analysis;
605603
providers.hir_crate = rustc_ast_lowering::lower_to_hir;
606-
providers.output_filenames = output_filenames;
604+
providers.write_dep_info = write_dep_info;
607605
providers.resolver_for_lowering = resolver_for_lowering;
608606
providers.early_lint_checks = early_lint_checks;
609607
proc_macro_decls::provide(providers);

compiler/rustc_interface/src/queries.rs

+2
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ impl<'tcx> Queries<'tcx> {
135135
sess.opts.cg.metadata.clone(),
136136
sess.cfg_version,
137137
);
138+
let outputs = util::build_output_filenames(sess, crate_name.to_string());
138139
let dep_graph = setup_dep_graph(sess, crate_name, stable_crate_id)?;
139140

140141
let cstore = FreezeLock::new(Box::new(CStore::new(
@@ -169,6 +170,7 @@ impl<'tcx> Queries<'tcx> {
169170
crate_name,
170171
)));
171172
feed.crate_for_resolver(tcx.arena.alloc(Steal::new((krate, pre_configured_attrs))));
173+
feed.output_filenames(Arc::new(outputs));
172174
});
173175
Ok(qcx)
174176
})

compiler/rustc_middle/src/query/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1916,6 +1916,11 @@ 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+
19191924
/// Do not call this query directly: invoke `normalize` instead.
19201925
query normalize_projection_ty(
19211926
goal: CanonicalProjectionGoal<'tcx>

0 commit comments

Comments
 (0)