1
Fork 0

Pass TyCtxt instead of Queries to the after_analysis callbacks

There is no other query that may need to be called at that point anyway.
This commit is contained in:
bjorn3 2024-10-31 16:05:59 +00:00
parent 1eece7478d
commit 3b02a3309e
22 changed files with 112 additions and 107 deletions

View file

@ -313,6 +313,7 @@ macro_rules! optional {
macro_rules! run_driver {
($args:expr, $callback:expr $(, $with_tcx:ident)?) => {{
use rustc_driver::{Callbacks, Compilation, RunCompiler};
use rustc_middle::ty::TyCtxt;
use rustc_interface::{interface, Queries};
use stable_mir::CompilerError;
use std::ops::ControlFlow;
@ -373,23 +374,21 @@ macro_rules! run_driver {
fn after_analysis<'tcx>(
&mut self,
_compiler: &interface::Compiler,
queries: &'tcx Queries<'tcx>,
tcx: TyCtxt<'tcx>,
) -> Compilation {
queries.global_ctxt().unwrap().enter(|tcx| {
if let Some(callback) = self.callback.take() {
rustc_internal::run(tcx, || {
self.result = Some(callback($(optional!($with_tcx tcx))?));
})
.unwrap();
if self.result.as_ref().is_some_and(|val| val.is_continue()) {
Compilation::Continue
} else {
Compilation::Stop
}
} else {
if let Some(callback) = self.callback.take() {
rustc_internal::run(tcx, || {
self.result = Some(callback($(optional!($with_tcx tcx))?));
})
.unwrap();
if self.result.as_ref().is_some_and(|val| val.is_continue()) {
Compilation::Continue
} else {
Compilation::Stop
}
})
} else {
Compilation::Continue
}
}
}