From 65d499f302fe3482207147d2c70892c12030b442 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Tue, 28 Jan 2025 11:26:38 -0500 Subject: [PATCH] Clean up `naga`'s `xtask` a bit (#7014) --- naga/xtask/src/main.rs | 1 - naga/xtask/src/result.rs | 33 --------------------------------- naga/xtask/src/validate.rs | 2 +- 3 files changed, 1 insertion(+), 35 deletions(-) delete mode 100644 naga/xtask/src/result.rs diff --git a/naga/xtask/src/main.rs b/naga/xtask/src/main.rs index aed7f48c71..76ca91383d 100644 --- a/naga/xtask/src/main.rs +++ b/naga/xtask/src/main.rs @@ -16,7 +16,6 @@ mod glob; mod jobserver; mod path; mod process; -mod result; mod validate; fn main() -> ExitCode { diff --git a/naga/xtask/src/result.rs b/naga/xtask/src/result.rs deleted file mode 100644 index e351ebf4cf..0000000000 --- a/naga/xtask/src/result.rs +++ /dev/null @@ -1,33 +0,0 @@ -#[derive(Clone, Copy, Debug)] -pub(crate) enum ErrorStatus { - NoFailuresFound, - OneOrMoreFailuresFound, -} - -impl ErrorStatus { - pub(crate) fn merge(self, other: Self) -> Self { - match (self, other) { - (Self::OneOrMoreFailuresFound, _) | (_, Self::OneOrMoreFailuresFound) => { - Self::OneOrMoreFailuresFound - } - (Self::NoFailuresFound, Self::NoFailuresFound) => Self::NoFailuresFound, - } - } -} - -pub(crate) trait LogIfError { - fn log_if_err_found(self, status: &mut ErrorStatus) -> Option; -} - -impl LogIfError for anyhow::Result { - fn log_if_err_found(self, status: &mut ErrorStatus) -> Option { - match self { - Ok(t) => Some(t), - Err(e) => { - log::error!("{e:?}"); - *status = status.merge(ErrorStatus::OneOrMoreFailuresFound); - None - } - } - } -} diff --git a/naga/xtask/src/validate.rs b/naga/xtask/src/validate.rs index 2006aa83ae..be6a900630 100644 --- a/naga/xtask/src/validate.rs +++ b/naga/xtask/src/validate.rs @@ -26,7 +26,7 @@ pub(crate) fn validate(cmd: ValidateSubcommand) -> anyhow::Result<()> { for job in jobs { let tx_results = tx_results.clone(); crate::jobserver::start_job_thread(move || { - let result = match std::panic::catch_unwind(|| job()) { + let result = match std::panic::catch_unwind(job) { Ok(result) => result, Err(payload) => Err(match payload.downcast_ref::<&str>() { Some(message) => {