forked from rust-lang/rust
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test that we do not change the offset of ZST tuple fields when unsizing
- Loading branch information
1 parent
e5d85f9
commit e9bc3dd
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
src/test/ui/dynamically-sized-types/dst-tuple-zst-offsets.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |