Skip to content

Commit 7f20198

Browse files
committed
pass Queries to compiler callbacks
1 parent 8f1bbd6 commit 7f20198

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

@@ -99,17 +99,29 @@ pub trait Callbacks {
9999
fn config(&mut self, _config: &mut interface::Config) {}
100100
/// Called after parsing. Return value instructs the compiler whether to
101101
/// continue the compilation afterwards (defaults to `Compilation::Continue`)
102-
fn after_parsing(&mut self, _compiler: &interface::Compiler) -> Compilation {
102+
fn after_parsing<'tcx>(
103+
&mut self,
104+
_compiler: &interface::Compiler,
105+
_queries: &'tcx Queries<'tcx>,
106+
) -> Compilation {
103107
Compilation::Continue
104108
}
105109
/// Called after expansion. Return value instructs the compiler whether to
106110
/// continue the compilation afterwards (defaults to `Compilation::Continue`)
107-
fn after_expansion(&mut self, _compiler: &interface::Compiler) -> Compilation {
111+
fn after_expansion<'tcx>(
112+
&mut self,
113+
_compiler: &interface::Compiler,
114+
_queries: &'tcx Queries<'tcx>,
115+
) -> Compilation {
108116
Compilation::Continue
109117
}
110118
/// Called after analysis. Return value instructs the compiler whether to
111119
/// continue the compilation afterwards (defaults to `Compilation::Continue`)
112-
fn after_analysis(&mut self, _compiler: &interface::Compiler) -> Compilation {
120+
fn after_analysis<'tcx>(
121+
&mut self,
122+
_compiler: &interface::Compiler,
123+
_queries: &'tcx Queries<'tcx>,
124+
) -> Compilation {
113125
Compilation::Continue
114126
}
115127
}
@@ -313,7 +325,7 @@ pub fn run_compiler(
313325
return early_exit();
314326
}
315327

316-
if callbacks.after_parsing(compiler) == Compilation::Stop {
328+
if callbacks.after_parsing(compiler, queries) == Compilation::Stop {
317329
return early_exit();
318330
}
319331

@@ -334,7 +346,7 @@ pub fn run_compiler(
334346
}
335347

336348
queries.expansion()?;
337-
if callbacks.after_expansion(compiler) == Compilation::Stop {
349+
if callbacks.after_expansion(compiler, queries) == Compilation::Stop {
338350
return early_exit();
339351
}
340352

@@ -383,7 +395,7 @@ pub fn run_compiler(
383395

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

386-
if callbacks.after_analysis(compiler) == Compilation::Stop {
398+
if callbacks.after_analysis(compiler, queries) == Compilation::Stop {
387399
return early_exit();
388400
}
389401

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)