test that we do not change the offset of ZST tuple fields when unsizing

This commit is contained in:
Erik Desjardins 2020-08-16 20:38:57 -04:00
parent e5d85f917b
commit e9bc3ddb07
1 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,22 @@
// run-pass
#![feature(unsized_tuple_coercion)]
// Check that we do not change the offsets of ZST fields when unsizing
fn scalar_layout() {
let sized: &(u8, [(); 13]) = &(123, [(); 13]);
let unsize: &(u8, [()]) = sized;
assert_eq!(sized.1.as_ptr(), unsize.1.as_ptr());
}
fn scalarpair_layout() {
let sized: &(u8, u16, [(); 13]) = &(123, 456, [(); 13]);
let unsize: &(u8, u16, [()]) = sized;
assert_eq!(sized.2.as_ptr(), unsize.2.as_ptr());
}
pub fn main() {
scalar_layout();
scalarpair_layout();
}