about summary refs log tree commit diff
path: root/library/alloctests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-04-06 23:07:48 +0000
committerbors <bors@rust-lang.org>2025-04-06 23:07:48 +0000
commit25a615bf829b9f6d6f22da537e3851043f92e5f2 (patch)
tree80edbfd363563909d4d3e6fd2eab056b9c919f34 /library/alloctests
parent2fa8b11f0933dae9b4e5d287cc10c989218e8b36 (diff)
parentaadfd810f62e2e07440672cc20a0540c9904d69b (diff)
downloadrust-25a615bf829b9f6d6f22da537e3851043f92e5f2.tar.gz
rust-25a615bf829b9f6d6f22da537e3851043f92e5f2.zip
Auto merge of #138951 - jwnrt:alloc-raw-vec-strict-prov, r=Noratrieb
Replace last `usize` -> `ptr` transmute in `alloc` with strict provenance API

This replaces the `usize -> ptr` transmute in `RawVecInner::new_in` with a strict provenance API (`NonNull::without_provenance`).

The API is changed to take an `Alignment` which encodes the non-null constraint needed for `Unique` and allows us to do the construction safely.

Two internal-only APIs were added to let us avoid UB-checking in this hot code: `Layout::alignment` to get the `Alignment` type directly rather than as a `usize`, and `Unique::from_non_null` to create `Unique` in const context without a transmute.
Diffstat (limited to 'library/alloctests')
-rw-r--r--library/alloctests/lib.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/library/alloctests/lib.rs b/library/alloctests/lib.rs
index 6ce8a6d9ca1..56e60ed4c84 100644
--- a/library/alloctests/lib.rs
+++ b/library/alloctests/lib.rs
@@ -28,6 +28,8 @@
 #![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)]
 #![feature(slice_iter_mut_as_mut_slice)]