Skip to content

Commit 3c53005

Browse files
committed
Auto merge of #85178 - cjgillot:local-crate, r=oli-obk
Remove CrateNum parameter for queries that only work on local crate The pervasive `CrateNum` parameter is a remnant of the multi-crate rustc idea. Using `()` as query key in those cases avoids having to worry about the validity of the query key.
2 parents a5da29c + 915d766 commit 3c53005

File tree

5 files changed

+10
-11
lines changed

5 files changed

+10
-11
lines changed

src/allocator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub(crate) fn codegen(
1313
module: &mut impl Module,
1414
unwind_context: &mut UnwindContext,
1515
) -> bool {
16-
let any_dynamic_crate = tcx.dependency_formats(LOCAL_CRATE).iter().any(|(_, list)| {
16+
let any_dynamic_crate = tcx.dependency_formats(()).iter().any(|(_, list)| {
1717
use rustc_middle::middle::dependency_format::Linkage;
1818
list.iter().any(|&linkage| linkage == Linkage::Dynamic)
1919
});

src/driver/aot.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn emit_module(
4242

4343
unwind_context.emit(&mut product);
4444

45-
let tmp_file = tcx.output_filenames(LOCAL_CRATE).temp_path(OutputType::Object, Some(&name));
45+
let tmp_file = tcx.output_filenames(()).temp_path(OutputType::Object, Some(&name));
4646
let obj = product.object.write().unwrap();
4747
if let Err(err) = std::fs::write(&tmp_file, obj) {
4848
tcx.sess.fatal(&format!("error writing object file: {}", err));
@@ -74,7 +74,7 @@ fn reuse_workproduct_for_cgu(
7474
let work_product = cgu.work_product(tcx);
7575
if let Some(saved_file) = &work_product.saved_file {
7676
let obj_out = tcx
77-
.output_filenames(LOCAL_CRATE)
77+
.output_filenames(())
7878
.temp_path(OutputType::Object, Some(&cgu.name().as_str()));
7979
object = Some(obj_out.clone());
8080
let source_file = rustc_incremental::in_incr_comp_dir(&incr_comp_session_dir, &saved_file);
@@ -190,7 +190,7 @@ pub(crate) fn run_aot(
190190
let mut work_products = FxHashMap::default();
191191

192192
let cgus = if tcx.sess.opts.output_types.should_codegen() {
193-
tcx.collect_and_partition_mono_items(LOCAL_CRATE).1
193+
tcx.collect_and_partition_mono_items(()).1
194194
} else {
195195
// If only `--emit metadata` is used, we shouldn't perform any codegen.
196196
// Also `tcx.collect_and_partition_mono_items` may panic in that case.
@@ -276,7 +276,7 @@ pub(crate) fn run_aot(
276276
.to_string();
277277

278278
let tmp_file = tcx
279-
.output_filenames(LOCAL_CRATE)
279+
.output_filenames(())
280280
.temp_path(OutputType::Metadata, Some(&metadata_cgu_name));
281281

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

355355
let output_object_file =
356-
tcx.output_filenames(LOCAL_CRATE).temp_path(OutputType::Object, Some(cgu_name));
356+
tcx.output_filenames(()).temp_path(OutputType::Object, Some(cgu_name));
357357

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

src/driver/jit.rs

+2-3
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())
@@ -179,7 +178,7 @@ fn load_imported_symbols_for_jit(tcx: TyCtxt<'_>) -> Vec<(String, *const u8)> {
179178
let mut dylib_paths = Vec::new();
180179

181180
let crate_info = CrateInfo::new(tcx);
182-
let formats = tcx.dependency_formats(LOCAL_CRATE);
181+
let formats = tcx.dependency_formats(());
183182
let data = &formats
184183
.iter()
185184
.find(|(crate_type, _data)| *crate_type == rustc_session::config::CrateType::Executable)

src/main_shim.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub(crate) fn maybe_create_entry_wrapper(
1515
unwind_context: &mut UnwindContext,
1616
is_jit: bool,
1717
) {
18-
let (main_def_id, is_main_fn) = match tcx.entry_fn(LOCAL_CRATE) {
18+
let (main_def_id, is_main_fn) = match tcx.entry_fn(()) {
1919
Some((def_id, entry_ty)) => (
2020
def_id,
2121
match entry_ty {

src/pretty_clif.rs

+1-1
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(()) => {}

0 commit comments

Comments
 (0)