about summary refs log tree commit diff
path: root/src/libcollections
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-06-03 08:32:58 +0000
committerbors <bors@rust-lang.org>2017-06-03 08:32:58 +0000
commitfbb92767801cd289ab0c62c81db172ce104b023e (patch)
treee7a02b6b23307253d91a75166421991494ddd6db /src/libcollections
parent6165203c48420c6f77ea22113eb4ff66931410c3 (diff)
parent42ac31182bab6735cfe9ad77d8f4292fad51bfa8 (diff)
downloadrust-fbb92767801cd289ab0c62c81db172ce104b023e.tar.gz
rust-fbb92767801cd289ab0c62c81db172ce104b023e.zip
Auto merge of #42331 - retep998:standard-relocation-coupon, r=alexcrichton
Improve reallocation in alloc_system on Windows

Fixes https://github.com/rust-lang/rust/issues/42025
Diffstat (limited to 'src/libcollections')
-rw-r--r--src/libcollections/tests/lib.rs2
-rw-r--r--src/libcollections/tests/vec.rs15
2 files changed, 17 insertions, 0 deletions
diff --git a/src/libcollections/tests/lib.rs b/src/libcollections/tests/lib.rs
index 8af8786994e..5f5217b73c2 100644
--- a/src/libcollections/tests/lib.rs
+++ b/src/libcollections/tests/lib.rs
@@ -10,6 +10,7 @@
 
 #![deny(warnings)]
 
+#![feature(attr_literals)]
 #![feature(box_syntax)]
 #![feature(inclusive_range_syntax)]
 #![feature(collection_placement)]
@@ -20,6 +21,7 @@
 #![feature(pattern)]
 #![feature(placement_in_syntax)]
 #![feature(rand)]
+#![feature(repr_align)]
 #![feature(slice_rotate)]
 #![feature(splice)]
 #![feature(str_escape)]
diff --git a/src/libcollections/tests/vec.rs b/src/libcollections/tests/vec.rs
index 29f18274962..fdf453b39cf 100644
--- a/src/libcollections/tests/vec.rs
+++ b/src/libcollections/tests/vec.rs
@@ -781,3 +781,18 @@ fn from_into_inner() {
     assert_eq!(vec, [2, 3]);
     assert!(ptr != vec.as_ptr());
 }
+
+#[test]
+fn overaligned_allocations() {
+    #[repr(align(256))]
+    struct Foo(usize);
+    let mut v = vec![Foo(273)];
+    for i in 0..0x1000 {
+        v.reserve_exact(i);
+        assert!(v[0].0 == 273);
+        assert!(v.as_ptr() as usize & 0xff == 0);
+        v.shrink_to_fit();
+        assert!(v[0].0 == 273);
+        assert!(v.as_ptr() as usize & 0xff == 0);
+    }
+}