diff --git a/src/tools/miri/src/bin/miri.rs b/src/tools/miri/src/bin/miri.rs index 48f8e146a190..aa5e5d708da9 100644 --- a/src/tools/miri/src/bin/miri.rs +++ b/src/tools/miri/src/bin/miri.rs @@ -39,6 +39,7 @@ mod log; use std::env; use std::num::{NonZero, NonZeroI32}; use std::ops::Range; +use std::process::ExitCode; use std::rc::Rc; use std::str::FromStr; use std::sync::Once; @@ -404,7 +405,11 @@ fn run_compiler_and_exit( // Invoke compiler, catch any unwinding panics and handle return code. let exit_code = rustc_driver::catch_with_exit_code(move || rustc_driver::run_compiler(args, callbacks)); - exit(exit_code) + exit(if exit_code == ExitCode::SUCCESS { + rustc_driver::EXIT_SUCCESS + } else { + rustc_driver::EXIT_FAILURE + }) } /// Parses a comma separated list of `T` from the given string: @@ -434,7 +439,7 @@ fn parse_range(val: &str) -> Result, &'static str> { Ok(from..to) } -fn main() { +fn main() -> ExitCode { let early_dcx = EarlyDiagCtxt::new(ErrorOutputType::default()); // Snapshot a copy of the environment before `rustc` starts messing with it. @@ -449,9 +454,7 @@ fn main() { if crate_kind == "host" { // For host crates like proc macros and build scripts, we are an entirely normal rustc. // These eventually produce actual binaries and never run in Miri. - match rustc_driver::main() { - // Empty match proves this function will never return. - } + return rustc_driver::main(); } else if crate_kind != "target" { panic!("invalid `MIRI_BE_RUSTC` value: {crate_kind:?}") };