From abee6137f70c8293078c03919fda68f0a5b9ca1d Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 7 Dec 2022 09:33:25 +0000 Subject: [PATCH] Remove another unneeded use of the resolver --- compiler/rustc_interface/src/passes.rs | 33 ++++++++++++------------- compiler/rustc_interface/src/queries.rs | 9 +++++-- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 379a76528f3..4b3034c4781 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -30,7 +30,7 @@ use rustc_plugin_impl as plugin; use rustc_query_impl::{OnDiskCache, Queries as TcxQueries}; use rustc_resolve::{Resolver, ResolverArenas}; use rustc_session::config::{CrateType, Input, OutputFilenames, OutputType}; -use rustc_session::cstore::{MetadataLoader, MetadataLoaderDyn, Untracked}; +use rustc_session::cstore::{CrateStoreDyn, MetadataLoader, MetadataLoaderDyn, Untracked}; use rustc_session::output::filename_for_input; use rustc_session::search_paths::PathKind; use rustc_session::{Limit, Session}; @@ -548,7 +548,7 @@ fn escape_dep_env(symbol: Symbol) -> String { fn write_out_deps( sess: &Session, - boxed_resolver: &RefCell, + cstore: &CrateStoreDyn, outputs: &OutputFilenames, out_filenames: &[PathBuf], ) { @@ -600,20 +600,19 @@ fn write_out_deps( } } - boxed_resolver.borrow_mut().access(|resolver| { - for cnum in resolver.cstore().crates_untracked() { - let source = resolver.cstore().crate_source_untracked(cnum); - if let Some((path, _)) = &source.dylib { - files.push(escape_dep_filename(&path.display().to_string())); - } - if let Some((path, _)) = &source.rlib { - files.push(escape_dep_filename(&path.display().to_string())); - } - if let Some((path, _)) = &source.rmeta { - files.push(escape_dep_filename(&path.display().to_string())); - } + let cstore = cstore.as_any().downcast_ref::().unwrap(); + for cnum in cstore.crates_untracked() { + let source = cstore.crate_source_untracked(cnum); + if let Some((path, _)) = &source.dylib { + files.push(escape_dep_filename(&path.display().to_string())); } - }); + if let Some((path, _)) = &source.rlib { + files.push(escape_dep_filename(&path.display().to_string())); + } + if let Some((path, _)) = &source.rmeta { + files.push(escape_dep_filename(&path.display().to_string())); + } + } } let mut file = BufWriter::new(fs::File::create(&deps_filename)?); @@ -664,7 +663,7 @@ fn write_out_deps( pub fn prepare_outputs( sess: &Session, krate: &ast::Crate, - boxed_resolver: &RefCell, + cstore: &CrateStoreDyn, crate_name: Symbol, ) -> Result { let _timer = sess.timer("prepare_outputs"); @@ -697,7 +696,7 @@ pub fn prepare_outputs( } } - write_out_deps(sess, boxed_resolver, &outputs, &output_paths); + write_out_deps(sess, cstore, &outputs, &output_paths); let only_dep_info = sess.opts.output_types.contains_key(&OutputType::DepInfo) && sess.opts.output_types.len() == 1; diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs index d5a49dd75be..fe24d41a4de 100644 --- a/compiler/rustc_interface/src/queries.rs +++ b/compiler/rustc_interface/src/queries.rs @@ -212,8 +212,6 @@ impl<'tcx> Queries<'tcx> { let crate_name = *self.crate_name()?.borrow(); let (krate, resolver, lint_store) = self.expansion()?.steal(); - let outputs = passes::prepare_outputs(self.session(), &krate, &resolver, crate_name)?; - let ty::ResolverOutputs { untracked, global_ctxt: untracked_resolutions, @@ -237,6 +235,13 @@ impl<'tcx> Queries<'tcx> { tcx.arena.alloc(Steal::new((untracked_resolver_for_lowering, krate))), ); feed.resolutions(tcx.arena.alloc(untracked_resolutions)); + + let outputs = passes::prepare_outputs( + self.session(), + &krate, + &*untracked.cstore, + crate_name, + )?; feed.output_filenames(tcx.arena.alloc(std::sync::Arc::new(outputs))); feed.features_query(tcx.sess.features_untracked()); let feed = tcx.feed_local_crate();