1
Fork 0

Make is_private_dep a query.

This commit is contained in:
Camille GILLOT 2021-05-11 22:06:07 +02:00
parent ee94fbb607
commit f0e5e22806
4 changed files with 10 additions and 15 deletions

View file

@ -188,6 +188,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
crate_hash => { cdata.root.hash } crate_hash => { cdata.root.hash }
crate_host_hash => { cdata.host_hash } crate_host_hash => { cdata.host_hash }
crate_name => { cdata.root.name } crate_name => { cdata.root.name }
is_private_dep => { cdata.private_dep }
extra_filename => { cdata.root.extra_filename.clone() } extra_filename => { cdata.root.extra_filename.clone() }
@ -476,10 +477,6 @@ impl CrateStore for CStore {
self.get_crate_data(cnum).root.name self.get_crate_data(cnum).root.name
} }
fn crate_is_private_dep_untracked(&self, cnum: CrateNum) -> bool {
self.get_crate_data(cnum).private_dep
}
fn stable_crate_id_untracked(&self, cnum: CrateNum) -> StableCrateId { fn stable_crate_id_untracked(&self, cnum: CrateNum) -> StableCrateId {
self.get_crate_data(cnum).root.stable_crate_id self.get_crate_data(cnum).root.stable_crate_id
} }

View file

@ -199,7 +199,6 @@ pub trait CrateStore: std::fmt::Debug {
// "queries" used in resolve that aren't tracked for incremental compilation // "queries" used in resolve that aren't tracked for incremental compilation
fn crate_name_untracked(&self, cnum: CrateNum) -> Symbol; fn crate_name_untracked(&self, cnum: CrateNum) -> Symbol;
fn crate_is_private_dep_untracked(&self, cnum: CrateNum) -> bool;
fn stable_crate_id_untracked(&self, cnum: CrateNum) -> StableCrateId; fn stable_crate_id_untracked(&self, cnum: CrateNum) -> StableCrateId;
fn crate_hash_untracked(&self, cnum: CrateNum) -> Svh; fn crate_hash_untracked(&self, cnum: CrateNum) -> Svh;

View file

@ -1412,6 +1412,11 @@ rustc_queries! {
eval_always eval_always
desc { "generating a postorder list of CrateNums" } desc { "generating a postorder list of CrateNums" }
} }
/// Returns whether or not the crate with CrateNum 'cnum'
/// is marked as a private dependency
query is_private_dep(c: CrateNum) -> bool {
desc { "check whether crate {} is a private dependency", c }
}
query allocator_kind(_: ()) -> Option<AllocatorKind> { query allocator_kind(_: ()) -> Option<AllocatorKind> {
desc { "allocator kind for the current crate" } desc { "allocator kind for the current crate" }
} }

View file

@ -1233,16 +1233,6 @@ impl<'tcx> TyCtxt<'tcx> {
} }
} }
/// Returns whether or not the crate with CrateNum 'cnum'
/// is marked as a private dependency
pub fn is_private_dep(self, cnum: CrateNum) -> bool {
if cnum == LOCAL_CRATE {
false
} else {
self.untracked_resolutions.cstore.crate_is_private_dep_untracked(cnum)
}
}
#[inline] #[inline]
pub fn def_path_hash(self, def_id: DefId) -> rustc_hir::definitions::DefPathHash { pub fn def_path_hash(self, def_id: DefId) -> rustc_hir::definitions::DefPathHash {
// Accessing the definitions is ok, since all its contents are tracked by the query system. // 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) {
// We want to check if the panic handler was defined in this crate // We want to check if the panic handler was defined in this crate
tcx.lang_items().panic_impl().map_or(false, |did| did.is_local()) tcx.lang_items().panic_impl().map_or(false, |did| did.is_local())
}; };
providers.is_private_dep = |_tcx, cnum| {
assert_eq!(cnum, LOCAL_CRATE);
false
};
providers.allocator_kind = |tcx, ()| tcx.resolutions(()).cstore.allocator_kind(); providers.allocator_kind = |tcx, ()| tcx.resolutions(()).cstore.allocator_kind();
} }