Skip to content

Commit

Permalink
rune_alloc: More nightly things being stabilized
Browse files Browse the repository at this point in the history
  • Loading branch information
udoprog committed Oct 25, 2024
1 parent 17202b8 commit 9e5f3c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 0 additions & 2 deletions crates/rune-alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
9 changes: 6 additions & 3 deletions crates/rune-alloc/src/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,13 @@ cfg_if! {
} else {
#[inline(always)]
pub(crate) unsafe fn sub_ptr<T>(from: *const T, to: *const T) -> usize {
let pointee_size = mem::size_of::<T>();
assert!(0 < pointee_size && pointee_size <= isize::MAX as usize);
const {
let pointee_size = mem::size_of::<T>();
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::<T>())
}
}
}
Expand Down

0 comments on commit 9e5f3c3

Please sign in to comment.