10000 Add an `after_expansion` callback in the driver by Xanewok · Pull Request #62679 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Add an after_expansion callback in the driver #62679

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

Merged
merged 2 commits into from
Jul 19, 2019
Merged
Changes from 1 commit
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
Prev Previous commit
Use more descriptive Compilation enum in rustc interface callbacks
  • Loading branch information
Xanewok committed Jul 15, 2019
commit ff63336b65691f4fd0e339bb74a1798d1f96e86e
27 changes: 15 additions & 12 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,20 @@ pub fn abort_on_err<T>(result: Result<T, ErrorReported>, sess: &Session) -> T {
pub trait Callbacks {
/// Called before creating the compiler instance
fn config(&mut self, _config: &mut interface::Config) {}
/// Called after parsing and returns true to continue execution
fn after_parsing(&mut self, _compiler: &interface::Compiler) -> bool {
true
/// 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 {
Compilation::Continue
}
/// Called after expansion and returns true to continue execution
fn after_expansion(&mut self, _compiler: &interface::Compiler) -> bool {
true
/// 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 {
Compilation::Continue
}
/// Called after analysis and returns true to continue execution
fn after_analysis(&mut self, _compiler: &interface::Compiler) -> bool {
true
/// 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 {
Compilation::Continue
}
}

Expand Down Expand Up @@ -298,7 +301,7 @@ pub fn run_compiler(
}
}

if !callbacks.after_parsing(compiler) {
if callbacks.after_parsing(compiler) == Compilation::Stop {
return sess.compile_status();
}

Expand All @@ -317,7 +320,7 @@ pub fn run_compiler(
}

compiler.expansion()?;
if !callbacks.after_expansion(compiler) {
if callbacks.after_expansion(compiler) == Compilation::Stop {
return sess.compile_status();
}

Expand Down Expand Up @@ -364,7 +367,7 @@ pub fn run_compiler(

compiler.global_ctxt()?.peek_mut().enter(|tcx| tcx.analysis(LOCAL_CRATE))?;

if !callbacks.after_analysis(compiler) {
if callbacks.after_analysis(compiler) == Compilation::Stop {
return sess.compile_status();
}

Expand Down
0