From 90a190656dcdc5f8344d057fc9918df3a4c38b33 Mon Sep 17 00:00:00 2001 From: Joshua Simmons Date: Sat, 8 Oct 2022 13:00:54 +0200 Subject: [PATCH] Always panic when failing to drop a `ManualArc` Hopefully the optimiser can nuke the branch most of the time. --- narcissus-core/src/manual_arc.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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"); + } } } } -- 2.49.0