Use tcx queries instead of passing the values to configure_and_expand.

This commit is contained in:
Oli Scherer 2023-02-16 11:36:44 +00:00
parent 1202fce40e
commit 63c8d00090
2 changed files with 8 additions and 13 deletions

View File

@ -12,7 +12,7 @@ use rustc_data_structures::sync::{Lrc, OnceCell, WorkerLocal};
use rustc_errors::{ErrorGuaranteed, PResult};
use rustc_expand::base::{ExtCtxt, LintStoreExpand, ResolverExpand};
use rustc_hir::def_id::{StableCrateId, LOCAL_CRATE};
use rustc_lint::{BufferedEarlyLint, EarlyCheckNode, LintStore};
use rustc_lint::{unerased_lint_store, BufferedEarlyLint, EarlyCheckNode, LintStore};
use rustc_metadata::creader::CStore;
use rustc_middle::arena::Arena;
use rustc_middle::dep_graph::DepGraph;
@ -171,14 +171,15 @@ impl LintStoreExpand for LintStoreExpandImpl<'_> {
/// syntax expansion, secondary `cfg` expansion, synthesis of a test
/// harness if one is to be provided, injection of a dependency on the
/// standard library and prelude, and name resolution.
#[instrument(level = "trace", skip(tcx, krate, resolver))]
pub fn configure_and_expand(
sess: &Session,
lint_store: &LintStore,
tcx: TyCtxt<'_>,
mut krate: ast::Crate,
crate_name: Symbol,
resolver: &mut Resolver<'_, '_>,
) -> Result<ast::Crate> {
trace!("configure_and_expand");
let sess = tcx.sess;
let lint_store = unerased_lint_store(tcx);
let crate_name = tcx.crate_name(LOCAL_CRATE);
pre_expansion_lint(sess, lint_store, resolver.registered_tools(), &krate, crate_name);
rustc_builtin_macros::register_builtin_macros(resolver);

View File

@ -204,7 +204,7 @@ impl<'tcx> Queries<'tcx> {
let qcx = passes::create_global_ctxt(
self.compiler,
lint_store.clone(),
lint_store,
self.dep_graph()?.steal(),
untracked,
&self.queries,
@ -227,13 +227,7 @@ impl<'tcx> Queries<'tcx> {
self.codegen_backend().metadata_loader(),
&arenas,
);
let krate = passes::configure_and_expand(
sess,
&lint_store,
krate,
crate_name,
&mut resolver,
)?;
let krate = passes::configure_and_expand(tcx, krate, &mut resolver)?;
// Make sure we don't mutate the cstore from here on.
tcx.untracked().cstore.leak();