From da81a33b05c216f0958e0110a1e059204d34ed85 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Sat, 8 Jul 2017 13:02:52 -0400 Subject: [PATCH] Box large array to avoid blowing the stack --- src/test/run-pass/align-struct.rs | 14 ++++++++------ 1 file 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::(), 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)); }