summaryrefslogtreecommitdiff
path: root/tests/expectations/tests/struct_with_derive_debug.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/expectations/tests/struct_with_derive_debug.rs')
-rw-r--r--tests/expectations/tests/struct_with_derive_debug.rs129
1 files changed, 60 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..890223ac 100644
--- a/tests/expectations/tests/struct_with_derive_debug.rs
+++ b/tests/expectations/tests/struct_with_derive_debug.rs
@@ -12,6 +12,8 @@ pub struct LittleArray {
}
#[test]
fn bindgen_test_layout_LittleArray() {
+ const UNINIT: ::std::mem::MaybeUninit<LittleArray> =
+ ::std::mem::MaybeUninit::uninit();
assert_eq!(
::std::mem::size_of::<LittleArray>(),
128usize,
@@ -22,23 +24,19 @@ 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 {
+ 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)
+ )
+ );
}
#[repr(C)]
#[derive(Copy, Clone)]
@@ -47,6 +45,8 @@ pub struct BigArray {
}
#[test]
fn bindgen_test_layout_BigArray() {
+ const UNINIT: ::std::mem::MaybeUninit<BigArray> =
+ ::std::mem::MaybeUninit::uninit();
assert_eq!(
::std::mem::size_of::<BigArray>(),
132usize,
@@ -57,23 +57,19 @@ 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 {
+ 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)
+ )
+ );
}
impl Default for BigArray {
fn default() -> Self {
@@ -91,6 +87,8 @@ pub struct WithLittleArray {
}
#[test]
fn bindgen_test_layout_WithLittleArray() {
+ const UNINIT: ::std::mem::MaybeUninit<WithLittleArray> =
+ ::std::mem::MaybeUninit::uninit();
assert_eq!(
::std::mem::size_of::<WithLittleArray>(),
128usize,
@@ -101,24 +99,19 @@ 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 {
+ 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)
+ )
+ );
}
#[repr(C)]
#[derive(Copy, Clone)]
@@ -127,6 +120,8 @@ pub struct WithBigArray {
}
#[test]
fn bindgen_test_layout_WithBigArray() {
+ const UNINIT: ::std::mem::MaybeUninit<WithBigArray> =
+ ::std::mem::MaybeUninit::uninit();
assert_eq!(
::std::mem::size_of::<WithBigArray>(),
132usize,
@@ -137,23 +132,19 @@ 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 {
+ 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)
+ )
+ );
}
impl Default for WithBigArray {
fn default() -> Self {