Skip to content

Commit b381ea8

Browse files
authored
Rollup merge of rust-lang#72090 - RalfJung:rustc_driver-exit-code, r=oli-obk
rustc_driver: factor out computing the exit code In a recent Miri PR I [added a convenience wrapper](https://github.com/rust-lang/miri/pull/1405/files#diff-c3d602c5c8035a16699ce9c015bfeceaR125) around `catch_fatal_errors` and `run_compiler` that @oli-obk suggested I could upstream. However, after seeing what could be shared between `rustc_driver::main`, clippy and Miri, really the only thing I found is computing the exit code -- so that's what this PR does. What prevents using the Miri convenience function in `rustc_driver::main` and clippy is that they do extra work inside `catch_fatal_errors`, and while I could abstract that away, clippy actually *computes the callbacks* inside there, and I fond no good way to abstract that and thus gave up. Maybe the clippy thing could be moved out, I am not sure if it ever can actually raise a `FatalErrorMarker` -- someone more knowledgeable in clippy would have to do that.
2 parents b0490cc + 3082273 commit b381ea8

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/driver.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ pub fn main() {
296296
rustc_driver::init_rustc_env_logger();
297297
lazy_static::initialize(&ICE_HOOK);
298298
exit(
299-
rustc_driver::catch_fatal_errors(move || {
299+
rustc_driver::catch_with_exit_code(move || {
300300
let mut orig_args: Vec<String> = env::args().collect();
301301

302302
if orig_args.iter().any(|a| a == "--version" || a == "-V") {
@@ -411,7 +411,5 @@ pub fn main() {
411411
if clippy_enabled { &mut clippy } else { &mut default };
412412
rustc_driver::run_compiler(&args, callbacks, None, None)
413413
})
414-
.and_then(|result| result)
415-
.is_err() as i32,
416414
)
417415
}

0 commit comments

Comments
 (0)