diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2018-05-27 20:02:51 +0200 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2018-06-05 18:04:18 +0200 |
| commit | 4e0ee758b7d3292c2f2bbc6443ed1ea8f180f953 (patch) | |
| tree | 95c3f88474c5a4643346803e06f531bac03abfc9 /src | |
| parent | 4f45b0611cf4ec0e0a7e49c4c5eb2bedd2805494 (diff) | |
| download | rust-4e0ee758b7d3292c2f2bbc6443ed1ea8f180f953.tar.gz rust-4e0ee758b7d3292c2f2bbc6443ed1ea8f180f953.zip | |
Impl CompilerCalls for CompileController instead of AdHocCompilerCalls
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_driver/driver.rs | 57 | ||||
| -rw-r--r-- | 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 ed28b05c125..7b177d5e79c 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<PathBuf>, + ofile: &Option<PathBuf>, + descriptions: &::errors::registry::Registry, + ) -> Option<(Input, Option<PathBuf>)> { + ::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<PathBuf>, + ofile: &Option<PathBuf>, + ) -> Compilation { + ::RustcDefaultCalls + .late_callback(codegen_backend, matches, sess, cstore, input, odir, ofile) + } + fn build_controller( + self: Box<Self>, + _: &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 991918a1729..67fd5da8c92 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<Fn(&mut ::driver::CompileState) + 'a>) -} - -impl<'a> CompilerCalls<'a> for AdHocCalls<'a> { - fn build_controller( - self: Box<Self>, - _: &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)] |
