Skip to content

Commit 89c2596

Browse files
committed
Auto merge of rust-lang#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.
2 parents a8b6ec1 + a68afa2 commit 89c2596

File tree

1 file changed

+6
-6
lines changed
  • src/tools/miri/tests/pass

1 file changed

+6
-6
lines changed

src/tools/miri/tests/pass/vec.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ fn vec_push_ptr_stable() {
100100
v.push(0);
101101
let v0 = unsafe { &mut *(&mut v[0] as *mut _) }; // laundering the lifetime -- we take care that `v` does not reallocate, so that's okay.
102102
v.push(1);
103-
let _val = *v0;
103+
*v0 = *v0;
104104
}
105105

106106
fn vec_extend_ptr_stable() {
@@ -109,23 +109,23 @@ fn vec_extend_ptr_stable() {
109109
let v0 = unsafe { &mut *(&mut v[0] as *mut _) }; // laundering the lifetime -- we take care that `v` does not reallocate, so that's okay.
110110
// `slice::Iter` (with `T: Copy`) specialization
111111
v.extend(&[1]);
112-
let _val = *v0;
112+
*v0 = *v0;
113113
// `vec::IntoIter` specialization
114114
v.extend(vec![2]);
115-
let _val = *v0;
115+
*v0 = *v0;
116116
// `TrustedLen` specialization
117117
v.extend(std::iter::once(3));
118-
let _val = *v0;
118+
*v0 = *v0;
119119
// base case
120120
v.extend(std::iter::once(3).filter(|_| true));
121-
let _val = *v0;
121+
*v0 = *v0;
122122
}
123123

124124
fn vec_truncate_ptr_stable() {
125125
let mut v = vec![0; 10];
126126
let v0 = unsafe { &mut *(&mut v[0] as *mut _) }; // laundering the lifetime -- we take care that `v` does not reallocate, so that's okay.
127127
v.truncate(5);
128-
let _val = *v0;
128+
*v0 = *v0;
129129
}
130130

131131
fn push_str_ptr_stable() {

0 commit comments

Comments
 (0)