Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 85a14d7

Browse files
committed
Use () in dependency_formats.
1 parent ac923d9 commit 85a14d7

File tree

8 files changed

+18
-13
lines changed

8 files changed

+18
-13
lines changed

compiler/rustc_codegen_cranelift/src/allocator.rs

Lines changed: 1 addition & 1 deletion
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
});

compiler/rustc_codegen_cranelift/src/driver/jit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ fn load_imported_symbols_for_jit(tcx: TyCtxt<'_>) -> Vec<(String, *const u8)> {
179179
let mut dylib_paths = Vec::new();
180180

181181
let crate_info = CrateInfo::new(tcx);
182-
let formats = tcx.dependency_formats(LOCAL_CRATE);
182+
let formats = tcx.dependency_formats(());
183183
let data = &formats
184184
.iter()
185185
.find(|(crate_type, _data)| *crate_type == rustc_session::config::CrateType::Executable)

compiler/rustc_codegen_ssa/src/back/linker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,7 @@ fn exported_symbols(tcx: TyCtxt<'_>, crate_type: CrateType) -> Vec<String> {
13031303
}
13041304
}
13051305

1306-
let formats = tcx.dependency_formats(LOCAL_CRATE);
1306+
let formats = tcx.dependency_formats(());
13071307
let deps = formats.iter().find_map(|(t, list)| (*t == crate_type).then_some(list)).unwrap();
13081308

13091309
for (index, dep_format) in deps.iter().enumerate() {

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
511511
// linkage, then it's already got an allocator shim and we'll be using that
512512
// one instead. If nothing exists then it's our job to generate the
513513
// allocator!
514-
let any_dynamic_crate = tcx.dependency_formats(LOCAL_CRATE).iter().any(|(_, list)| {
514+
let any_dynamic_crate = tcx.dependency_formats(()).iter().any(|(_, list)| {
515515
use rustc_middle::middle::dependency_format::Linkage;
516516
list.iter().any(|&linkage| linkage == Linkage::Dynamic)
517517
});
@@ -768,7 +768,7 @@ impl CrateInfo {
768768
used_crate_source: Default::default(),
769769
lang_item_to_crate: Default::default(),
770770
missing_lang_items: Default::default(),
771-
dependency_formats: tcx.dependency_formats(LOCAL_CRATE),
771+
dependency_formats: tcx.dependency_formats(()),
772772
};
773773
let lang_items = tcx.lang_items();
774774

compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,7 @@ pub fn provide(providers: &mut Providers) {
370370
visible_parent_map
371371
},
372372

373-
dependency_formats: |tcx, cnum| {
374-
assert_eq!(cnum, LOCAL_CRATE);
375-
Lrc::new(crate::dependency_format::calculate(tcx))
376-
},
373+
dependency_formats: |tcx, ()| Lrc::new(crate::dependency_format::calculate(tcx)),
377374
has_global_allocator: |tcx, cnum| {
378375
assert_eq!(cnum, LOCAL_CRATE);
379376
CStore::from_tcx(tcx).has_global_allocator()

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1773,7 +1773,7 @@ impl EncodeContext<'a, 'tcx> {
17731773

17741774
fn encode_dylib_dependency_formats(&mut self) -> Lazy<[Option<LinkagePreference>]> {
17751775
empty_proc_macro!(self);
1776-
let formats = self.tcx.dependency_formats(LOCAL_CRATE);
1776+
let formats = self.tcx.dependency_formats(());
17771777
for (ty, arr) in formats.iter() {
17781778
if *ty != CrateType::Dylib {
17791779
continue;

compiler/rustc_middle/src/query/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,9 +1053,7 @@ rustc_queries! {
10531053
desc { "dylib dependency formats of crate" }
10541054
}
10551055

1056-
query dependency_formats(_: CrateNum)
1057-
-> Lrc<crate::middle::dependency_format::Dependencies>
1058-
{
1056+
query dependency_formats(_: ()) -> Lrc<crate::middle::dependency_format::Dependencies> {
10591057
desc { "get the linkage format of all dependencies" }
10601058
}
10611059

compiler/rustc_query_impl/src/keys.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ pub trait Key {
2121
fn default_span(&self, tcx: TyCtxt<'_>) -> Span;
2222
}
2323

24+
impl Key for () {
25+
fn query_crate(&self) -> CrateNum {
26+
LOCAL_CRATE
27+
}
28+
29+
fn default_span(&self, _: TyCtxt<'_>) -> Span {
30+
DUMMY_SP
31+
}
32+
}
33+
2434
impl<'tcx> Key for ty::InstanceDef<'tcx> {
2535
fn query_crate(&self) -> CrateNum {
2636
LOCAL_CRATE

0 commit comments

Comments
 (0)