about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-07-03 12:00:27 +0000
committerbors <bors@rust-lang.org>2023-07-03 12:00:27 +0000
commit89c2596ddedbaa35673d317a90e51bc6c6933ba0 (patch)
tree217bd533985c5934fec327c0b787880a996c7445
parenta8b6ec16676ded3b90ddf44e33fe6dc9b4dfa23e (diff)
parenta68afa2211a4b42bd1094ccbc7500040071b4ded (diff)
downloadrust-89c2596ddedbaa35673d317a90e51bc6c6933ba0.tar.gz
rust-89c2596ddedbaa35673d317a90e51bc6c6933ba0.zip
Auto merge of #2959 - RalfJung:vectest, r=RalfJung
vec tets: ensure pointer is still writeable

Under Tree Borrows, a pointer can become read-only: still allowing reads but not permitting writes any more. So these tests that want to check that pointers remain valid need to do writes to ensure that pointers indeed remain fully valid.
-rw-r--r--src/tools/miri/tests/pass/vec.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/tools/miri/tests/pass/vec.rs b/src/tools/miri/tests/pass/vec.rs
index 048f7d1c351..4ab2bcb7f22 100644
--- a/src/tools/miri/tests/pass/vec.rs
+++ b/src/tools/miri/tests/pass/vec.rs
@@ -100,7 +100,7 @@ fn vec_push_ptr_stable() {
     v.push(0);
     let v0 = unsafe { &mut *(&mut v[0] as *mut _) }; // laundering the lifetime -- we take care that `v` does not reallocate, so that's okay.
     v.push(1);
-    let _val = *v0;
+    *v0 = *v0;
 }
 
 fn vec_extend_ptr_stable() {
@@ -109,23 +109,23 @@ fn vec_extend_ptr_stable() {
     let v0 = unsafe { &mut *(&mut v[0] as *mut _) }; // laundering the lifetime -- we take care that `v` does not reallocate, so that's okay.
     // `slice::Iter` (with `T: Copy`) specialization
     v.extend(&[1]);
-    let _val = *v0;
+    *v0 = *v0;
     // `vec::IntoIter` specialization
     v.extend(vec![2]);
-    let _val = *v0;
+    *v0 = *v0;
     // `TrustedLen` specialization
     v.extend(std::iter::once(3));
-    let _val = *v0;
+    *v0 = *v0;
     // base case
     v.extend(std::iter::once(3).filter(|_| true));
-    let _val = *v0;
+    *v0 = *v0;
 }
 
 fn vec_truncate_ptr_stable() {
     let mut v = vec![0; 10];
     let v0 = unsafe { &mut *(&mut v[0] as *mut _) }; // laundering the lifetime -- we take care that `v` does not reallocate, so that's okay.
     v.truncate(5);
-    let _val = *v0;
+    *v0 = *v0;
 }
 
 fn push_str_ptr_stable() {