diff --git a/rust-version b/rust-version index 3007bc068a..c84d46fa51 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -634770c0a7f8598164ab825cfe419cc8b03c36e5 +f262ca12aac76152c4b46cefcf8300f0249a5eb2 diff --git a/tests/run-pass/partially-uninit.rs b/tests/run-pass/partially-uninit.rs new file mode 100644 index 0000000000..1de5308428 --- /dev/null +++ b/tests/run-pass/partially-uninit.rs @@ -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 = mem::transmute(x); + assert_eq!(x, mem::transmute(y)); +} }