about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-05-16 02:37:23 +0200
committerGitHub <noreply@github.com>2020-05-16 02:37:23 +0200
commitb381ea8abb278e42c3f157440fd1bd2af6c7782d (patch)
tree432ebcce378ee34af39b4550cd7515ff6c654adc /src
parentb0490cc80d1a0747f2a91d1200ed31b8c77d45bc (diff)
parent30822733f080fdee42409a6e05c6b8c7adfbbe7f (diff)
downloadrust-b381ea8abb278e42c3f157440fd1bd2af6c7782d.tar.gz
rust-b381ea8abb278e42c3f157440fd1bd2af6c7782d.zip
Rollup merge of #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.
Diffstat (limited to 'src')
-rw-r--r--src/driver.rs4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/driver.rs b/src/driver.rs
index 2c699998ea9..1ce0300f239 100644
--- a/src/driver.rs
+++ b/src/driver.rs
@@ -296,7 +296,7 @@ pub fn main() {
     rustc_driver::init_rustc_env_logger();
     lazy_static::initialize(&ICE_HOOK);
     exit(
-        rustc_driver::catch_fatal_errors(move || {
+        rustc_driver::catch_with_exit_code(move || {
             let mut orig_args: Vec<String> = env::args().collect();
 
             if orig_args.iter().any(|a| a == "--version" || a == "-V") {
@@ -411,7 +411,5 @@ pub fn main() {
                 if clippy_enabled { &mut clippy } else { &mut default };
             rustc_driver::run_compiler(&args, callbacks, None, None)
         })
-        .and_then(|result| result)
-        .is_err() as i32,
     )
 }