Skip to content

Commit e9bc3dd

Browse files
test that we do not change the offset of ZST tuple fields when unsizing
1 parent e5d85f9 commit e9bc3dd

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
}

0 commit comments

Comments
 (0)