From: Joshua Simmons Date: Sat, 8 Oct 2022 11:00:54 +0000 (+0200) Subject: Always panic when failing to drop a `ManualArc` X-Git-Url: https://git.nega.tv//gitweb.cgi?a=commitdiff_plain;h=90a190656dcdc5f8344d057fc9918df3a4c38b33;p=josh%2Fnarcissus Always panic when failing to drop a `ManualArc` Hopefully the optimiser can nuke the branch most of the time. --- diff --git a/narcissus-core/src/manual_arc.rs b/narcissus-core/src/manual_arc.rs index 3041ebc..4554376 100644 --- a/narcissus-core/src/manual_arc.rs +++ b/narcissus-core/src/manual_arc.rs @@ -127,14 +127,12 @@ impl Clone for ManualArc { } } -#[cfg(debug_assertions)] impl Drop for ManualArc { fn drop(&mut self) { - if !std::thread::panicking() { - assert!( - self.ptr.is_none(), - "must release manually by calling `ManualArc::release` before value is dropped" - ); + if self.ptr.is_some() { + if !std::thread::panicking() { + panic!("must call `ManualArc::release` before value is dropped"); + } } } }