diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-02-07 17:57:15 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-07 17:57:15 +0100 |
| commit | 8709e9be5adfe50fa765f73aec8fb5725ec20862 (patch) | |
| tree | 9cfd0da47d01c1a8e22cf371f068d51e21f66b00 | |
| parent | 401fe5c000d785fdc428ea753c9246dfe6bce935 (diff) | |
| parent | 0ddf249532f188cdd947a333dfd8a009cc517ccc (diff) | |
| download | rust-8709e9be5adfe50fa765f73aec8fb5725ec20862.tar.gz rust-8709e9be5adfe50fa765f73aec8fb5725ec20862.zip | |
Rollup merge of #107740 - oli-obk:lock_tcx, r=petrochenkov
Avoid locking the global context across the `after_expansion` callback r? `@petrochenkov` This was noticed in https://github.com/model-checking/kani/pull/2184#issuecomment-1416566982 This didn't have a perf impact, as it's just an additional 2 or 3 RefCell locks being created.
| -rw-r--r-- | compiler/rustc_driver_impl/src/lib.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 02e0b042ad2..1da13afecfa 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -326,14 +326,16 @@ fn run_compiler( } } - let mut gctxt = queries.global_ctxt()?; + // Make sure name resolution and macro expansion is run. + queries.global_ctxt()?; + if callbacks.after_expansion(compiler, queries) == Compilation::Stop { return early_exit(); } // Make sure the `output_filenames` query is run for its side // effects of writing the dep-info and reporting errors. - gctxt.enter(|tcx| tcx.output_filenames(())); + queries.global_ctxt()?.enter(|tcx| tcx.output_filenames(())); if sess.opts.output_types.contains_key(&OutputType::DepInfo) && sess.opts.output_types.len() == 1 @@ -345,7 +347,7 @@ fn run_compiler( return early_exit(); } - gctxt.enter(|tcx| { + queries.global_ctxt()?.enter(|tcx| { let result = tcx.analysis(()); if sess.opts.unstable_opts.save_analysis { let crate_name = tcx.crate_name(LOCAL_CRATE); @@ -362,8 +364,6 @@ fn run_compiler( result })?; - drop(gctxt); - if callbacks.after_analysis(compiler, queries) == Compilation::Stop { return early_exit(); } |
