Add test that Vec::spare_capacity_mut doesn't invalidate pointers

This commit is contained in:
Waffle 2021-03-03 01:00:59 +03:00
parent 2f04a793ae
commit 9c4e3af39d
2 changed files with 5 additions and 0 deletions

View File

@ -21,6 +21,7 @@
#![feature(vecdeque_binary_search)]
#![feature(slice_group_by)]
#![feature(vec_extend_from_within)]
#![feature(vec_spare_capacity)]
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};

View File

@ -1691,6 +1691,10 @@ fn next_then_drop<I: Iterator>(mut i: I) {
next_then_drop(v.splice(5..6, vec![1; 10].into_iter().filter(|_| true))); // lower bound not exact
assert_eq!(*v0, 13);
// spare_capacity_mut
v.spare_capacity_mut();
assert_eq!(*v0, 13);
// Smoke test that would fire even outside Miri if an actual relocation happened.
*v0 -= 13;
assert_eq!(v[0], 0);