about summary refs log tree commit diff
path: root/library/alloc/tests/vec.rs
diff options
context:
space:
mode:
authorjoboet <jonasboettiger@icloud.com>2025-01-10 18:48:48 +0100
committerjoboet <jonasboettiger@icloud.com>2025-01-10 18:48:48 +0100
commit4426e9a3c260e329f51c94e2b231f72574271f0b (patch)
tree5e951ec52413e97fde47b94bc51089ae20378dcc /library/alloc/tests/vec.rs
parent336209eef13882bd1e211b24779584cb7ef911eb (diff)
downloadrust-4426e9a3c260e329f51c94e2b231f72574271f0b.tar.gz
rust-4426e9a3c260e329f51c94e2b231f72574271f0b.zip
alloc: remove unsound `IsZero` for raw pointers
Fixes #135338
Diffstat (limited to 'library/alloc/tests/vec.rs')
-rw-r--r--library/alloc/tests/vec.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/library/alloc/tests/vec.rs b/library/alloc/tests/vec.rs
index 2e654d3d1ff..b24daec2968 100644
--- a/library/alloc/tests/vec.rs
+++ b/library/alloc/tests/vec.rs
@@ -2742,3 +2742,13 @@ fn max_swap_remove() {
     let mut v = vec![0];
     v.swap_remove(usize::MAX);
 }
+
+// Regression test for #135338
+#[test]
+fn vec_null_ptr_roundtrip() {
+    let ptr = std::ptr::from_ref(&42);
+    let zero = ptr.with_addr(0);
+    let roundtripped = vec![zero; 1].pop().unwrap();
+    let new = roundtripped.with_addr(ptr.addr());
+    unsafe { new.read() };
+}