diff --git a/src/lib.rs b/src/lib.rs index 4fc1191738482d8ae15d5118612e344b13c1a40a..dee238203e5441c20a5208b80261464cfcef0ef1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,7 @@ #![no_std] use core::cell::Cell; +use core::hint; use core::marker::PhantomPinned; use core::mem::{self, MaybeUninit}; use core::ops::{Deref, DerefMut}; @@ -164,7 +165,10 @@ pub struct Xrc<T: ?Sized> { impl<T: ?Sized> Drop for Xrc<T> { fn drop(&mut self) { let Some(root) = Self::inner(self).root.get() else { - unreachable!("missing root"); + debug_assert!(false, "missing root"); + unsafe { + hint::unreachable_unchecked(); + } }; let state_ref = unsafe { &(*root.as_ptr()).state }; @@ -187,7 +191,10 @@ impl<T> Clone for Xrc<T> { fn clone(&self) -> Self { let root = Self::inner(self).root.get(); let Some(root) = root else { - unreachable!("missing root"); + debug_assert!(false, "missing root"); + unsafe { + hint::unreachable_unchecked(); + } }; let state_ref = unsafe { &(*root.as_ptr()).state }; @@ -218,7 +225,10 @@ impl<T: ?Sized> Xrc<T> { { let source = Self::inner(&this); let Some(source_root) = source.root.get() else { - unreachable!("missing root"); + debug_assert!(false, "missing root"); + unsafe { + hint::unreachable_unchecked(); + } }; let target = f(source);