diff --git a/src/r3/src/kernel/task/readyqueue.rs b/src/r3/src/kernel/task/readyqueue.rs index 3cbcdb07e2..fe22d7edcd 100644 --- a/src/r3/src/kernel/task/readyqueue.rs +++ b/src/r3/src/kernel/task/readyqueue.rs @@ -9,7 +9,6 @@ use crate::{ }, utils::{ intrusive_list::{Ident, ListAccessorCell, Static, StaticLink, StaticListHead}, - unwrap::UnwrapUnchecked, Init, PrioBitmap, }, }; diff --git a/src/r3/src/kernel/wait.rs b/src/r3/src/kernel/wait.rs index 31288c3942..303c3db3f6 100644 --- a/src/r3/src/kernel/wait.rs +++ b/src/r3/src/kernel/wait.rs @@ -10,7 +10,6 @@ use super::{ use crate::utils::{ intrusive_list::{self, HandleInconsistencyUnchecked, ListAccessorCell}, - unwrap::UnwrapUnchecked, Init, }; diff --git a/src/r3/src/lib.rs b/src/r3/src/lib.rs index 993d976d11..1946dfe190 100644 --- a/src/r3/src/lib.rs +++ b/src/r3/src/lib.rs @@ -16,6 +16,7 @@ #![feature(set_ptr_value)] // `<*const T>::set_ptr_value` #![feature(raw_ref_macros)] #![feature(or_patterns)] +#![feature(option_result_unwrap_unchecked)] // `Option::unwrap_unchecked` #![feature(cfg_target_has_atomic)] // `#[cfg(target_has_atomic_load_store)]` #![feature(unsafe_block_in_unsafe_fn)] // `unsafe fn` doesn't imply `unsafe {}` #![feature(never_type)] // `!` diff --git a/src/r3/src/utils.rs b/src/r3/src/utils.rs index f233293b3b..a62629b7e5 100644 --- a/src/r3/src/utils.rs +++ b/src/r3/src/utils.rs @@ -29,7 +29,6 @@ pub mod mem; pub(crate) mod pin; mod prio_bitmap; mod rawcell; -pub(crate) mod unwrap; #[macro_use] mod vec; #[macro_use] diff --git a/src/r3/src/utils/unwrap.rs b/src/r3/src/utils/unwrap.rs deleted file mode 100644 index ef0e740054..0000000000 --- a/src/r3/src/utils/unwrap.rs +++ /dev/null @@ -1,52 +0,0 @@ -#[cfg(not(debug_assertions))] -use core::hint::unreachable_unchecked; - -pub trait UnwrapUnchecked { - type Output; - - /// Unwrap `self`, assuming `self` is unwrappable. - /// - /// This method may panic instead if `self` is not unwrappable and debug - /// assertions are enabled. - /// - /// # Safety - /// - /// `self` must be `Ok(_)` or `Some(_)`. - unsafe fn unwrap_unchecked(self) -> Self::Output; -} - -impl UnwrapUnchecked for Option { - type Output = T; - - #[inline] - #[track_caller] - #[cfg(debug_assertions)] - unsafe fn unwrap_unchecked(self) -> Self::Output { - self.unwrap() - } - - #[inline] - #[cfg(not(debug_assertions))] - unsafe fn unwrap_unchecked(self) -> Self::Output { - // Safety: `self` is `Some(_)` - self.unwrap_or_else(|| unsafe { unreachable_unchecked() }) - } -} - -impl UnwrapUnchecked for Result { - type Output = T; - - #[inline] - #[track_caller] - #[cfg(debug_assertions)] - unsafe fn unwrap_unchecked(self) -> Self::Output { - self.unwrap() - } - - #[inline] - #[cfg(not(debug_assertions))] - unsafe fn unwrap_unchecked(self) -> Self::Output { - // Safety: `self` is `Some(_)` - self.unwrap_or_else(|_| unsafe { unreachable_unchecked() }) - } -}