Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass Queries to compiler callbacks #66896

Merged
merged 1 commit into from
Dec 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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();
}

Expand All @@ -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();
}

Expand Down Expand Up @@ -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();
}

Expand Down
1 change: 1 addition & 0 deletions src/librustc_interface/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;