Skip to content

Commit 1eece74

Browse files
committed
Reduce the amount of GlobalCtxt::enter calls in the driver
We now only exit the GlobalCtxt when calling a callback and all the way at the end when the GlobalCtxt is about to be destroyed.
1 parent 8e9bbc8 commit 1eece74

File tree

1 file changed

+10
-14
lines changed
  • compiler/rustc_driver_impl/src

1 file changed

+10
-14
lines changed

compiler/rustc_driver_impl/src/lib.rs

+10-14
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,6 @@ fn run_compiler(
396396
queries.global_ctxt()?.enter(|tcx| {
397397
tcx.ensure().early_lint_checks(());
398398
pretty::print(sess, pp_mode, pretty::PrintExtra::NeedsAstMap { tcx });
399-
Ok(())
400-
})?;
401-
402-
queries.global_ctxt()?.enter(|tcx| {
403399
passes::write_dep_info(tcx);
404400
});
405401
} else {
@@ -429,19 +425,19 @@ fn run_compiler(
429425

430426
queries.global_ctxt()?.enter(|tcx| {
431427
passes::write_dep_info(tcx);
432-
});
433428

434-
if sess.opts.output_types.contains_key(&OutputType::DepInfo)
435-
&& sess.opts.output_types.len() == 1
436-
{
437-
return early_exit();
438-
}
429+
if sess.opts.output_types.contains_key(&OutputType::DepInfo)
430+
&& sess.opts.output_types.len() == 1
431+
{
432+
return early_exit();
433+
}
439434

440-
if sess.opts.unstable_opts.no_analysis {
441-
return early_exit();
442-
}
435+
if sess.opts.unstable_opts.no_analysis {
436+
return early_exit();
437+
}
443438

444-
queries.global_ctxt()?.enter(|tcx| tcx.analysis(()))?;
439+
tcx.analysis(())?;
440+
})?;
445441

446442
if callbacks.after_analysis(compiler, queries) == Compilation::Stop {
447443
return early_exit();

0 commit comments

Comments
 (0)