diff options
| author | Lee Bousfield <ljbousfield@gmail.com> | 2017-07-08 13:02:52 -0400 |
|---|---|---|
| committer | Lee Bousfield <ljbousfield@gmail.com> | 2017-07-08 13:02:52 -0400 |
| commit | da81a33b05c216f0958e0110a1e059204d34ed85 (patch) | |
| tree | 8f394cf0daba07aeb11b765829706538b297cfbc | |
| parent | afed75a2d9b7e049dc26be7af3cb72297274d343 (diff) | |
| download | rust-da81a33b05c216f0958e0110a1e059204d34ed85.tar.gz rust-da81a33b05c216f0958e0110a1e059204d34ed85.zip | |
Box large array to avoid blowing the stack
| -rw-r--r-- | src/test/run-pass/align-struct.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/test/run-pass/align-struct.rs b/src/test/run-pass/align-struct.rs index 19c4c643552..59d05399167 100644 --- a/src/test/run-pass/align-struct.rs +++ b/src/test/run-pass/align-struct.rs @@ -9,6 +9,7 @@ // except according to those terms. #![feature(attr_literals)] #![feature(repr_align)] +#![feature(box_syntax)] use std::mem; @@ -201,13 +202,14 @@ pub fn main() { assert_eq!(mem::size_of_val(&a), 16); assert!(is_aligned_to(&a, 16)); - let mut arr = [0; 0x10000]; - arr[0] = 132; - let large = AlignLarge { - stuff: arr, + let mut large = box AlignLarge { + stuff: [0; 0x10000], }; + large.stuff[0] = 132; + *large.stuff.last_mut().unwrap() = 102; assert_eq!(large.stuff[0], 132); + assert_eq!(large.stuff.last(), Some(&102)); assert_eq!(mem::align_of::<AlignLarge>(), 0x10000); - assert_eq!(mem::align_of_val(&large), 0x10000); - assert!(is_aligned_to(&large, 0x10000)); + assert_eq!(mem::align_of_val(&*large), 0x10000); + assert!(is_aligned_to(&*large, 0x10000)); } |
