Some cleanups around EarlyDiagCtxt

All callers of EarlyDiagCtxt::early_error now emit a fatal error.
This commit is contained in:
bjorn3 2025-02-02 15:17:29 +00:00
parent 6dd75f0d68
commit d237378cd1
8 changed files with 26 additions and 40 deletions

View file

@ -197,7 +197,7 @@ pub fn main() {
});
exit(rustc_driver::catch_with_exit_code(move || {
let mut orig_args = rustc_driver::args::raw_args(&early_dcx)?;
let mut orig_args = rustc_driver::args::raw_args(&early_dcx);
let has_sysroot_arg = |args: &mut [String]| -> bool {
if has_arg(args, "--sysroot") {
@ -239,7 +239,7 @@ pub fn main() {
pass_sysroot_env_if_given(&mut args, sys_root_env);
rustc_driver::run_compiler(&args, &mut DefaultCallbacks);
return Ok(());
return;
}
if orig_args.iter().any(|a| a == "--version" || a == "-V") {
@ -301,7 +301,6 @@ pub fn main() {
} else {
rustc_driver::run_compiler(&args, &mut RustcCallbacks { clippy_args_var });
}
Ok(())
}))
}

View file

@ -379,10 +379,8 @@ fn run_compiler_and_exit(
callbacks: &mut (dyn rustc_driver::Callbacks + Send),
) -> ! {
// Invoke compiler, and handle return code.
let exit_code = rustc_driver::catch_with_exit_code(move || {
rustc_driver::run_compiler(args, callbacks);
Ok(())
});
let exit_code =
rustc_driver::catch_with_exit_code(move || rustc_driver::run_compiler(args, callbacks));
std::process::exit(exit_code)
}
@ -461,7 +459,7 @@ fn main() {
// (`install_ice_hook` might change `RUST_BACKTRACE`.)
let env_snapshot = env::vars_os().collect::<Vec<_>>();
let args = rustc_driver::args::raw_args(&early_dcx)
let args = rustc_driver::catch_fatal_errors(|| rustc_driver::args::raw_args(&early_dcx))
.unwrap_or_else(|_| std::process::exit(rustc_driver::EXIT_FAILURE));
// Install the ctrlc handler that sets `rustc_const_eval::CTRL_C_RECEIVED`, even if