@@ -41,6 +41,7 @@ mod log;
4141use std:: env;
4242use std:: num:: { NonZero , NonZeroI32 } ;
4343use std:: ops:: Range ;
44+ use std:: process:: ExitCode ;
4445use std:: rc:: Rc ;
4546use std:: str:: FromStr ;
4647use std:: sync:: Once ;
@@ -397,16 +398,14 @@ use fatal_error;
397398fn run_compiler_and_exit (
398399 args : & [ String ] ,
399400 callbacks : & mut ( dyn rustc_driver:: Callbacks + Send ) ,
400- ) -> ! {
401+ ) -> ExitCode {
401402 // Install the ctrlc handler that sets `rustc_const_eval::CTRL_C_RECEIVED`, even if
402403 // MIRI_BE_RUSTC is set. We do this late so that when `native_lib::init_sv` is called,
403404 // there are no other threads.
404405 rustc_driver:: install_ctrlc_handler ( ) ;
405406
406407 // Invoke compiler, catch any unwinding panics and handle return code.
407- let exit_code =
408- rustc_driver:: catch_with_exit_code ( move || rustc_driver:: run_compiler ( args, callbacks) ) ;
409- exit ( exit_code)
408+ rustc_driver:: catch_with_exit_code ( move || rustc_driver:: run_compiler ( args, callbacks) )
410409}
411410
412411/// Parses a comma separated list of `T` from the given string:
@@ -436,7 +435,7 @@ fn parse_range(val: &str) -> Result<Range<u32>, &'static str> {
436435 Ok ( from..to)
437436}
438437
439- fn main ( ) {
438+ fn main ( ) -> ExitCode {
440439 let early_dcx = EarlyDiagCtxt :: new ( ErrorOutputType :: default ( ) ) ;
441440
442441 // Snapshot a copy of the environment before `rustc` starts messing with it.
@@ -451,9 +450,7 @@ fn main() {
451450 if crate_kind == "host" {
452451 // For host crates like proc macros and build scripts, we are an entirely normal rustc.
453452 // These eventually produce actual binaries and never run in Miri.
454- match rustc_driver:: main ( ) {
455- // Empty match proves this function will never return.
456- }
453+ return rustc_driver:: main ( ) ;
457454 } else if crate_kind != "target" {
458455 panic ! ( "invalid `MIRI_BE_RUSTC` value: {crate_kind:?}" )
459456 } ;
@@ -469,7 +466,7 @@ fn main() {
469466 args. splice ( 1 ..1 , miri:: MIRI_DEFAULT_ARGS . iter ( ) . map ( ToString :: to_string) ) ;
470467
471468 // We cannot use `rustc_driver::main` as we want it to use `args` as the CLI arguments.
472- run_compiler_and_exit ( & args, & mut MiriDepCompilerCalls )
469+ return run_compiler_and_exit ( & args, & mut MiriDepCompilerCalls ) ;
473470 }
474471
475472 // Add an ICE bug report hook.
@@ -517,10 +514,9 @@ fn main() {
517514 Some ( BorrowTrackerMethod :: TreeBorrows ( params) ) => {
518515 params. precise_interior_mut = false ;
519516 }
520- _ =>
521- fatal_error ! (
522- "`-Zmiri-tree-borrows` is required before `-Zmiri-tree-borrows-no-precise-interior-mut`"
523- ) ,
517+ _ => fatal_error ! (
518+ "`-Zmiri-tree-borrows` is required before `-Zmiri-tree-borrows-no-precise-interior-mut`"
519+ ) ,
524520 } ;
525521 } else if arg == "-Zmiri-disable-data-race-detector" {
526522 miri_config. data_race_detector = false ;
@@ -542,12 +538,12 @@ fn main() {
542538 "abort" => miri:: IsolatedOp :: Reject ( miri:: RejectOpWith :: Abort ) ,
543539 "hide" => miri:: IsolatedOp :: Reject ( miri:: RejectOpWith :: NoWarning ) ,
544540 "warn" => miri:: IsolatedOp :: Reject ( miri:: RejectOpWith :: Warning ) ,
545- "warn-nobacktrace" =>
546- miri:: IsolatedOp :: Reject ( miri:: RejectOpWith :: WarningWithoutBacktrace ) ,
547- _ =>
548- fatal_error ! (
549- "-Zmiri-isolation-error must be `abort`, `hide`, `warn`, or `warn-nobacktrace`"
550- ) ,
541+ "warn-nobacktrace" => {
542+ miri:: IsolatedOp :: Reject ( miri:: RejectOpWith :: WarningWithoutBacktrace )
543+ }
544+ _ => fatal_error ! (
545+ "-Zmiri-isolation-error must be `abort`, `hide`, `warn`, or `warn-nobacktrace`"
546+ ) ,
551547 } ;
552548 } else if arg == "-Zmiri-ignore-leaks" {
553549 miri_config. ignore_leaks = true ;
0 commit comments