Skip to content

Commit 0bde3b1

Browse files
committed
Use () for codegen queries.
1 parent 4e8d4bd commit 0bde3b1

File tree

15 files changed

+40
-56
lines changed

15 files changed

+40
-56
lines changed

compiler/rustc_codegen_cranelift/src/driver/aot.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fn emit_module(
4141

4242
unwind_context.emit(&mut product);
4343

44-
let tmp_file = tcx.output_filenames(LOCAL_CRATE).temp_path(OutputType::Object, Some(&name));
44+
let tmp_file = tcx.output_filenames(()).temp_path(OutputType::Object, Some(&name));
4545
let obj = product.object.write().unwrap();
4646
if let Err(err) = std::fs::write(&tmp_file, obj) {
4747
tcx.sess.fatal(&format!("error writing object file: {}", err));
@@ -73,7 +73,7 @@ fn reuse_workproduct_for_cgu(
7373
let work_product = cgu.work_product(tcx);
7474
if let Some(saved_file) = &work_product.saved_file {
7575
let obj_out = tcx
76-
.output_filenames(LOCAL_CRATE)
76+
.output_filenames(())
7777
.temp_path(OutputType::Object, Some(&cgu.name().as_str()));
7878
object = Some(obj_out.clone());
7979
let source_file = rustc_incremental::in_incr_comp_dir(&incr_comp_session_dir, &saved_file);
@@ -179,7 +179,7 @@ pub(crate) fn run_aot(
179179
let mut work_products = FxHashMap::default();
180180

181181
let cgus = if tcx.sess.opts.output_types.should_codegen() {
182-
tcx.collect_and_partition_mono_items(LOCAL_CRATE).1
182+
tcx.collect_and_partition_mono_items(()).1
183183
} else {
184184
// If only `--emit metadata` is used, we shouldn't perform any codegen.
185185
// Also `tcx.collect_and_partition_mono_items` may panic in that case.
@@ -265,7 +265,7 @@ pub(crate) fn run_aot(
265265
.to_string();
266266

267267
let tmp_file = tcx
268-
.output_filenames(LOCAL_CRATE)
268+
.output_filenames(())
269269
.temp_path(OutputType::Metadata, Some(&metadata_cgu_name));
270270

271271
let obj = crate::backend::with_object(tcx.sess, &metadata_cgu_name, |object| {
@@ -342,7 +342,7 @@ fn codegen_global_asm(tcx: TyCtxt<'_>, cgu_name: &str, global_asm: &str) {
342342
.join("\n");
343343

344344
let output_object_file =
345-
tcx.output_filenames(LOCAL_CRATE).temp_path(OutputType::Object, Some(cgu_name));
345+
tcx.output_filenames(()).temp_path(OutputType::Object, Some(cgu_name));
346346

347347
// Assemble `global_asm`
348348
let global_asm_object_file = add_file_stem_postfix(output_object_file.clone(), ".asm");

compiler/rustc_codegen_cranelift/src/driver/jit.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use std::os::raw::{c_char, c_int};
88
use cranelift_codegen::binemit::{NullStackMapSink, NullTrapSink};
99
use rustc_codegen_ssa::CrateInfo;
1010
use rustc_middle::mir::mono::MonoItem;
11-
use rustc_session::config::EntryFnType;
1211

1312
use cranelift_jit::{JITBuilder, JITModule};
1413

@@ -66,7 +65,7 @@ pub(crate) fn run_jit(tcx: TyCtxt<'_>, backend_config: BackendConfig) -> ! {
6665
matches!(backend_config.codegen_mode, CodegenMode::JitLazy),
6766
);
6867

69-
let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE);
68+
let (_, cgus) = tcx.collect_and_partition_mono_items(());
7069
let mono_items = cgus
7170
.iter()
7271
.map(|cgu| cgu.items_in_deterministic_order(tcx).into_iter())

compiler/rustc_codegen_cranelift/src/pretty_clif.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ pub(crate) fn write_ir_file(
214214
return;
215215
}
216216

217-
let clif_output_dir = tcx.output_filenames(LOCAL_CRATE).with_extension("clif");
217+
let clif_output_dir = tcx.output_filenames(()).with_extension("clif");
218218

219219
match std::fs::create_dir(&clif_output_dir) {
220220
Ok(()) => {}

compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use rustc_codegen_ssa::{CompiledModule, ModuleCodegen};
2020
use rustc_data_structures::small_c_str::SmallCStr;
2121
use rustc_errors::{FatalError, Handler, Level};
2222
use rustc_fs_util::{link_or_copy, path_to_c_string};
23-
use rustc_hir::def_id::LOCAL_CRATE;
2423
use rustc_middle::bug;
2524
use rustc_middle::ty::TyCtxt;
2625
use rustc_session::config::{self, Lto, OutputType, Passes, SwitchWithOptPath};
@@ -92,13 +91,12 @@ pub fn create_informational_target_machine(sess: &Session) -> &'static mut llvm:
9291

9392
pub fn create_target_machine(tcx: TyCtxt<'_>, mod_name: &str) -> &'static mut llvm::TargetMachine {
9493
let split_dwarf_file = if tcx.sess.target_can_use_split_dwarf() {
95-
tcx.output_filenames(LOCAL_CRATE)
96-
.split_dwarf_path(tcx.sess.split_debuginfo(), Some(mod_name))
94+
tcx.output_filenames(()).split_dwarf_path(tcx.sess.split_debuginfo(), Some(mod_name))
9795
} else {
9896
None
9997
};
10098
let config = TargetMachineFactoryConfig { split_dwarf_file };
101-
target_machine_factory(&tcx.sess, tcx.backend_optimization_level(LOCAL_CRATE))(config)
99+
target_machine_factory(&tcx.sess, tcx.backend_optimization_level(()))(config)
102100
.unwrap_or_else(|err| llvm_err(tcx.sess.diagnostic(), &err).raise())
103101
}
104102

compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use llvm::coverageinfo::CounterMappingRegion;
66
use rustc_codegen_ssa::coverageinfo::map::{Counter, CounterExpression};
77
use rustc_codegen_ssa::traits::{ConstMethods, CoverageInfoMethods};
88
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
9-
use rustc_hir::def_id::{DefId, DefIdSet, LOCAL_CRATE};
9+
use rustc_hir::def_id::{DefId, DefIdSet};
1010
use rustc_llvm::RustString;
1111
use rustc_middle::mir::coverage::CodeRegion;
1212
use rustc_span::Symbol;
@@ -276,7 +276,7 @@ fn add_unused_functions<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>) {
276276
})
277277
.collect();
278278

279-
let codegenned_def_ids = tcx.codegened_and_inlined_items(LOCAL_CRATE);
279+
let codegenned_def_ids = tcx.codegened_and_inlined_items(());
280280

281281
let mut unused_def_ids_by_file: FxHashMap<Symbol, Vec<DefId>> = FxHashMap::default();
282282
for &non_codegenned_def_id in all_def_ids.difference(codegenned_def_ids) {

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -995,9 +995,10 @@ pub fn compile_unit_metadata(
995995
let name_in_debuginfo = name_in_debuginfo.to_string_lossy();
996996
let work_dir = tcx.sess.working_dir.0.to_string_lossy();
997997
let flags = "\0";
998-
let out_dir = &tcx.output_filenames(LOCAL_CRATE).out_directory;
998+
let output_filenames = tcx.output_filenames(());
999+
let out_dir = &output_filenames.out_directory;
9991000
let split_name = if tcx.sess.target_can_use_split_dwarf() {
1000-
tcx.output_filenames(LOCAL_CRATE)
1001+
output_filenames
10011002
.split_dwarf_path(tcx.sess.split_debuginfo(), Some(codegen_unit_name))
10021003
.map(|f| out_dir.join(f))
10031004
} else {
@@ -1058,15 +1059,12 @@ pub fn compile_unit_metadata(
10581059
if tcx.sess.opts.debugging_opts.profile {
10591060
let cu_desc_metadata =
10601061
llvm::LLVMRustMetadataAsValue(debug_context.llcontext, unit_metadata);
1061-
let default_gcda_path = &tcx.output_filenames(LOCAL_CRATE).with_extension("gcda");
1062+
let default_gcda_path = &output_filenames.with_extension("gcda");
10621063
let gcda_path =
10631064
tcx.sess.opts.debugging_opts.profile_emit.as_ref().unwrap_or(default_gcda_path);
10641065

10651066
let gcov_cu_info = [
1066-
path_to_mdstring(
1067-
debug_context.llcontext,
1068-
&tcx.output_filenames(LOCAL_CRATE).with_extension("gcno"),
1069-
),
1067+
path_to_mdstring(debug_context.llcontext, &output_filenames.with_extension("gcno")),
10701068
path_to_mdstring(debug_context.llcontext, &gcda_path),
10711069
cu_desc_metadata,
10721070
];

compiler/rustc_codegen_ssa/src/back/symbol_export.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ fn exported_symbols_provider_local(
230230
// external linkage is enough for monomorphization to be linked to.
231231
let need_visibility = tcx.sess.target.dynamic_linking && !tcx.sess.target.only_cdylib;
232232

233-
let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE);
233+
let (_, cgus) = tcx.collect_and_partition_mono_items(());
234234

235235
for (mono_item, &(linkage, visibility)) in cgus.iter().flat_map(|cgu| cgu.items().iter()) {
236236
if linkage != Linkage::External {
@@ -275,10 +275,8 @@ fn exported_symbols_provider_local(
275275

276276
fn upstream_monomorphizations_provider(
277277
tcx: TyCtxt<'_>,
278-
cnum: CrateNum,
278+
(): (),
279279
) -> DefIdMap<FxHashMap<SubstsRef<'_>, CrateNum>> {
280-
debug_assert!(cnum == LOCAL_CRATE);
281-
282280
let cnums = tcx.all_crate_nums(());
283281

284282
let mut instances: DefIdMap<FxHashMap<_, _>> = Default::default();
@@ -341,7 +339,7 @@ fn upstream_monomorphizations_for_provider(
341339
def_id: DefId,
342340
) -> Option<&FxHashMap<SubstsRef<'_>, CrateNum>> {
343341
debug_assert!(!def_id.is_local());
344-
tcx.upstream_monomorphizations(LOCAL_CRATE).get(&def_id)
342+
tcx.upstream_monomorphizations(()).get(&def_id)
345343
}
346344

347345
fn upstream_drop_glue_for_provider<'tcx>(

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
482482
codegen_worker_receive,
483483
shared_emitter_main,
484484
future: coordinator_thread,
485-
output_filenames: tcx.output_filenames(LOCAL_CRATE),
485+
output_filenames: tcx.output_filenames(()),
486486
}
487487
}
488488

@@ -1042,7 +1042,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
10421042
// If we know that we won’t be doing codegen, create target machines without optimisation.
10431043
config::OptLevel::No
10441044
} else {
1045-
tcx.backend_optimization_level(LOCAL_CRATE)
1045+
tcx.backend_optimization_level(())
10461046
};
10471047
let cgcx = CodegenContext::<B> {
10481048
backend: backend.clone(),
@@ -1061,7 +1061,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
10611061
cgu_reuse_tracker: sess.cgu_reuse_tracker.clone(),
10621062
coordinator_send,
10631063
diag_emitter: shared_emitter.clone(),
1064-
output_filenames: tcx.output_filenames(LOCAL_CRATE),
1064+
output_filenames: tcx.output_filenames(()),
10651065
regular_module_config: regular_config,
10661066
metadata_module_config: metadata_config,
10671067
allocator_module_config: allocator_config,

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
485485

486486
// Run the monomorphization collector and partition the collected items into
487487
// codegen units.
488-
let codegen_units = tcx.collect_and_partition_mono_items(LOCAL_CRATE).1;
488+
let codegen_units = tcx.collect_and_partition_mono_items(()).1;
489489

490490
// Force all codegen_unit queries so they are already either red or green
491491
// when compile_codegen_unit accesses them. We are not able to re-execute

compiler/rustc_incremental/src/assert_module_sources.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub fn assert_module_sources(tcx: TyCtxt<'_>) {
3636
}
3737

3838
let available_cgus = tcx
39-
.collect_and_partition_mono_items(LOCAL_CRATE)
39+
.collect_and_partition_mono_items(())
4040
.1
4141
.iter()
4242
.map(|cgu| cgu.name().to_string())

0 commit comments

Comments
 (0)