diff options
Diffstat (limited to 'tests/expectations/tests/struct_with_derive_debug.rs')
-rw-r--r-- | tests/expectations/tests/struct_with_derive_debug.rs | 121 |
1 files changed, 52 insertions, 69 deletions
diff --git a/tests/expectations/tests/struct_with_derive_debug.rs b/tests/expectations/tests/struct_with_derive_debug.rs index a2729bbe..1bb7c77d 100644 --- a/tests/expectations/tests/struct_with_derive_debug.rs +++ b/tests/expectations/tests/struct_with_derive_debug.rs @@ -12,6 +12,9 @@ pub struct LittleArray { } #[test] fn bindgen_test_layout_LittleArray() { + const UNINIT: ::std::mem::MaybeUninit<LittleArray> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::<LittleArray>(), 128usize, @@ -22,23 +25,16 @@ fn bindgen_test_layout_LittleArray() { 4usize, concat!("Alignment of ", stringify!(LittleArray)) ); - fn test_field_a() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<LittleArray>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(LittleArray), - "::", - stringify!(a) - ) - ); - } - test_field_a(); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(LittleArray), + "::", + stringify!(a) + ) + ); } #[repr(C)] #[derive(Copy, Clone)] @@ -47,6 +43,9 @@ pub struct BigArray { } #[test] fn bindgen_test_layout_BigArray() { + const UNINIT: ::std::mem::MaybeUninit<BigArray> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::<BigArray>(), 132usize, @@ -57,23 +56,16 @@ fn bindgen_test_layout_BigArray() { 4usize, concat!("Alignment of ", stringify!(BigArray)) ); - fn test_field_a() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<BigArray>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(BigArray), - "::", - stringify!(a) - ) - ); - } - test_field_a(); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(BigArray), + "::", + stringify!(a) + ) + ); } impl Default for BigArray { fn default() -> Self { @@ -91,6 +83,9 @@ pub struct WithLittleArray { } #[test] fn bindgen_test_layout_WithLittleArray() { + const UNINIT: ::std::mem::MaybeUninit<WithLittleArray> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::<WithLittleArray>(), 128usize, @@ -101,24 +96,16 @@ fn bindgen_test_layout_WithLittleArray() { 4usize, concat!("Alignment of ", stringify!(WithLittleArray)) ); - fn test_field_a() { - assert_eq!( - unsafe { - let uninit = - ::std::mem::MaybeUninit::<WithLittleArray>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(WithLittleArray), - "::", - stringify!(a) - ) - ); - } - test_field_a(); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(WithLittleArray), + "::", + stringify!(a) + ) + ); } #[repr(C)] #[derive(Copy, Clone)] @@ -127,6 +114,9 @@ pub struct WithBigArray { } #[test] fn bindgen_test_layout_WithBigArray() { + const UNINIT: ::std::mem::MaybeUninit<WithBigArray> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::<WithBigArray>(), 132usize, @@ -137,23 +127,16 @@ fn bindgen_test_layout_WithBigArray() { 4usize, concat!("Alignment of ", stringify!(WithBigArray)) ); - fn test_field_a() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<WithBigArray>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(WithBigArray), - "::", - stringify!(a) - ) - ); - } - test_field_a(); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(WithBigArray), + "::", + stringify!(a) + ) + ); } impl Default for WithBigArray { fn default() -> Self { |