diff options
| author | Waffle <waffle.lapkin@gmail.com> | 2021-03-03 01:00:59 +0300 |
|---|---|---|
| committer | Waffle <waffle.lapkin@gmail.com> | 2021-03-03 01:00:59 +0300 |
| commit | 9c4e3af39d5e93b2976afa8062ee5c705ba589c5 (patch) | |
| tree | e4c6fef766b4a58a7a23219d870009addbbb54be | |
| parent | 2f04a793ae0b9331f6d853a971a670c8ea99b0b7 (diff) | |
| download | rust-9c4e3af39d5e93b2976afa8062ee5c705ba589c5.tar.gz rust-9c4e3af39d5e93b2976afa8062ee5c705ba589c5.zip | |
Add test that Vec::spare_capacity_mut doesn't invalidate pointers
| -rw-r--r-- | library/alloc/tests/lib.rs | 1 | ||||
| -rw-r--r-- | library/alloc/tests/vec.rs | 4 |
2 files changed, 5 insertions, 0 deletions
diff --git a/library/alloc/tests/lib.rs b/library/alloc/tests/lib.rs index dd98f806451..d40496bfaab 100644 --- a/library/alloc/tests/lib.rs +++ b/library/alloc/tests/lib.rs @@ -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}; diff --git a/library/alloc/tests/vec.rs b/library/alloc/tests/vec.rs index 2969da58d42..fab45028585 100644 --- a/library/alloc/tests/vec.rs +++ b/library/alloc/tests/vec.rs @@ -1691,6 +1691,10 @@ fn test_stable_pointers() { 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); |
