summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_interface/src/queries.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_interface/src/queries.rs')
-rw-r--r--compiler/rustc_interface/src/queries.rs59
1 files changed, 10 insertions, 49 deletions
diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs
index fc71c6c7e..fe253febf 100644
--- a/compiler/rustc_interface/src/queries.rs
+++ b/compiler/rustc_interface/src/queries.rs
@@ -7,10 +7,10 @@ use rustc_codegen_ssa::traits::CodegenBackend;
use rustc_codegen_ssa::CodegenResults;
use rustc_data_structures::steal::Steal;
use rustc_data_structures::svh::Svh;
-use rustc_data_structures::sync::{AppendOnlyIndexVec, Lrc, OnceCell, RwLock, WorkerLocal};
+use rustc_data_structures::sync::{AppendOnlyIndexVec, FreezeLock, Lrc, OnceLock, WorkerLocal};
use rustc_hir::def_id::{StableCrateId, CRATE_DEF_ID, LOCAL_CRATE};
use rustc_hir::definitions::Definitions;
-use rustc_incremental::DepGraphFuture;
+use rustc_incremental::setup_dep_graph;
use rustc_metadata::creader::CStore;
use rustc_middle::arena::Arena;
use rustc_middle::dep_graph::DepGraph;
@@ -19,7 +19,6 @@ use rustc_session::config::{self, CrateType, OutputFilenames, OutputType};
use rustc_session::cstore::Untracked;
use rustc_session::{output::find_crate_name, Session};
use rustc_span::symbol::sym;
-use rustc_span::Symbol;
use std::any::Any;
use std::cell::{RefCell, RefMut};
use std::sync::Arc;
@@ -78,7 +77,7 @@ impl<T> Default for Query<T> {
pub struct Queries<'tcx> {
compiler: &'tcx Compiler,
- gcx_cell: OnceCell<GlobalCtxt<'tcx>>,
+ gcx_cell: OnceLock<GlobalCtxt<'tcx>>,
arena: WorkerLocal<Arena<'tcx>>,
hir_arena: WorkerLocal<rustc_hir::Arena<'tcx>>,
@@ -93,7 +92,7 @@ impl<'tcx> Queries<'tcx> {
pub fn new(compiler: &'tcx Compiler) -> Queries<'tcx> {
Queries {
compiler,
- gcx_cell: OnceCell::new(),
+ gcx_cell: OnceLock::new(),
arena: WorkerLocal::new(|_| Arena::default()),
hir_arena: WorkerLocal::new(|_| rustc_hir::Arena::default()),
parse: Default::default(),
@@ -114,6 +113,7 @@ impl<'tcx> Queries<'tcx> {
.compute(|| passes::parse(self.session()).map_err(|mut parse_error| parse_error.emit()))
}
+ #[deprecated = "pre_configure may be made private in the future. If you need it please open an issue with your use case."]
pub fn pre_configure(&self) -> Result<QueryResult<'_, (ast::Crate, ast::AttrVec)>> {
self.pre_configure.compute(|| {
let mut krate = self.parse()?.steal();
@@ -131,46 +131,10 @@ impl<'tcx> Queries<'tcx> {
})
}
- fn dep_graph_future(
- &self,
- crate_name: Symbol,
- stable_crate_id: StableCrateId,
- ) -> Result<Option<DepGraphFuture>> {
- let sess = self.session();
-
- // `load_dep_graph` can only be called after `prepare_session_directory`.
- rustc_incremental::prepare_session_directory(sess, crate_name, stable_crate_id)?;
- let res = sess.opts.build_dep_graph().then(|| rustc_incremental::load_dep_graph(sess));
-
- if sess.opts.incremental.is_some() {
- sess.time("incr_comp_garbage_collect_session_directories", || {
- if let Err(e) = rustc_incremental::garbage_collect_session_directories(sess) {
- warn!(
- "Error while trying to garbage collect incremental \
- compilation cache directory: {}",
- e
- );
- }
- });
- }
-
- Ok(res)
- }
-
- fn dep_graph(&self, dep_graph_future: Option<DepGraphFuture>) -> DepGraph {
- dep_graph_future
- .and_then(|future| {
- let sess = self.session();
- let (prev_graph, prev_work_products) =
- sess.time("blocked_on_dep_graph_loading", || future.open().open(sess));
- rustc_incremental::build_dep_graph(sess, prev_graph, prev_work_products)
- })
- .unwrap_or_else(DepGraph::new_disabled)
- }
-
pub fn global_ctxt(&'tcx self) -> Result<QueryResult<'_, &'tcx GlobalCtxt<'tcx>>> {
self.gcx.compute(|| {
let sess = self.session();
+ #[allow(deprecated)]
let (krate, pre_configured_attrs) = self.pre_configure()?.steal();
// parse `#[crate_name]` even if `--crate-name` was passed, to make sure it matches.
@@ -182,10 +146,7 @@ impl<'tcx> Queries<'tcx> {
sess.opts.cg.metadata.clone(),
sess.cfg_version,
);
-
- // Compute the dependency graph (in the background). We want to do this as early as
- // possible, to give the DepGraph maximum time to load before `dep_graph` is called.
- let dep_graph_future = self.dep_graph_future(crate_name, stable_crate_id)?;
+ let dep_graph = setup_dep_graph(sess, crate_name, stable_crate_id)?;
let lint_store = Lrc::new(passes::create_lint_store(
sess,
@@ -193,11 +154,11 @@ impl<'tcx> Queries<'tcx> {
self.compiler.register_lints.as_deref(),
&pre_configured_attrs,
));
- let cstore = RwLock::new(Box::new(CStore::new(
+ let cstore = FreezeLock::new(Box::new(CStore::new(
self.codegen_backend().metadata_loader(),
stable_crate_id,
)) as _);
- let definitions = RwLock::new(Definitions::new(stable_crate_id));
+ let definitions = FreezeLock::new(Definitions::new(stable_crate_id));
let source_span = AppendOnlyIndexVec::new();
let _id = source_span.push(krate.spans.inner_span);
debug_assert_eq!(_id, CRATE_DEF_ID);
@@ -208,7 +169,7 @@ impl<'tcx> Queries<'tcx> {
crate_types,
stable_crate_id,
lint_store,
- self.dep_graph(dep_graph_future),
+ dep_graph,
untracked,
&self.gcx_cell,
&self.arena,