Skip to content

Commit 0ddf249

Browse files
committed
Avoid locking the global context across the after_expansion callback
1 parent 0c13c17 commit 0ddf249

File tree

1 file changed

+5
-5
lines changed
  • compiler/rustc_driver_impl/src

1 file changed

+5
-5
lines changed

compiler/rustc_driver_impl/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -326,14 +326,16 @@ fn run_compiler(
326326
}
327327
}
328328

329-
let mut gctxt = queries.global_ctxt()?;
329+
// Make sure name resolution and macro expansion is run.
330+
queries.global_ctxt()?;
331+
330332
if callbacks.after_expansion(compiler, queries) == Compilation::Stop {
331333
return early_exit();
332334
}
333335

334336
// Make sure the `output_filenames` query is run for its side
335337
// effects of writing the dep-info and reporting errors.
336-
gctxt.enter(|tcx| tcx.output_filenames(()));
338+
queries.global_ctxt()?.enter(|tcx| tcx.output_filenames(()));
337339

338340
if sess.opts.output_types.contains_key(&OutputType::DepInfo)
339341
&& sess.opts.output_types.len() == 1
@@ -345,7 +347,7 @@ fn run_compiler(
345347
return early_exit();
346348
}
347349

348-
gctxt.enter(|tcx| {
350+
queries.global_ctxt()?.enter(|tcx| {
349351
let result = tcx.analysis(());
350352
if sess.opts.unstable_opts.save_analysis {
351353
let crate_name = tcx.crate_name(LOCAL_CRATE);
@@ -362,8 +364,6 @@ fn run_compiler(
362364
result
363365
})?;
364366

365-
drop(gctxt);
366-
367367
if callbacks.after_analysis(compiler, queries) == Compilation::Stop {
368368
return early_exit();
369369
}

0 commit comments

Comments
 (0)