Skip to content

Commit bed4c09

Browse files
authored
Rollup merge of #66896 - RalfJung:queries, r=Zoxc
pass Queries to compiler callbacks #66791 made it impossible to access the tcx in the callbacks; this should fix that. r? @Zoxc
2 parents 3db3f15 + 7f20198 commit bed4c09

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

src/librustc_driver/lib.rs

+19-7
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use rustc::util::common::{set_time_depth, time, print_time_passes_entry, ErrorRe
4141
use rustc_metadata::locator;
4242
use rustc_codegen_utils::codegen_backend::CodegenBackend;
4343
use errors::{PResult, registry::Registry};
44-
use rustc_interface::interface;
44+
use rustc_interface::{interface, Queries};
4545
use rustc_interface::util::get_codegen_sysroot;
4646
use rustc_data_structures::sync::SeqCst;
4747
use rustc_feature::{find_gated_cfg, UnstableFeatures};
@@ -98,17 +98,29 @@ pub trait Callbacks {
9898
fn config(&mut self, _config: &mut interface::Config) {}
9999
/// Called after parsing. Return value instructs the compiler whether to
100100
/// continue the compilation afterwards (defaults to `Compilation::Continue`)
101-
fn after_parsing(&mut self, _compiler: &interface::Compiler) -> Compilation {
101+
fn after_parsing<'tcx>(
102+
&mut self,
103+
_compiler: &interface::Compiler,
104+
_queries: &'tcx Queries<'tcx>,
105+
) -> Compilation {
102106
Compilation::Continue
103107
}
104108
/// Called after expansion. Return value instructs the compiler whether to
105109
/// continue the compilation afterwards (defaults to `Compilation::Continue`)
106-
fn after_expansion(&mut self, _compiler: &interface::Compiler) -> Compilation {
110+
fn after_expansion<'tcx>(
111+
&mut self,
112+
_compiler: &interface::Compiler,
113+
_queries: &'tcx Queries<'tcx>,
114+
) -> Compilation {
107115
Compilation::Continue
108116
}
109117
/// Called after analysis. Return value instructs the compiler whether to
110118
/// continue the compilation afterwards (defaults to `Compilation::Continue`)
111-
fn after_analysis(&mut self, _compiler: &interface::Compiler) -> Compilation {
119+
fn after_analysis<'tcx>(
120+
&mut self,
121+
_compiler: &interface::Compiler,
122+
_queries: &'tcx Queries<'tcx>,
123+
) -> Compilation {
112124
Compilation::Continue
113125
}
114126
}
@@ -312,7 +324,7 @@ pub fn run_compiler(
312324
return early_exit();
313325
}
314326

315-
if callbacks.after_parsing(compiler) == Compilation::Stop {
327+
if callbacks.after_parsing(compiler, queries) == Compilation::Stop {
316328
return early_exit();
317329
}
318330

@@ -333,7 +345,7 @@ pub fn run_compiler(
333345
}
334346

335347
queries.expansion()?;
336-
if callbacks.after_expansion(compiler) == Compilation::Stop {
348+
if callbacks.after_expansion(compiler, queries) == Compilation::Stop {
337349
return early_exit();
338350
}
339351

@@ -382,7 +394,7 @@ pub fn run_compiler(
382394

383395
queries.global_ctxt()?.peek_mut().enter(|tcx| tcx.analysis(LOCAL_CRATE))?;
384396

385-
if callbacks.after_analysis(compiler) == Compilation::Stop {
397+
if callbacks.after_analysis(compiler, queries) == Compilation::Stop {
386398
return early_exit();
387399
}
388400

src/librustc_interface/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub mod util;
1818
mod proc_macro_decls;
1919

2020
pub use interface::{run_compiler, Config};
21+
pub use queries::Queries;
2122

2223
#[cfg(test)]
2324
mod tests;

0 commit comments

Comments
 (0)