Remove metadata_loader query
It is only used by CrateLoader. We can store the metadata loader in CStore instead which CrateLoader has access to.
This commit is contained in:
parent
980143b50c
commit
c6247387b4
@ -193,7 +193,10 @@ impl<'tcx> Queries<'tcx> {
|
||||
self.compiler.register_lints.as_deref(),
|
||||
&pre_configured_attrs,
|
||||
));
|
||||
let cstore = RwLock::new(Box::new(CStore::new(stable_crate_id)) as _);
|
||||
let cstore = RwLock::new(Box::new(CStore::new(
|
||||
self.codegen_backend().metadata_loader(),
|
||||
stable_crate_id,
|
||||
)) as _);
|
||||
let definitions = RwLock::new(Definitions::new(stable_crate_id));
|
||||
let source_span = AppendOnlyIndexVec::new();
|
||||
let _id = source_span.push(krate.spans.inner_span);
|
||||
@ -221,9 +224,6 @@ impl<'tcx> Queries<'tcx> {
|
||||
tcx.arena.alloc(rustc_expand::config::features(sess, &pre_configured_attrs)),
|
||||
);
|
||||
feed.crate_for_resolver(tcx.arena.alloc(Steal::new((krate, pre_configured_attrs))));
|
||||
feed.metadata_loader(
|
||||
tcx.arena.alloc(Steal::new(self.codegen_backend().metadata_loader())),
|
||||
);
|
||||
});
|
||||
Ok(qcx)
|
||||
})
|
||||
|
@ -15,8 +15,9 @@ use rustc_hir::definitions::Definitions;
|
||||
use rustc_index::IndexVec;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::config::{self, CrateType, ExternLocation};
|
||||
use rustc_session::cstore::ExternCrateSource;
|
||||
use rustc_session::cstore::{CrateDepKind, CrateSource, ExternCrate};
|
||||
use rustc_session::cstore::{
|
||||
CrateDepKind, CrateSource, ExternCrate, ExternCrateSource, MetadataLoaderDyn,
|
||||
};
|
||||
use rustc_session::lint;
|
||||
use rustc_session::output::validate_crate_name;
|
||||
use rustc_session::search_paths::PathKind;
|
||||
@ -33,6 +34,8 @@ use std::time::Duration;
|
||||
use std::{cmp, env, iter};
|
||||
|
||||
pub struct CStore {
|
||||
metadata_loader: Box<MetadataLoaderDyn>,
|
||||
|
||||
metas: IndexVec<CrateNum, Option<Box<CrateMetadata>>>,
|
||||
injected_panic_runtime: Option<CrateNum>,
|
||||
/// This crate needs an allocator and either provides it itself, or finds it in a dependency.
|
||||
@ -261,10 +264,14 @@ impl CStore {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(local_stable_crate_id: StableCrateId) -> CStore {
|
||||
pub fn new(
|
||||
metadata_loader: Box<MetadataLoaderDyn>,
|
||||
local_stable_crate_id: StableCrateId,
|
||||
) -> CStore {
|
||||
let mut stable_crate_ids = StableCrateIdMap::default();
|
||||
stable_crate_ids.insert(local_stable_crate_id, LOCAL_CRATE);
|
||||
CStore {
|
||||
metadata_loader,
|
||||
// We add an empty entry for LOCAL_CRATE (which maps to zero) in
|
||||
// order to make array indices in `metas` match with the
|
||||
// corresponding `CrateNum`. This first entry will always remain
|
||||
@ -538,10 +545,9 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
|
||||
(LoadResult::Previous(cnum), None)
|
||||
} else {
|
||||
info!("falling back to a load");
|
||||
let metadata_loader = self.tcx.metadata_loader(()).borrow();
|
||||
let mut locator = CrateLocator::new(
|
||||
self.sess,
|
||||
&**metadata_loader,
|
||||
&*self.cstore.metadata_loader,
|
||||
name,
|
||||
// The all loop is because `--crate-type=rlib --crate-type=rlib` is
|
||||
// legal and produces both inside this type.
|
||||
|
@ -40,7 +40,6 @@ macro_rules! arena_types {
|
||||
rustc_data_structures::sync::Lrc<rustc_ast::Crate>,
|
||||
)>,
|
||||
[] output_filenames: std::sync::Arc<rustc_session::config::OutputFilenames>,
|
||||
[] metadata_loader: rustc_data_structures::steal::Steal<Box<rustc_session::cstore::MetadataLoaderDyn>>,
|
||||
[] crate_for_resolver: rustc_data_structures::steal::Steal<(rustc_ast::Crate, rustc_ast::AttrVec)>,
|
||||
[] resolutions: rustc_middle::ty::ResolverGlobalCtxt,
|
||||
[decode] unsafety_check_result: rustc_middle::mir::UnsafetyCheckResult,
|
||||
|
@ -2096,12 +2096,6 @@ rustc_queries! {
|
||||
desc { "looking up enabled feature gates" }
|
||||
}
|
||||
|
||||
query metadata_loader((): ()) -> &'tcx Steal<Box<rustc_session::cstore::MetadataLoaderDyn>> {
|
||||
feedable
|
||||
no_hash
|
||||
desc { "raw operations for metadata file access" }
|
||||
}
|
||||
|
||||
query crate_for_resolver((): ()) -> &'tcx Steal<(rustc_ast::Crate, rustc_ast::AttrVec)> {
|
||||
feedable
|
||||
no_hash
|
||||
|
Loading…
x
Reference in New Issue
Block a user