diff --git a/crates/rune-alloc/src/ptr.rs b/crates/rune-alloc/src/ptr.rs index c51978aac..910f56020 100644 --- a/crates/rune-alloc/src/ptr.rs +++ b/crates/rune-alloc/src/ptr.rs @@ -59,21 +59,6 @@ pub const fn invalid_mut(addr: usize) -> *mut T { unsafe { mem::transmute(addr) } } -cfg_if! { - if #[cfg(rune_nightly)] { - #[inline(always)] - pub(crate) const fn wrapping_byte_sub(ptr: *const T, count: usize) -> *const T { - ptr.cast::().wrapping_sub(count).with_metadata_of(ptr) - } - } else { - #[inline(always)] - pub(crate) const fn wrapping_byte_sub(ptr: *const T, count: usize) -> *const T { - // TODO: We need to use metadata. - ptr.cast::().wrapping_sub(count) as *const T - } - } -} - cfg_if! { if #[cfg(rune_nightly)] { #[inline(always)] diff --git a/crates/rune-alloc/src/vec/into_iter.rs b/crates/rune-alloc/src/vec/into_iter.rs index e39555320..a9f1c5093 100644 --- a/crates/rune-alloc/src/vec/into_iter.rs +++ b/crates/rune-alloc/src/vec/into_iter.rs @@ -110,7 +110,7 @@ impl Iterator for IntoIter { } else if T::IS_ZST { // `ptr` has to stay where it is to remain aligned, so we reduce the length by 1 by // reducing the `end`. - self.end = ptr::wrapping_byte_sub(self.end, 1); + self.end = self.end.wrapping_byte_sub(1); // Make up a value of this ZST. Some(unsafe { mem::zeroed() }) @@ -145,7 +145,7 @@ impl DoubleEndedIterator for IntoIter { None } else if T::IS_ZST { // See above for why 'ptr.offset' isn't used - self.end = ptr::wrapping_byte_sub(self.end, 1); + self.end = self.end.wrapping_byte_sub(1); // Make up a value of this ZST. Some(unsafe { mem::zeroed() })