diff --git a/rust/kernel/ptr/projection.rs b/rust/kernel/ptr/projection.rs index 441bc1b83c3f..575e936f6d29 100644 --- a/rust/kernel/ptr/projection.rs +++ b/rust/kernel/ptr/projection.rs @@ -45,7 +45,10 @@ pub unsafe trait ProjectIndex: Sized { /// Returns an index-projected pointer; fail the build if it cannot be proved to be in bounds. #[inline(always)] fn build_index(self, slice: *mut T) -> *mut Self::Output { - Self::get(self, slice).unwrap_or_else(|| build_error!()) + match Self::get(self, slice) { + Some(v) => v, + None => build_error!(), + } } }