Skip to content

Commit

Permalink
test that we do not change the offset of ZST tuple fields when unsizing
Browse files Browse the repository at this point in the history
  • Loading branch information
erikdesjardins committed Aug 30, 2020
1 parent e5d85f9 commit e9bc3dd
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/test/ui/dynamically-sized-types/dst-tuple-zst-offsets.rs
@@ -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();
}

0 comments on commit e9bc3dd

Please sign in to comment.