1 // Issue 36278: On an unsized struct with >1 level of nontrivial 2 // nesting, ensure we are computing dynamic size of prefix correctly. 3 4 use std::mem; 5 6 const SZ: usize = 100; 7 struct P<T: ?Sized>([u8; SZ], T); 8 9 type Ack<T> = P<P<T>>; 10 main()11fn main() { 12 let size_of_sized; 13 let size_of_unsized; 14 let x: Box<Ack<[u8; 0]>> = Box::new(P([0; SZ], P([0; SZ], [0; 0]))); 15 size_of_sized = mem::size_of_val::<Ack<_>>(&x); 16 let align_of_sized = mem::align_of_val::<Ack<_>>(&x); 17 let y: Box<Ack<[u8]>> = x; 18 size_of_unsized = mem::size_of_val::<Ack<_>>(&y); 19 assert_eq!(size_of_sized, size_of_unsized); 20 assert_eq!(align_of_sized, 1); 21 assert_eq!(mem::align_of_val::<Ack<_>>(&y), 1); 22 } 23