Skip to content

Commit 717287f

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 6076dd5 commit 717287f

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
@@ -394,10 +394,6 @@ fn run_compiler(
394394
queries.global_ctxt()?.enter(|tcx| {
395395
tcx.ensure().early_lint_checks(());
396396
pretty::print(sess, pp_mode, pretty::PrintExtra::NeedsAstMap { tcx });
397-
Ok(())
398-
})?;
399-
400-
queries.global_ctxt()?.enter(|tcx| {
401397
passes::write_dep_info(tcx);
402398
});
403399
} else {
@@ -427,19 +423,19 @@ fn run_compiler(
427423

428424
queries.global_ctxt()?.enter(|tcx| {
429425
passes::write_dep_info(tcx);
430-
});
431426

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

438-
if sess.opts.unstable_opts.no_analysis {
439-
return early_exit();
440-
}
433+
if sess.opts.unstable_opts.no_analysis {
434+
return early_exit();
435+
}
441436

442-
queries.global_ctxt()?.enter(|tcx| tcx.analysis(()))?;
437+
tcx.analysis(())?;
438+
})?;
443439

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

0 commit comments

Comments
 (0)