diff options
| author | James Wainwright <james.wainwright@lowrisc.org> | 2025-03-25 21:44:54 +0000 |
|---|---|---|
| committer | James Wainwright <james.wainwright@lowrisc.org> | 2025-03-26 21:41:11 +0000 |
| commit | aadfd810f62e2e07440672cc20a0540c9904d69b (patch) | |
| tree | 92b2c41db7be2267fa3e052f1965ba3020ed849b /library/alloc/src/raw_vec/mod.rs | |
| parent | 78e962139020df03174f03da6af91acc5cbb37e3 (diff) | |
| download | rust-aadfd810f62e2e07440672cc20a0540c9904d69b.tar.gz rust-aadfd810f62e2e07440672cc20a0540c9904d69b.zip | |
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.
Diffstat (limited to 'library/alloc/src/raw_vec/mod.rs')
| -rw-r--r-- | library/alloc/src/raw_vec/mod.rs | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/library/alloc/src/raw_vec/mod.rs b/library/alloc/src/raw_vec/mod.rs index 83facd9d932..a989e5b55b3 100644 --- a/library/alloc/src/raw_vec/mod.rs +++ b/library/alloc/src/raw_vec/mod.rs @@ -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 } } |
