Skip to content

Commit 01db8b4

Browse files
committed
Auto merge of #1366 - RalfJung:rustc-exit, r=RalfJung
fix exit code on rustc errors Fixes #1352
2 parents 52f5d20 + b128879 commit 01db8b4

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/bin/miri.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,11 @@ fn main() {
259259
rustc_driver::install_ice_hook();
260260
let result = rustc_driver::catch_fatal_errors(move || {
261261
rustc_driver::run_compiler(&rustc_args, &mut MiriCompilerCalls { miri_config }, None, None)
262-
});
263-
std::process::exit(result.is_err() as i32);
262+
})
263+
.and_then(|result| result);
264+
let exit_code = match result {
265+
Ok(()) => rustc_driver::EXIT_SUCCESS,
266+
Err(_) => rustc_driver::EXIT_FAILURE,
267+
};
268+
std::process::exit(exit_code);
264269
}

tests/compile-fail/rustc-error.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Make sure we exit with non-0 status code when the program fails to build.
2+
fn main() {
3+
println("Hello, world!"); //~ ERROR expected function, found macro
4+
}

0 commit comments

Comments
 (0)