Skip to content

Commit cfa42df

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 9b47a43 commit cfa42df

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
@@ -408,9 +408,9 @@ fn run_compiler(
408408
Ok(())
409409
})?;
410410

411-
// Make sure the `output_filenames` query is run for its side
411+
// Make sure the `write_dep_info` query is run for its side
412412
// effects of writing the dep-info and reporting errors.
413-
queries.global_ctxt()?.enter(|tcx| tcx.output_filenames(()));
413+
queries.global_ctxt()?.enter(|tcx| tcx.write_dep_info(()));
414414
} else {
415415
let krate = queries.parse()?;
416416
pretty::print(
@@ -443,9 +443,9 @@ fn run_compiler(
443443
return early_exit();
444444
}
445445

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

450450
if sess.opts.output_types.contains_key(&OutputType::DepInfo)
451451
&& 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
@@ -136,6 +136,7 @@ impl<'tcx> Queries<'tcx> {
136136
sess.opts.cg.metadata.clone(),
137137
sess.cfg_version,
138138
);
139+
let outputs = util::build_output_filenames(sess, crate_name.to_string());
139140
let dep_graph = setup_dep_graph(sess, crate_name, stable_crate_id)?;
140141

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

compiler/rustc_middle/src/query/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1910,6 +1910,11 @@ rustc_queries! {
19101910
arena_cache
19111911
}
19121912

1913+
/// Write the dep-info file.
1914+
query write_dep_info(_: ()) -> () {
1915+
desc { "writing the dep-info file" }
1916+
}
1917+
19131918
/// Do not call this query directly: invoke `normalize` instead.
19141919
query normalize_projection_ty(
19151920
goal: CanonicalProjectionGoal<'tcx>

0 commit comments

Comments
 (0)