diff --git a/crates/rune-alloc/src/lib.rs b/crates/rune-alloc/src/lib.rs index d6722c2d6..c4b8d1cc9 100644 --- a/crates/rune-alloc/src/lib.rs +++ b/crates/rune-alloc/src/lib.rs @@ -44,9 +44,7 @@ #![cfg_attr(rune_nightly, feature(dropck_eyepatch))] #![cfg_attr(rune_nightly, feature(min_specialization))] #![cfg_attr(rune_nightly, feature(ptr_sub_ptr))] -#![cfg_attr(rune_nightly, feature(set_ptr_value))] #![cfg_attr(rune_nightly, feature(slice_range))] -#![cfg_attr(rune_nightly, feature(strict_provenance))] #![cfg_attr(rune_nightly, feature(rustc_attrs))] #![allow(clippy::comparison_chain)] #![allow(clippy::manual_map)] diff --git a/crates/rune-alloc/src/ptr.rs b/crates/rune-alloc/src/ptr.rs index 910f56020..3dff1fc48 100644 --- a/crates/rune-alloc/src/ptr.rs +++ b/crates/rune-alloc/src/ptr.rs @@ -68,10 +68,13 @@ cfg_if! { } else { #[inline(always)] pub(crate) unsafe fn sub_ptr(from: *const T, to: *const T) -> usize { - let pointee_size = mem::size_of::(); - assert!(0 < pointee_size && pointee_size <= isize::MAX as usize); + const { + let pointee_size = mem::size_of::(); + assert!(0 < pointee_size && pointee_size <= isize::MAX as usize); + } + debug_assert!(addr(from) >= addr(to)); - addr(from).wrapping_sub(addr(to)).saturating_div(pointee_size) + addr(from).wrapping_sub(addr(to)).saturating_div(mem::size_of::()) } } }