1
Fork 0

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

View file

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