]> git.nega.tv - josh/narcissus/commitdiff
Always panic when failing to drop a `ManualArc`
authorJoshua Simmons <josh@nega.tv>
Sat, 8 Oct 2022 11:00:54 +0000 (13:00 +0200)
committerJoshua Simmons <josh@nega.tv>
Sat, 8 Oct 2022 11:00:54 +0000 (13:00 +0200)
Hopefully the optimiser can nuke the branch most of the time.

narcissus-core/src/manual_arc.rs

index 3041ebcb64a1e07555dde06b9b02b5a3f88d50a7..4554376250469454df73e2f5c20830edd05e58f3 100644 (file)
@@ -127,14 +127,12 @@ impl<T> Clone for ManualArc<T> {
     }
 }
 
-#[cfg(debug_assertions)]
 impl<T> Drop for ManualArc<T> {
     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");
+            }
         }
     }
 }