Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
634770c0a7f8598164ab825cfe419cc8b03c36e5
f262ca12aac76152c4b46cefcf8300f0249a5eb2
15 changes: 15 additions & 0 deletions tests/run-pass/partially-uninit.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// compile-flags: -Zmiri-check-number-validity

use std::mem::{self, MaybeUninit};

#[repr(C)]
#[derive(Copy, Clone, Debug, PartialEq)]
struct Demo(bool, u16);

fn main() { unsafe {
// Transmute-round-trip through a type with Scalar layout is lossless.
// This is tricky because that 'scalar' is *partially* uninitialized.
let x = Demo(true, 3);
let y: MaybeUninit<u32> = mem::transmute(x);
assert_eq!(x, mem::transmute(y));
} }