From 138c8558402e3cffa77b53ce5e42d4343b2dfd4f Mon Sep 17 00:00:00 2001 From: jyn Date: Thu, 26 Oct 2023 10:29:04 -0400 Subject: [PATCH] slightly simplify the driver only need one call to `catch_with_exit_code`, not two. also this avoids weird generics in the type signature of `run_compiler`. --- src/main.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/main.rs b/src/main.rs index aa164ea..997638a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,7 +6,6 @@ extern crate rustc_interface; extern crate rustc_middle; extern crate rustc_session; -use rustc_driver::Callbacks; use rustc_hir::def_id::LocalDefId; use rustc_interface::interface; use rustc_middle::mir::BorrowCheckResult; @@ -42,14 +41,8 @@ fn main() { let handler = EarlyErrorHandler::new(ErrorOutputType::HumanReadable(HumanReadableErrorType::Default(ColorConfig::Auto))); rustc_driver::init_rustc_env_logger(&handler); std::process::exit(rustc_driver::catch_with_exit_code(move || { - let args: Vec = std::env::args().collect(); - run_compiler(args, &mut UbrustcCallbacks); + let mut args: Vec = std::env::args().collect(); + args.splice(1..1, std::iter::once("--cfg=ubrustc".to_string())); + rustc_driver::RunCompiler::new(&args, &mut UbrustcCallbacks).run() })) } - -fn run_compiler(mut args: Vec, callbacks: &mut CB) -> ! { - args.splice(1..1, std::iter::once("--cfg=ubrustc".to_string())); - std::process::exit(rustc_driver::catch_with_exit_code(move || { - rustc_driver::RunCompiler::new(&args, callbacks).run() - })); -}