diff options
Diffstat (limited to 'tests/expectations/tests/struct_with_anon_union.rs')
-rw-r--r-- | tests/expectations/tests/struct_with_anon_union.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/expectations/tests/struct_with_anon_union.rs b/tests/expectations/tests/struct_with_anon_union.rs index 15b8c9e4..e15939bd 100644 --- a/tests/expectations/tests/struct_with_anon_union.rs +++ b/tests/expectations/tests/struct_with_anon_union.rs @@ -30,7 +30,9 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { ); assert_eq!( unsafe { - &(*(::std::ptr::null::<foo__bindgen_ty_1>())).a as *const _ as usize + let uninit = ::std::mem::MaybeUninit::<foo__bindgen_ty_1>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, 0usize, concat!( @@ -42,7 +44,9 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { ); assert_eq!( unsafe { - &(*(::std::ptr::null::<foo__bindgen_ty_1>())).b as *const _ as usize + let uninit = ::std::mem::MaybeUninit::<foo__bindgen_ty_1>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).b) as usize - ptr as usize }, 0usize, concat!( @@ -75,7 +79,11 @@ fn bindgen_test_layout_foo() { concat!("Alignment of ", stringify!(foo)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::<foo>())).bar as *const _ as usize }, + unsafe { + let uninit = ::std::mem::MaybeUninit::<foo>::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).bar) as usize - ptr as usize + }, 0usize, concat!("Offset of field: ", stringify!(foo), "::", stringify!(bar)) ); |