Skip to content

Commit b0505d0

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 911ec3b commit b0505d0

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
@@ -417,9 +417,9 @@ fn run_compiler(
417417
Ok(())
418418
})?;
419419

420-
// Make sure the `output_filenames` query is run for its side
420+
// Make sure the `write_dep_info` query is run for its side
421421
// effects of writing the dep-info and reporting errors.
422-
queries.global_ctxt()?.enter(|tcx| tcx.output_filenames(()));
422+
queries.global_ctxt()?.enter(|tcx| tcx.write_dep_info(()));
423423
} else {
424424
let krate = queries.parse()?.steal();
425425
pretty::print(sess, *ppm, pretty::PrintExtra::AfterParsing { krate });
@@ -450,9 +450,9 @@ fn run_compiler(
450450
return early_exit();
451451
}
452452

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

457457
if sess.opts.output_types.contains_key(&OutputType::DepInfo)
458458
&& 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> {
@@ -564,12 +564,12 @@ fn resolver_for_lowering<'tcx>(
564564
tcx.arena.alloc(Steal::new((untracked_resolver_for_lowering, Lrc::new(krate))))
565565
}
566566

567-
fn output_filenames(tcx: TyCtxt<'_>, (): ()) -> Arc<OutputFilenames> {
567+
fn write_dep_info(tcx: TyCtxt<'_>, (): ()) {
568568
let sess = tcx.sess;
569-
let _timer = sess.timer("prepare_outputs");
569+
let _timer = sess.timer("write_dep_info");
570570
let crate_name = tcx.crate_name(LOCAL_CRATE);
571571

572-
let outputs = util::build_output_filenames(sess, crate_name.to_string());
572+
let outputs = tcx.output_filenames(());
573573
let output_paths =
574574
generated_output_paths(tcx, &outputs, sess.io.output_file.is_some(), crate_name);
575575

@@ -606,15 +606,13 @@ fn output_filenames(tcx: TyCtxt<'_>, (): ()) -> Arc<OutputFilenames> {
606606
}
607607
}
608608
}
609-
610-
outputs.into()
611609
}
612610

613611
pub static DEFAULT_QUERY_PROVIDERS: LazyLock<Providers> = LazyLock::new(|| {
614612
let providers = &mut Providers::default();
615613
providers.analysis = analysis;
616614
providers.hir_crate = rustc_ast_lowering::lower_to_hir;
617-
providers.output_filenames = output_filenames;
615+
providers.write_dep_info = write_dep_info;
618616
providers.resolver_for_lowering = resolver_for_lowering;
619617
providers.early_lint_checks = early_lint_checks;
620618
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 lint_store =
@@ -172,6 +173,7 @@ impl<'tcx> Queries<'tcx> {
172173
crate_name,
173174
)));
174175
feed.crate_for_resolver(tcx.arena.alloc(Steal::new((krate, pre_configured_attrs))));
176+
feed.output_filenames(Arc::new(outputs));
175177
});
176178
Ok(qcx)
177179
})

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)