Skip to content

Commit 7100b31

Browse files
committed
Auto merge of #86749 - bjorn3:link_info_refactor_part1, r=petrochenkov
Rename all_crate_nums query to crates and remove useless wrapper Split out of #86105 r? `@petrochenkov`
2 parents ecef52a + c7d2099 commit 7100b31

File tree

21 files changed

+27
-31
lines changed

21 files changed

+27
-31
lines changed

compiler/rustc_codegen_ssa/src/back/symbol_export.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ fn upstream_monomorphizations_provider(
277277
tcx: TyCtxt<'_>,
278278
(): (),
279279
) -> DefIdMap<FxHashMap<SubstsRef<'_>, CrateNum>> {
280-
let cnums = tcx.all_crate_nums(());
280+
let cnums = tcx.crates(());
281281

282282
let mut instances: DefIdMap<FxHashMap<_, _>> = Default::default();
283283

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
994994
}
995995
Lto::Fat | Lto::Thin => {
996996
exported_symbols.insert(LOCAL_CRATE, copy_symbols(LOCAL_CRATE));
997-
for &cnum in tcx.crates().iter() {
997+
for &cnum in tcx.crates(()).iter() {
998998
exported_symbols.insert(cnum, copy_symbols(cnum));
999999
}
10001000
Some(Arc::new(exported_symbols))

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ impl CrateInfo {
789789
};
790790
let lang_items = tcx.lang_items();
791791

792-
let crates = tcx.crates();
792+
let crates = tcx.crates(());
793793

794794
let n_crates = crates.len();
795795
info.native_libraries.reserve(n_crates);

compiler/rustc_metadata/src/dependency_format.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
129129
&& sess.crt_static(Some(ty))
130130
&& !sess.target.crt_static_allows_dylibs)
131131
{
132-
for &cnum in tcx.crates().iter() {
132+
for &cnum in tcx.crates(()).iter() {
133133
if tcx.dep_kind(cnum).macros_only() {
134134
continue;
135135
}
@@ -152,7 +152,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
152152
// Sweep all crates for found dylibs. Add all dylibs, as well as their
153153
// dependencies, ensuring there are no conflicts. The only valid case for a
154154
// dependency to be relied upon twice is for both cases to rely on a dylib.
155-
for &cnum in tcx.crates().iter() {
155+
for &cnum in tcx.crates(()).iter() {
156156
if tcx.dep_kind(cnum).macros_only() {
157157
continue;
158158
}
@@ -170,7 +170,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
170170
}
171171

172172
// Collect what we've got so far in the return vector.
173-
let last_crate = tcx.crates().len();
173+
let last_crate = tcx.crates(()).len();
174174
let mut ret = (1..last_crate + 1)
175175
.map(|cnum| match formats.get(&CrateNum::new(cnum)) {
176176
Some(&RequireDynamic) => Linkage::Dynamic,
@@ -184,7 +184,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
184184
//
185185
// If the crate hasn't been included yet and it's not actually required
186186
// (e.g., it's an allocator) then we skip it here as well.
187-
for &cnum in tcx.crates().iter() {
187+
for &cnum in tcx.crates(()).iter() {
188188
let src = tcx.used_crate_source(cnum);
189189
if src.dylib.is_none()
190190
&& !formats.contains_key(&cnum)
@@ -281,7 +281,7 @@ fn attempt_static(tcx: TyCtxt<'_>) -> Option<DependencyList> {
281281

282282
// All crates are available in an rlib format, so we're just going to link
283283
// everything in explicitly so long as it's actually required.
284-
let last_crate = tcx.crates().len();
284+
let last_crate = tcx.crates(()).len();
285285
let mut ret = (1..last_crate + 1)
286286
.map(|cnum| {
287287
if tcx.dep_kind(CrateNum::new(cnum)) == CrateDepKind::Explicit {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ pub fn provide(providers: &mut Providers) {
312312
// which is to say, its not deterministic in general. But
313313
// we believe that libstd is consistently assigned crate
314314
// num 1, so it should be enough to resolve #46112.
315-
let mut crates: Vec<CrateNum> = (*tcx.crates()).to_owned();
315+
let mut crates: Vec<CrateNum> = (*tcx.crates(())).to_owned();
316316
crates.sort();
317317

318318
for &cnum in crates.iter() {

compiler/rustc_metadata/src/rmeta/encoder.rs

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

16741674
fn encode_crate_deps(&mut self) -> Lazy<[CrateDep]> {
16751675
empty_proc_macro!(self);
1676-
let crates = self.tcx.crates();
1676+
let crates = self.tcx.crates(());
16771677

16781678
let mut deps = crates
16791679
.iter()

compiler/rustc_middle/src/middle/cstore.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ pub type CrateStoreDyn = dyn CrateStore + sync::Sync;
229229
// positions.
230230
pub fn used_crates(tcx: TyCtxt<'_>, prefer: LinkagePreference) -> Vec<(CrateNum, LibSource)> {
231231
let mut libs = tcx
232-
.crates()
232+
.crates(())
233233
.iter()
234234
.cloned()
235235
.filter_map(|cnum| {

compiler/rustc_middle/src/query/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1444,7 +1444,7 @@ rustc_queries! {
14441444
eval_always
14451445
desc { "calculating the stability index for the local crate" }
14461446
}
1447-
query all_crate_nums(_: ()) -> &'tcx [CrateNum] {
1447+
query crates(_: ()) -> &'tcx [CrateNum] {
14481448
eval_always
14491449
desc { "fetching all foreign CrateNum instances" }
14501450
}

compiler/rustc_middle/src/ty/context.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,10 +1267,6 @@ impl<'tcx> TyCtxt<'tcx> {
12671267
self.stability_index(())
12681268
}
12691269

1270-
pub fn crates(self) -> &'tcx [CrateNum] {
1271-
self.all_crate_nums(())
1272-
}
1273-
12741270
pub fn features(self) -> &'tcx rustc_feature::Features {
12751271
self.features_query(())
12761272
}
@@ -2827,7 +2823,7 @@ pub fn provide(providers: &mut ty::query::Providers) {
28272823
tcx.stability().local_deprecation_entry(id)
28282824
};
28292825
providers.extern_mod_stmt_cnum = |tcx, id| tcx.extern_crate_map.get(&id).cloned();
2830-
providers.all_crate_nums = |tcx, ()| tcx.arena.alloc_slice(&tcx.cstore.crates_untracked());
2826+
providers.crates = |tcx, ()| tcx.arena.alloc_slice(&tcx.cstore.crates_untracked());
28312827
providers.output_filenames = |tcx, ()| tcx.output_filenames.clone();
28322828
providers.features_query = |tcx, ()| tcx.sess.features_untracked();
28332829
providers.is_panic_runtime = |tcx, cnum| {

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2248,7 +2248,7 @@ fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, N
22482248
let queue = &mut Vec::new();
22492249
let mut seen_defs: DefIdSet = Default::default();
22502250

2251-
for &cnum in tcx.crates().iter() {
2251+
for &cnum in tcx.crates(()).iter() {
22522252
let def_id = DefId { krate: cnum, index: CRATE_DEF_INDEX };
22532253

22542254
// Ignore crates that are not direct dependencies.

0 commit comments

Comments
 (0)