diff --git a/src/tools/miri/tests/fail/uninit/padding-enum.rs b/src/tools/miri/tests/fail/uninit/padding-enum.rs index 4ba059caf8b18..e1a16bea23ccb 100644 --- a/src/tools/miri/tests/fail/uninit/padding-enum.rs +++ b/src/tools/miri/tests/fail/uninit/padding-enum.rs @@ -18,9 +18,10 @@ fn main() { // Turns out the discriminant is (currently) stored // in the 1st pointer, so the second half is padding. - let c = (&p as *const mem::MaybeUninit).byte_add(mem::size_of::<&'static ()>()) as *const u8; + let c = &p as *const _ as *const u8; + let padding_offset = mem::size_of::<&'static ()>(); // Read a padding byte. - let _val = *c.add(0); + let _val = *c.add(padding_offset); //~^ERROR: uninitialized } } diff --git a/src/tools/miri/tests/fail/uninit/padding-enum.stderr b/src/tools/miri/tests/fail/uninit/padding-enum.stderr index 66d3092c9ba89..765e7cc4e637d 100644 --- a/src/tools/miri/tests/fail/uninit/padding-enum.stderr +++ b/src/tools/miri/tests/fail/uninit/padding-enum.stderr @@ -1,8 +1,8 @@ error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory --> tests/fail/uninit/padding-enum.rs:LL:CC | -LL | let _val = *c.add(0); - | ^^^^^^^^^ using uninitialized data, but this operation requires initialized memory +LL | let _val = *c.add(padding_offset); + | ^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information