Skip to content

Commit 74a0bd1

Browse files
authored
Rollup merge of #106950 - the8472:fix-splice-miri, r=cuviper
Don't do pointer arithmetic on pointers to deallocated memory vec::Splice can invalidate the slice::Iter inside vec::Drain. So we replace them with dangling pointers which, unlike ones to deallocated memory, are allowed. Fixes miri test failures. Fixes #2759
2 parents 3c9d6ba + 22fcfb2 commit 74a0bd1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tests/pass/vec.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ fn reverse() {
162162
assert!(v[0].0 == 49);
163163
}
164164

165+
fn miri_issue_2759() {
166+
let mut input = "1".to_string();
167+
input.replace_range(0..0, "0");
168+
}
169+
165170
fn main() {
166171
assert_eq!(vec_reallocate().len(), 5);
167172

@@ -191,4 +196,5 @@ fn main() {
191196
swap();
192197
swap_remove();
193198
reverse();
199+
miri_issue_2759();
194200
}

0 commit comments

Comments
 (0)