Skip to content

Commit 9c4e3af

Browse files
committed
Add test that Vec::spare_capacity_mut doesn't invalidate pointers
1 parent 2f04a79 commit 9c4e3af

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

library/alloc/tests/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#![feature(vecdeque_binary_search)]
2222
#![feature(slice_group_by)]
2323
#![feature(vec_extend_from_within)]
24+
#![feature(vec_spare_capacity)]
2425

2526
use std::collections::hash_map::DefaultHasher;
2627
use std::hash::{Hash, Hasher};

library/alloc/tests/vec.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,6 +1691,10 @@ fn test_stable_pointers() {
16911691
next_then_drop(v.splice(5..6, vec![1; 10].into_iter().filter(|_| true))); // lower bound not exact
16921692
assert_eq!(*v0, 13);
16931693

1694+
// spare_capacity_mut
1695+
v.spare_capacity_mut();
1696+
assert_eq!(*v0, 13);
1697+
16941698
// Smoke test that would fire even outside Miri if an actual relocation happened.
16951699
*v0 -= 13;
16961700
assert_eq!(v[0], 0);

0 commit comments

Comments
 (0)