diff --git a/src/lib.rs b/src/lib.rs index 4518e1d..2595a89 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,23 +8,20 @@ extern crate rustc_driver; extern crate rustc_errors; extern crate rustc_metadata; extern crate rustc_codegen_utils; +extern crate rustc_interface; extern crate syntax; -use rustc_metadata::cstore::CStore; -use rustc::session::{Session, early_error}; -use rustc::session::config::{self, ErrorOutputType, Input}; -use rustc_codegen_utils::codegen_backend::CodegenBackend; -use rustc_driver::driver::CompileController; -use rustc_driver::{run_compiler, CompilerCalls, RustcDefaultCalls, Compilation, enable_save_analysis}; -use syntax::ast; +use rustc::session::early_error; +use rustc::session::config::ErrorOutputType; +use rustc_driver::{run_compiler, Callbacks}; +use rustc_interface::interface; use std::env; -use std::path::PathBuf; use std::process; pub fn run() { drop(env_logger::init()); - let result = rustc_driver::run(|| { + let result = rustc_driver::report_ices_to_stderr_if_any(|| { let args = env::args_os().enumerate() .map(|(i, arg)| arg.into_string().unwrap_or_else(|arg| { early_error(ErrorOutputType::default(), @@ -33,63 +30,18 @@ pub fn run() { .collect::>(); run_compiler(&args, - Box::new(ShimCalls), + &mut ShimCalls, None, None) - }); - process::exit(result as i32); + }).and_then(|result| result); + process::exit(result.is_err() as i32); } - struct ShimCalls; -impl<'a> CompilerCalls<'a> for ShimCalls { - fn early_callback(&mut self, - a: &getopts::Matches, - b: &config::Options, - c: &ast::CrateConfig, - d: &rustc_errors::registry::Registry, - e: ErrorOutputType) - -> Compilation { - RustcDefaultCalls.early_callback(a, b, c, d, e) - } - - fn late_callback(&mut self, - a: &CodegenBackend, - b: &getopts::Matches, - c: &Session, - d: &CStore, - e: &Input, - f: &Option, - g: &Option) - -> Compilation { - RustcDefaultCalls.late_callback(a, b, c, d, e, f, g) - } - - fn some_input(&mut self, - a: Input, - b: Option) - -> (Input, Option) { - RustcDefaultCalls.some_input(a, b) - } - - fn no_input(&mut self, - a: &getopts::Matches, - b: &config::Options, - c: &ast::CrateConfig, - d: &Option, - e: &Option, - f: &rustc_errors::registry::Registry) - -> Option<(Input, Option)> { - RustcDefaultCalls.no_input(a, b, c, d, e, f) - } - - fn build_controller(self: Box, a: &Session, b: &getopts::Matches) -> CompileController<'a> { - let mut result = Box::new(RustcDefaultCalls).build_controller(a, b); - - result.continue_parse_after_error = true; - enable_save_analysis(&mut result); - - result +impl Callbacks for ShimCalls { + fn config(&mut self, config: &mut interface::Config) { + config.opts.debugging_opts.continue_parse_after_error = true; + config.opts.debugging_opts.save_analysis = true; } }