Skip to content

Commit f0e5e22

Browse files
committed
Make is_private_dep a query.
1 parent ee94fbb commit f0e5e22

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
188188
crate_hash => { cdata.root.hash }
189189
crate_host_hash => { cdata.host_hash }
190190
crate_name => { cdata.root.name }
191+
is_private_dep => { cdata.private_dep }
191192

192193
extra_filename => { cdata.root.extra_filename.clone() }
193194

@@ -476,10 +477,6 @@ impl CrateStore for CStore {
476477
self.get_crate_data(cnum).root.name
477478
}
478479

479-
fn crate_is_private_dep_untracked(&self, cnum: CrateNum) -> bool {
480-
self.get_crate_data(cnum).private_dep
481-
}
482-
483480
fn stable_crate_id_untracked(&self, cnum: CrateNum) -> StableCrateId {
484481
self.get_crate_data(cnum).root.stable_crate_id
485482
}

compiler/rustc_middle/src/middle/cstore.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ pub trait CrateStore: std::fmt::Debug {
199199

200200
// "queries" used in resolve that aren't tracked for incremental compilation
201201
fn crate_name_untracked(&self, cnum: CrateNum) -> Symbol;
202-
fn crate_is_private_dep_untracked(&self, cnum: CrateNum) -> bool;
203202
fn stable_crate_id_untracked(&self, cnum: CrateNum) -> StableCrateId;
204203
fn crate_hash_untracked(&self, cnum: CrateNum) -> Svh;
205204

compiler/rustc_middle/src/query/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,6 +1412,11 @@ rustc_queries! {
14121412
eval_always
14131413
desc { "generating a postorder list of CrateNums" }
14141414
}
1415+
/// Returns whether or not the crate with CrateNum 'cnum'
1416+
/// is marked as a private dependency
1417+
query is_private_dep(c: CrateNum) -> bool {
1418+
desc { "check whether crate {} is a private dependency", c }
1419+
}
14151420
query allocator_kind(_: ()) -> Option<AllocatorKind> {
14161421
desc { "allocator kind for the current crate" }
14171422
}

compiler/rustc_middle/src/ty/context.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,16 +1233,6 @@ impl<'tcx> TyCtxt<'tcx> {
12331233
}
12341234
}
12351235

1236-
/// Returns whether or not the crate with CrateNum 'cnum'
1237-
/// is marked as a private dependency
1238-
pub fn is_private_dep(self, cnum: CrateNum) -> bool {
1239-
if cnum == LOCAL_CRATE {
1240-
false
1241-
} else {
1242-
self.untracked_resolutions.cstore.crate_is_private_dep_untracked(cnum)
1243-
}
1244-
}
1245-
12461236
#[inline]
12471237
pub fn def_path_hash(self, def_id: DefId) -> rustc_hir::definitions::DefPathHash {
12481238
// Accessing the definitions is ok, since all its contents are tracked by the query system.
@@ -2812,5 +2802,9 @@ pub fn provide(providers: &mut ty::query::Providers) {
28122802
// We want to check if the panic handler was defined in this crate
28132803
tcx.lang_items().panic_impl().map_or(false, |did| did.is_local())
28142804
};
2805+
providers.is_private_dep = |_tcx, cnum| {
2806+
assert_eq!(cnum, LOCAL_CRATE);
2807+
false
2808+
};
28152809
providers.allocator_kind = |tcx, ()| tcx.resolutions(()).cstore.allocator_kind();
28162810
}

0 commit comments

Comments
 (0)