Skip to content

Commit

Permalink
Revert "Let several methods take &Resolver instead of a BoxedResolver…
Browse files Browse the repository at this point in the history
… wrapper"

This reverts commit 5343ec338f72a61e2f51f9d90117092c8e8a725a.
  • Loading branch information
bjorn3 committed Jun 8, 2021
1 parent 5e14820 commit cf1f92a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 29 deletions.
33 changes: 18 additions & 15 deletions compiler/rustc_interface/src/passes.rs
Expand Up @@ -7,6 +7,7 @@ use rustc_ast::{self as ast, visit};
use rustc_codegen_ssa::back::link::emit_metadata;
use rustc_codegen_ssa::traits::CodegenBackend;
use rustc_data_structures::parallel;
use rustc_data_structures::steal::Steal;
use rustc_data_structures::sync::{par_iter, Lrc, OnceCell, ParallelIterator, WorkerLocal};
use rustc_data_structures::temp_dir::MaybeTempDir;
use rustc_errors::{ErrorReported, PResult};
Expand Down Expand Up @@ -270,7 +271,7 @@ fn pre_expansion_lint(

fn configure_and_expand_inner<'a>(
sess: &'a Session,
lint_store: &LintStore,
lint_store: &'a LintStore,
mut krate: ast::Crate,
crate_name: &str,
resolver_arenas: &'a ResolverArenas<'a>,
Expand Down Expand Up @@ -593,7 +594,7 @@ fn escape_dep_env(symbol: Symbol) -> String {

fn write_out_deps(
sess: &Session,
resolver: &Resolver<'_>,
boxed_resolver: &Steal<Rc<RefCell<BoxedResolver>>>,
outputs: &OutputFilenames,
out_filenames: &[PathBuf],
) {
Expand All @@ -620,18 +621,20 @@ fn write_out_deps(
}

if sess.binary_dep_depinfo() {
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()));
boxed_resolver.borrow().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 mut file = BufWriter::new(fs::File::create(&deps_filename)?);
Expand Down Expand Up @@ -687,7 +690,7 @@ pub fn prepare_outputs(
sess: &Session,
compiler: &Compiler,
krate: &ast::Crate,
resolver: &Resolver<'_>,
boxed_resolver: &Steal<Rc<RefCell<BoxedResolver>>>,
crate_name: &str,
) -> Result<OutputFilenames> {
let _timer = sess.timer("prepare_outputs");
Expand Down Expand Up @@ -727,7 +730,7 @@ pub fn prepare_outputs(
}
}

write_out_deps(sess, resolver, &outputs, &output_paths);
write_out_deps(sess, boxed_resolver, &outputs, &output_paths);

let only_dep_info = sess.opts.output_types.contains_key(&OutputType::DepInfo)
&& sess.opts.output_types.len() == 1;
Expand Down
21 changes: 7 additions & 14 deletions compiler/rustc_interface/src/queries.rs
Expand Up @@ -246,20 +246,13 @@ impl<'tcx> Queries<'tcx> {
let expansion_result = self.expansion()?;
let (krate, boxed_resolver, _) = &*expansion_result.peek();
let crate_name = self.crate_name()?.peek();

// These borrow(), borrow_mut() and access() calls are separate statements to prevent a
// "temporary value dropped while borrowed" error.
let boxed_resolver = boxed_resolver.borrow();
let mut boxed_resolver = boxed_resolver.borrow_mut();
boxed_resolver.access(|resolver| {
passes::prepare_outputs(
self.session(),
self.compiler,
&krate,
resolver,
&crate_name,
)
})
passes::prepare_outputs(
self.session(),
self.compiler,
&krate,
&boxed_resolver,
&crate_name,
)
})
}

Expand Down

0 comments on commit cf1f92a

Please sign in to comment.