From 9e553108c748b117afeee22633e2944b2363af40 Mon Sep 17 00:00:00 2001 From: shourya5 Date: Tue, 9 Aug 2022 22:55:57 +0530 Subject: [PATCH 1/2] replaced resume_unwind with process::exit to fix bootstrap panic when running x fmt --check. running x fmt --check --- src/bootstrap/lib.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index f84de73297acb..7b720e6ee9ecf 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -1632,13 +1632,10 @@ fn chmod(_path: &Path, _perms: u32) {} /// If the test is running and code is an error code, it will cause a panic. fn detail_exit(code: i32) -> ! { // Successful exit - if code == 0 { - std::process::exit(0); - } - if cfg!(test) { + if cfg!(test) && code != 0 { panic!("status code: {}", code); } else { - std::panic::resume_unwind(Box::new(code)); + std::process::exit(code); } } From 0d8bcc3dc5c2b9bbe19a65b82e4391bd07d52dff Mon Sep 17 00:00:00 2001 From: shourya5 Date: Wed, 10 Aug 2022 00:55:07 +0530 Subject: [PATCH 2/2] added some comments --- src/bootstrap/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 7b720e6ee9ecf..a242243aaafa9 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -1631,10 +1631,11 @@ fn chmod(_path: &Path, _perms: u32) {} /// If code is not 0 (successful exit status), exit status is 101 (rust's default error code.) /// If the test is running and code is an error code, it will cause a panic. fn detail_exit(code: i32) -> ! { - // Successful exit + // if in test and code is an error code, panic with staus code provided if cfg!(test) && code != 0 { panic!("status code: {}", code); } else { + //otherwise,exit with provided status code std::process::exit(code); } }