From 4e0ee758b7d3292c2f2bbc6443ed1ea8f180f953 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 27 May 2018 20:02:51 +0200 Subject: [PATCH] Impl CompilerCalls for CompileController instead of AdHocCompilerCalls --- src/librustc_driver/driver.rs | 57 +++++++++++++++++++++++++++++++++++ src/librustc_driver/lib.rs | 24 --------------- 2 files changed, 57 insertions(+), 24 deletions(-) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index ed28b05c1255..7b177d5e79c1 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -414,6 +414,63 @@ impl<'a> CompileController<'a> { } } +impl<'a> ::CompilerCalls<'a> for CompileController<'a> { + fn early_callback( + &mut self, + matches: &::getopts::Matches, + sopts: &config::Options, + cfg: &ast::CrateConfig, + descriptions: &::errors::registry::Registry, + output: ::ErrorOutputType, + ) -> Compilation { + ::RustcDefaultCalls.early_callback( + matches, + sopts, + cfg, + descriptions, + output, + ) + } + fn no_input( + &mut self, + matches: &::getopts::Matches, + sopts: &config::Options, + cfg: &ast::CrateConfig, + odir: &Option, + ofile: &Option, + descriptions: &::errors::registry::Registry, + ) -> Option<(Input, Option)> { + ::RustcDefaultCalls.no_input( + matches, + sopts, + cfg, + odir, + ofile, + descriptions, + ) + } + fn late_callback( + &mut self, + codegen_backend: &::CodegenBackend, + matches: &::getopts::Matches, + sess: &Session, + cstore: &::CrateStore, + input: &Input, + odir: &Option, + ofile: &Option, + ) -> Compilation { + ::RustcDefaultCalls + .late_callback(codegen_backend, matches, sess, cstore, input, odir, ofile) + } + fn build_controller( + self: Box, + _: &Session, + _: &::getopts::Matches + ) -> CompileController<'a> { + *self + } +} + pub struct PhaseController<'a> { pub stop: Compilation, // If true then the compiler will try to run the callback even if the phase diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 991918a1729e..67fd5da8c92d 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -712,30 +712,6 @@ pub trait CompilerCalls<'a> { #[derive(Copy, Clone)] pub struct RustcDefaultCalls; -/// CompilerCalls instance for quick access to the result of one compile phase. -pub enum AdHocCalls<'a> { - AfterAnalysis(Compilation, Box) -} - -impl<'a> CompilerCalls<'a> for AdHocCalls<'a> { - fn build_controller( - self: Box, - _: &Session, - _: &getopts::Matches - ) -> CompileController<'a> { - let mut control = CompileController::basic(); - - match *self { - AdHocCalls::AfterAnalysis(c, f) => { - control.after_analysis.stop = c; - control.after_analysis.callback = f; - } - } - - control - } -} - // FIXME remove these and use winapi 0.3 instead // Duplicates: bootstrap/compile.rs, librustc_errors/emitter.rs #[cfg(unix)]