]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/pass/partially-uninit.rs
Rollup merge of #94145 - ssomers:binary_heap_tests, r=jyn514
[rust.git] / src / tools / miri / tests / pass / partially-uninit.rs
1 use std::mem::{self, MaybeUninit};
2
3 #[repr(C)]
4 #[derive(Copy, Clone, Debug, PartialEq)]
5 struct Demo(bool, u16);
6
7 fn main() {
8     unsafe {
9         // Transmute-round-trip through a type with Scalar layout is lossless.
10         // This is tricky because that 'scalar' is *partially* uninitialized.
11         let x = Demo(true, 3);
12         let y: MaybeUninit<u32> = mem::transmute(x);
13         assert_eq!(x, mem::transmute(y));
14     }
15 }