about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJakub Beránek <berykubik@gmail.com>2023-10-11 19:02:00 +0200
committerJakub Beránek <berykubik@gmail.com>2023-10-17 21:38:46 +0200
commitb153a0182875b420bdecb19c81be0731e2e2f6b4 (patch)
tree5c546c7c6c834e62ee98a15f43839e964e2cfed2
parent03d48dd735b18593f9e361f2156efae7bb551236 (diff)
downloadrust-b153a0182875b420bdecb19c81be0731e2e2f6b4.tar.gz
rust-b153a0182875b420bdecb19c81be0731e2e2f6b4.zip
Simplify BehaviorOnFailure
-rw-r--r--src/bootstrap/src/lib.rs19
-rw-r--r--src/bootstrap/src/utils/exec.rs12
2 files changed, 17 insertions, 14 deletions
diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs
index 6f9a9beb331..701c8df11a7 100644
--- a/src/bootstrap/src/lib.rs
+++ b/src/bootstrap/src/lib.rs
@@ -997,19 +997,18 @@ impl Build {
         match result {
             Ok(_) => true,
             Err(_) => {
-                if let Some(failure_behavior) = command.failure_behavior {
-                    match failure_behavior {
-                        BehaviorOnFailure::DelayFail => {
-                            let mut failures = self.delayed_failures.borrow_mut();
-                            failures.push(format!("{command:?}"));
-                        }
-                        BehaviorOnFailure::Exit => {
+                match command.failure_behavior {
+                    BehaviorOnFailure::DelayFail => {
+                        if self.fail_fast {
                             exit!(1);
                         }
+
+                        let mut failures = self.delayed_failures.borrow_mut();
+                        failures.push(format!("{command:?}"));
+                    }
+                    BehaviorOnFailure::Exit => {
+                        exit!(1);
                     }
-                }
-                if self.fail_fast {
-                    exit!(1);
                 }
                 false
             }
diff --git a/src/bootstrap/src/utils/exec.rs b/src/bootstrap/src/utils/exec.rs
index f244f5152be..1b9e5cb174a 100644
--- a/src/bootstrap/src/utils/exec.rs
+++ b/src/bootstrap/src/utils/exec.rs
@@ -25,16 +25,16 @@ pub enum OutputMode {
 #[derive(Debug)]
 pub struct BootstrapCommand<'a> {
     pub command: &'a mut Command,
-    pub failure_behavior: Option<BehaviorOnFailure>,
+    pub failure_behavior: BehaviorOnFailure,
     pub output_mode: OutputMode,
 }
 
 impl<'a> BootstrapCommand<'a> {
     pub fn delay_failure(self) -> Self {
-        Self { failure_behavior: Some(BehaviorOnFailure::DelayFail), ..self }
+        Self { failure_behavior: BehaviorOnFailure::DelayFail, ..self }
     }
     pub fn fail_fast(self) -> Self {
-        Self { failure_behavior: Some(BehaviorOnFailure::Exit), ..self }
+        Self { failure_behavior: BehaviorOnFailure::Exit, ..self }
     }
     pub fn output_mode(self, output_mode: OutputMode) -> Self {
         Self { output_mode, ..self }
@@ -43,6 +43,10 @@ impl<'a> BootstrapCommand<'a> {
 
 impl<'a> From<&'a mut Command> for BootstrapCommand<'a> {
     fn from(command: &'a mut Command) -> Self {
-        Self { command, failure_behavior: None, output_mode: OutputMode::SuppressOnSuccess }
+        Self {
+            command,
+            failure_behavior: BehaviorOnFailure::Exit,
+            output_mode: OutputMode::SuppressOnSuccess,
+        }
     }
 }