]> git.proxmox.com Git - rustc.git/blob - src/test/ui/dynamically-sized-types/dst-tuple-zst-offsets.rs
New upstream version 1.48.0~beta.8+dfsg1
[rustc.git] / src / test / ui / dynamically-sized-types / dst-tuple-zst-offsets.rs
1 // run-pass
2
3 #![feature(unsized_tuple_coercion)]
4
5 // Check that we do not change the offsets of ZST fields when unsizing
6
7 fn scalar_layout() {
8 let sized: &(u8, [(); 13]) = &(123, [(); 13]);
9 let unsize: &(u8, [()]) = sized;
10 assert_eq!(sized.1.as_ptr(), unsize.1.as_ptr());
11 }
12
13 fn scalarpair_layout() {
14 let sized: &(u8, u16, [(); 13]) = &(123, 456, [(); 13]);
15 let unsize: &(u8, u16, [()]) = sized;
16 assert_eq!(sized.2.as_ptr(), unsize.2.as_ptr());
17 }
18
19 pub fn main() {
20 scalar_layout();
21 scalarpair_layout();
22 }