From ce36991de363bfadb9c6a76e3b0ea9fca5fc7900 Mon Sep 17 00:00:00 2001 From: Alisa Sireneva Date: Sun, 28 Dec 2025 10:56:11 +0300 Subject: [PATCH] Remove unnecessary use of std::thread::panicking --- src/util.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/util.rs b/src/util.rs index 6464aa6d..75366136 100644 --- a/src/util.rs +++ b/src/util.rs @@ -12,23 +12,20 @@ pub fn map_in_place_2 T>((k, v): (U, &mut T), f: F) { // # Safety // // If the closure panics, we must abort otherwise we could double drop `T` - let promote_panic_to_abort = AbortOnPanic; + let promote_panic_to_abort = AbortOnDrop; ptr::write(v, f(k, ptr::read(v))); - // If we made it here, the calling thread could have already have panicked, in which case - // We know that the closure did not panic, so don't bother checking. + // If we made it here, the operation has already completed, so no need to panic. std::mem::forget(promote_panic_to_abort); } } -struct AbortOnPanic; +struct AbortOnDrop; -impl Drop for AbortOnPanic { +impl Drop for AbortOnDrop { fn drop(&mut self) { - if std::thread::panicking() { - std::process::abort() - } + std::process::abort() } }