mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-16 22:16:53 +00:00
Swap usize -> ptr transmute for strict_pov API
Removes some unsafety and reduces the number of `usize` -> `ptr` transmutes which might be helpful for CHERI-like targets in the future.
This commit is contained in:
parent
78e9621390
commit
aadfd810f6
@ -410,8 +410,7 @@ unsafe impl<#[may_dangle] T, A: Allocator> Drop for RawVec<T, A> {
|
||||
impl<A: Allocator> RawVecInner<A> {
|
||||
#[inline]
|
||||
const fn new_in(alloc: A, align: Alignment) -> Self {
|
||||
// SAFETY: `Alignment` is non-zero.
|
||||
let ptr = unsafe { core::mem::transmute(align) };
|
||||
let ptr = Unique::from_non_null(NonNull::without_provenance(align.as_nonzero()));
|
||||
// `cap: 0` means "unallocated". zero-sized types are ignored.
|
||||
Self { ptr, cap: ZERO_CAP, alloc }
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
#![feature(iter_next_chunk)]
|
||||
#![feature(maybe_uninit_slice)]
|
||||
#![feature(maybe_uninit_uninit_array_transpose)]
|
||||
#![feature(nonnull_provenance)]
|
||||
#![feature(ptr_alignment_type)]
|
||||
#![feature(ptr_internals)]
|
||||
#![feature(sized_type_properties)]
|
||||
|
Loading…
Reference in New Issue
Block a user