about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2019-11-30 10:16:19 +0100
committerRalf Jung <post@ralfj.de>2019-11-30 10:16:19 +0100
commit7f20198632bc2079d4deb4c213ec4876c47ec5d2 (patch)
treec000bfcd05ceaf59708ba13a85c30155095ba905 /src
parent8f1bbd69e13c9e04a4c2b75612bc0c31af972439 (diff)
downloadrust-7f20198632bc2079d4deb4c213ec4876c47ec5d2.tar.gz
rust-7f20198632bc2079d4deb4c213ec4876c47ec5d2.zip
pass Queries to compiler callbacks
Diffstat (limited to 'src')
-rw-r--r--src/librustc_driver/lib.rs26
-rw-r--r--src/librustc_interface/lib.rs1
2 files changed, 20 insertions, 7 deletions
diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs
index c945de8f1e1..37fc8d0a554 100644
--- a/src/librustc_driver/lib.rs
+++ b/src/librustc_driver/lib.rs
@@ -41,7 +41,7 @@ use rustc::util::common::{set_time_depth, time, print_time_passes_entry, ErrorRe
 use rustc_metadata::locator;
 use rustc_codegen_utils::codegen_backend::CodegenBackend;
 use errors::{PResult, registry::Registry};
-use rustc_interface::interface;
+use rustc_interface::{interface, Queries};
 use rustc_interface::util::get_codegen_sysroot;
 use rustc_data_structures::sync::SeqCst;
 
@@ -99,17 +99,29 @@ pub trait Callbacks {
     fn config(&mut self, _config: &mut interface::Config) {}
     /// Called after parsing. Return value instructs the compiler whether to
     /// continue the compilation afterwards (defaults to `Compilation::Continue`)
-    fn after_parsing(&mut self, _compiler: &interface::Compiler) -> Compilation {
+    fn after_parsing<'tcx>(
+        &mut self,
+        _compiler: &interface::Compiler,
+        _queries: &'tcx Queries<'tcx>,
+    ) -> Compilation {
         Compilation::Continue
     }
     /// Called after expansion. Return value instructs the compiler whether to
     /// continue the compilation afterwards (defaults to `Compilation::Continue`)
-    fn after_expansion(&mut self, _compiler: &interface::Compiler) -> Compilation {
+    fn after_expansion<'tcx>(
+        &mut self,
+        _compiler: &interface::Compiler,
+        _queries: &'tcx Queries<'tcx>,
+    ) -> Compilation {
         Compilation::Continue
     }
     /// Called after analysis. Return value instructs the compiler whether to
     /// continue the compilation afterwards (defaults to `Compilation::Continue`)
-    fn after_analysis(&mut self, _compiler: &interface::Compiler) -> Compilation {
+    fn after_analysis<'tcx>(
+        &mut self,
+        _compiler: &interface::Compiler,
+        _queries: &'tcx Queries<'tcx>,
+    ) -> Compilation {
         Compilation::Continue
     }
 }
@@ -313,7 +325,7 @@ pub fn run_compiler(
                 return early_exit();
             }
 
-            if callbacks.after_parsing(compiler) == Compilation::Stop {
+            if callbacks.after_parsing(compiler, queries) == Compilation::Stop {
                 return early_exit();
             }
 
@@ -334,7 +346,7 @@ pub fn run_compiler(
             }
 
             queries.expansion()?;
-            if callbacks.after_expansion(compiler) == Compilation::Stop {
+            if callbacks.after_expansion(compiler, queries) == Compilation::Stop {
                 return early_exit();
             }
 
@@ -383,7 +395,7 @@ pub fn run_compiler(
 
             queries.global_ctxt()?.peek_mut().enter(|tcx| tcx.analysis(LOCAL_CRATE))?;
 
-            if callbacks.after_analysis(compiler) == Compilation::Stop {
+            if callbacks.after_analysis(compiler, queries) == Compilation::Stop {
                 return early_exit();
             }
 
diff --git a/src/librustc_interface/lib.rs b/src/librustc_interface/lib.rs
index 53baf6556fb..76af4342f5c 100644
--- a/src/librustc_interface/lib.rs
+++ b/src/librustc_interface/lib.rs
@@ -18,6 +18,7 @@ pub mod util;
 mod proc_macro_decls;
 
 pub use interface::{run_compiler, Config};
+pub use queries::Queries;
 
 #[cfg(test)]
 mod tests;