Skip to content

Commit d58dd0d

Browse files
committed
use mutable reference
1 parent 483203a commit d58dd0d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/run-pass/vec.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ fn vec_reallocate() -> Vec<u8> {
7474
fn vec_push_ptr_stable() {
7575
let mut v = Vec::with_capacity(10);
7676
v.push(0);
77-
let v0 = unsafe { &*(&v[0] as *const _) }; // laundering the lifetime -- we take care that `v` does not reallocate, so that's okay.
77+
let v0 = unsafe { &mut *(&mut v[0] as *mut _) }; // laundering the lifetime -- we take care that `v` does not reallocate, so that's okay.
7878
v.push(1);
7979
let _val = *v0;
8080
}
8181

8282
fn vec_extend_ptr_stable() {
8383
let mut v = Vec::with_capacity(10);
8484
v.push(0);
85-
let v0 = unsafe { &*(&v[0] as *const _) }; // laundering the lifetime -- we take care that `v` does not reallocate, so that's okay.
85+
let v0 = unsafe { &mut *(&mut v[0] as *mut _) }; // laundering the lifetime -- we take care that `v` does not reallocate, so that's okay.
8686
// `slice::Iter` (with `T: Copy`) specialization
8787
v.extend(&[1]);
8888
let _val = *v0;
@@ -99,7 +99,7 @@ fn vec_extend_ptr_stable() {
9999

100100
fn vec_truncate_ptr_stable() {
101101
let mut v = vec![0; 10];
102-
let v0 = unsafe { &*(&v[0] as *const _) }; // laundering the lifetime -- we take care that `v` does not reallocate, so that's okay.
102+
let v0 = unsafe { &mut *(&mut v[0] as *mut _) }; // laundering the lifetime -- we take care that `v` does not reallocate, so that's okay.
103103
v.truncate(5);
104104
let _val = *v0;
105105
}

0 commit comments

Comments
 (0)