summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoronalante-msft <89409054+onalante-msft@users.noreply.github.com>2022-07-15 21:44:18 -0700
committerEmilio Cobos Álvarez <emilio@crisal.io>2022-07-16 14:33:01 +0200
commit17b01c72ec985b8604410a82cc91734cb76cfcc2 (patch)
tree9ef116d982ffd76b54f68ec87e9b8259fcc3a3d3
parentfba40c70e5967a67f7a00991c1544eb9b76abf0a (diff)
Regenerate tests targeting libclang 5
-rw-r--r--tests/expectations/tests/class.rs336
-rw-r--r--tests/expectations/tests/class_1_0.rs336
-rw-r--r--tests/expectations/tests/derive-hash-struct-with-incomplete-array.rs54
-rw-r--r--tests/expectations/tests/issue-643-inner-struct.rs64
-rw-r--r--tests/expectations/tests/layout_align.rs32
-rw-r--r--tests/expectations/tests/libclang-5/call-conv-field.rs64
-rw-r--r--tests/expectations/tests/libclang-5/type_alias_template_specialized.rs32
-rw-r--r--tests/expectations/tests/zero-sized-array.rs66
8 files changed, 426 insertions, 558 deletions
diff --git a/tests/expectations/tests/class.rs b/tests/expectations/tests/class.rs
index 3bfba7e1..f26c77b7 100644
--- a/tests/expectations/tests/class.rs
+++ b/tests/expectations/tests/class.rs
@@ -43,6 +43,8 @@ pub struct C {
}
#[test]
fn bindgen_test_layout_C() {
+ const UNINIT: ::std::mem::MaybeUninit<C> =
+ ::std::mem::MaybeUninit::uninit();
assert_eq!(
::std::mem::size_of::<C>(),
40usize,
@@ -53,35 +55,27 @@ fn bindgen_test_layout_C() {
4usize,
concat!("Alignment of ", stringify!(C))
);
- fn test_field_a() {
- assert_eq!(
- unsafe {
- let uninit = ::std::mem::MaybeUninit::<C>::uninit();
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize
- },
- 0usize,
- concat!("Offset of field: ", stringify!(C), "::", stringify!(a))
- );
- }
- test_field_a();
- fn test_field_big_array() {
- assert_eq!(
- unsafe {
- let uninit = ::std::mem::MaybeUninit::<C>::uninit();
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).big_array) as usize - ptr as usize
- },
- 4usize,
- concat!(
- "Offset of field: ",
- stringify!(C),
- "::",
- stringify!(big_array)
- )
- );
- }
- test_field_big_array();
+ 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!(C), "::", stringify!(a))
+ );
+ assert_eq!(
+ unsafe {
+ let ptr = UNINIT.as_ptr();
+ ::std::ptr::addr_of!((*ptr).big_array) as usize - ptr as usize
+ },
+ 4usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(C),
+ "::",
+ stringify!(big_array)
+ )
+ );
}
impl Default for C {
fn default() -> Self {
@@ -100,6 +94,8 @@ pub struct C_with_zero_length_array {
}
#[test]
fn bindgen_test_layout_C_with_zero_length_array() {
+ const UNINIT: ::std::mem::MaybeUninit<C_with_zero_length_array> =
+ ::std::mem::MaybeUninit::uninit();
assert_eq!(
::std::mem::size_of::<C_with_zero_length_array>(),
40usize,
@@ -110,64 +106,46 @@ fn bindgen_test_layout_C_with_zero_length_array() {
4usize,
concat!("Alignment of ", stringify!(C_with_zero_length_array))
);
- fn test_field_a() {
- assert_eq!(
- unsafe {
- let uninit =
- ::std::mem::MaybeUninit::<C_with_zero_length_array>::uninit(
- );
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize
- },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(C_with_zero_length_array),
- "::",
- stringify!(a)
- )
- );
- }
- test_field_a();
- fn test_field_big_array() {
- assert_eq!(
- unsafe {
- let uninit =
- ::std::mem::MaybeUninit::<C_with_zero_length_array>::uninit(
- );
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).big_array) as usize - ptr as usize
- },
- 4usize,
- concat!(
- "Offset of field: ",
- stringify!(C_with_zero_length_array),
- "::",
- stringify!(big_array)
- )
- );
- }
- test_field_big_array();
- fn test_field_zero_length_array() {
- assert_eq!(
- unsafe {
- let uninit =
- ::std::mem::MaybeUninit::<C_with_zero_length_array>::uninit(
- );
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).zero_length_array) as usize -
- ptr as usize
- },
- 37usize,
- concat!(
- "Offset of field: ",
- stringify!(C_with_zero_length_array),
- "::",
- stringify!(zero_length_array)
- )
- );
- }
- test_field_zero_length_array();
+ 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!(C_with_zero_length_array),
+ "::",
+ stringify!(a)
+ )
+ );
+ assert_eq!(
+ unsafe {
+ let ptr = UNINIT.as_ptr();
+ ::std::ptr::addr_of!((*ptr).big_array) as usize - ptr as usize
+ },
+ 4usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(C_with_zero_length_array),
+ "::",
+ stringify!(big_array)
+ )
+ );
+ assert_eq!(
+ unsafe {
+ let ptr = UNINIT.as_ptr();
+ ::std::ptr::addr_of!((*ptr).zero_length_array) as usize -
+ ptr as usize
+ },
+ 37usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(C_with_zero_length_array),
+ "::",
+ stringify!(zero_length_array)
+ )
+ );
}
impl Default for C_with_zero_length_array {
fn default() -> Self {
@@ -186,6 +164,8 @@ pub struct C_with_zero_length_array_2 {
}
#[test]
fn bindgen_test_layout_C_with_zero_length_array_2() {
+ const UNINIT: ::std::mem::MaybeUninit<C_with_zero_length_array_2> =
+ ::std::mem::MaybeUninit::uninit();
assert_eq!(
::std::mem::size_of::<C_with_zero_length_array_2>(),
4usize,
@@ -196,45 +176,33 @@ fn bindgen_test_layout_C_with_zero_length_array_2() {
4usize,
concat!("Alignment of ", stringify!(C_with_zero_length_array_2))
);
- fn test_field_a() {
- assert_eq!(
- unsafe {
- let uninit = ::std::mem::MaybeUninit::<
- C_with_zero_length_array_2,
- >::uninit();
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize
- },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(C_with_zero_length_array_2),
- "::",
- stringify!(a)
- )
- );
- }
- test_field_a();
- fn test_field_zero_length_array() {
- assert_eq!(
- unsafe {
- let uninit = ::std::mem::MaybeUninit::<
- C_with_zero_length_array_2,
- >::uninit();
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).zero_length_array) as usize -
- ptr as usize
- },
- 4usize,
- concat!(
- "Offset of field: ",
- stringify!(C_with_zero_length_array_2),
- "::",
- stringify!(zero_length_array)
- )
- );
- }
- test_field_zero_length_array();
+ 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!(C_with_zero_length_array_2),
+ "::",
+ stringify!(a)
+ )
+ );
+ assert_eq!(
+ unsafe {
+ let ptr = UNINIT.as_ptr();
+ ::std::ptr::addr_of!((*ptr).zero_length_array) as usize -
+ ptr as usize
+ },
+ 4usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(C_with_zero_length_array_2),
+ "::",
+ stringify!(zero_length_array)
+ )
+ );
}
#[repr(C)]
pub struct C_with_incomplete_array {
@@ -353,6 +321,8 @@ pub struct WithDtor {
}
#[test]
fn bindgen_test_layout_WithDtor() {
+ const UNINIT: ::std::mem::MaybeUninit<WithDtor> =
+ ::std::mem::MaybeUninit::uninit();
assert_eq!(
::std::mem::size_of::<WithDtor>(),
4usize,
@@ -363,23 +333,19 @@ fn bindgen_test_layout_WithDtor() {
4usize,
concat!("Alignment of ", stringify!(WithDtor))
);
- fn test_field_b() {
- assert_eq!(
- unsafe {
- let uninit = ::std::mem::MaybeUninit::<WithDtor>::uninit();
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).b) as usize - ptr as usize
- },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(WithDtor),
- "::",
- stringify!(b)
- )
- );
- }
- test_field_b();
+ assert_eq!(
+ unsafe {
+ let ptr = UNINIT.as_ptr();
+ ::std::ptr::addr_of!((*ptr).b) as usize - ptr as usize
+ },
+ 0usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(WithDtor),
+ "::",
+ stringify!(b)
+ )
+ );
}
#[repr(C)]
pub struct IncompleteArrayNonCopiable {
@@ -416,6 +382,8 @@ pub union Union {
}
#[test]
fn bindgen_test_layout_Union() {
+ const UNINIT: ::std::mem::MaybeUninit<Union> =
+ ::std::mem::MaybeUninit::uninit();
assert_eq!(
::std::mem::size_of::<Union>(),
4usize,
@@ -426,40 +394,22 @@ fn bindgen_test_layout_Union() {
4usize,
concat!("Alignment of ", stringify!(Union))
);
- fn test_field_d() {
- assert_eq!(
- unsafe {
- let uninit = ::std::mem::MaybeUninit::<Union>::uninit();
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).d) as usize - ptr as usize
- },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(Union),
- "::",
- stringify!(d)
- )
- );
- }
- test_field_d();
- fn test_field_i() {
- assert_eq!(
- unsafe {
- let uninit = ::std::mem::MaybeUninit::<Union>::uninit();
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).i) as usize - ptr as usize
- },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(Union),
- "::",
- stringify!(i)
- )
- );
- }
- test_field_i();
+ assert_eq!(
+ unsafe {
+ let ptr = UNINIT.as_ptr();
+ ::std::ptr::addr_of!((*ptr).d) as usize - ptr as usize
+ },
+ 0usize,
+ concat!("Offset of field: ", stringify!(Union), "::", stringify!(d))
+ );
+ assert_eq!(
+ unsafe {
+ let ptr = UNINIT.as_ptr();
+ ::std::ptr::addr_of!((*ptr).i) as usize - ptr as usize
+ },
+ 0usize,
+ concat!("Offset of field: ", stringify!(Union), "::", stringify!(i))
+ );
}
impl Default for Union {
fn default() -> Self {
@@ -477,6 +427,8 @@ pub struct WithUnion {
}
#[test]
fn bindgen_test_layout_WithUnion() {
+ const UNINIT: ::std::mem::MaybeUninit<WithUnion> =
+ ::std::mem::MaybeUninit::uninit();
assert_eq!(
::std::mem::size_of::<WithUnion>(),
4usize,
@@ -487,23 +439,19 @@ fn bindgen_test_layout_WithUnion() {
4usize,
concat!("Alignment of ", stringify!(WithUnion))
);
- fn test_field_data() {
- assert_eq!(
- unsafe {
- let uninit = ::std::mem::MaybeUninit::<WithUnion>::uninit();
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize
- },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(WithUnion),
- "::",
- stringify!(data)
- )
- );
- }
- test_field_data();
+ assert_eq!(
+ unsafe {
+ let ptr = UNINIT.as_ptr();
+ ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize
+ },
+ 0usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(WithUnion),
+ "::",
+ stringify!(data)
+ )
+ );
}
impl Default for WithUnion {
fn default() -> Self {
diff --git a/tests/expectations/tests/class_1_0.rs b/tests/expectations/tests/class_1_0.rs
index 5415500a..c17e48d4 100644
--- a/tests/expectations/tests/class_1_0.rs
+++ b/tests/expectations/tests/class_1_0.rs
@@ -86,6 +86,8 @@ pub struct C {
}
#[test]
fn bindgen_test_layout_C() {
+ const UNINIT: ::std::mem::MaybeUninit<C> =
+ ::std::mem::MaybeUninit::uninit();
assert_eq!(
::std::mem::size_of::<C>(),
40usize,
@@ -96,35 +98,27 @@ fn bindgen_test_layout_C() {
4usize,
concat!("Alignment of ", stringify!(C))
);
- fn test_field_a() {
- assert_eq!(
- unsafe {
- let uninit = ::std::mem::MaybeUninit::<C>::uninit();
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize
- },
- 0usize,
- concat!("Offset of field: ", stringify!(C), "::", stringify!(a))
- );
- }
- test_field_a();
- fn test_field_big_array() {
- assert_eq!(
- unsafe {
- let uninit = ::std::mem::MaybeUninit::<C>::uninit();
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).big_array) as usize - ptr as usize
- },
- 4usize,
- concat!(
- "Offset of field: ",
- stringify!(C),
- "::",
- stringify!(big_array)
- )
- );
- }
- test_field_big_array();
+ 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!(C), "::", stringify!(a))
+ );
+ assert_eq!(
+ unsafe {
+ let ptr = UNINIT.as_ptr();
+ ::std::ptr::addr_of!((*ptr).big_array) as usize - ptr as usize
+ },
+ 4usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(C),
+ "::",
+ stringify!(big_array)
+ )
+ );
}
impl Clone for C {
fn clone(&self) -> Self {
@@ -153,6 +147,8 @@ pub struct C_with_zero_length_array {
}
#[test]
fn bindgen_test_layout_C_with_zero_length_array() {
+ const UNINIT: ::std::mem::MaybeUninit<C_with_zero_length_array> =
+ ::std::mem::MaybeUninit::uninit();
assert_eq!(
::std::mem::size_of::<C_with_zero_length_array>(),
40usize,
@@ -163,64 +159,46 @@ fn bindgen_test_layout_C_with_zero_length_array() {
4usize,
concat!("Alignment of ", stringify!(C_with_zero_length_array))
);
- fn test_field_a() {
- assert_eq!(
- unsafe {
- let uninit =
- ::std::mem::MaybeUninit::<C_with_zero_length_array>::uninit(
- );
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize
- },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(C_with_zero_length_array),
- "::",
- stringify!(a)
- )
- );
- }
- test_field_a();
- fn test_field_big_array() {
- assert_eq!(
- unsafe {
- let uninit =
- ::std::mem::MaybeUninit::<C_with_zero_length_array>::uninit(
- );
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).big_array) as usize - ptr as usize
- },
- 4usize,
- concat!(
- "Offset of field: ",
- stringify!(C_with_zero_length_array),
- "::",
- stringify!(big_array)
- )
- );
- }
- test_field_big_array();
- fn test_field_zero_length_array() {
- assert_eq!(
- unsafe {
- let uninit =
- ::std::mem::MaybeUninit::<C_with_zero_length_array>::uninit(
- );
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).zero_length_array) as usize -
- ptr as usize
- },
- 37usize,
- concat!(
- "Offset of field: ",
- stringify!(C_with_zero_length_array),
- "::",
- stringify!(zero_length_array)
- )
- );
- }
- test_field_zero_length_array();
+ 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!(C_with_zero_length_array),
+ "::",
+ stringify!(a)
+ )
+ );
+ assert_eq!(
+ unsafe {
+ let ptr = UNINIT.as_ptr();
+ ::std::ptr::addr_of!((*ptr).big_array) as usize - ptr as usize
+ },
+ 4usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(C_with_zero_length_array),
+ "::",
+ stringify!(big_array)
+ )
+ );
+ assert_eq!(
+ unsafe {
+ let ptr = UNINIT.as_ptr();
+ ::std::ptr::addr_of!((*ptr).zero_length_array) as usize -
+ ptr as usize
+ },
+ 37usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(C_with_zero_length_array),
+ "::",
+ stringify!(zero_length_array)
+ )
+ );
}
impl Default for C_with_zero_length_array {
fn default() -> Self {
@@ -239,6 +217,8 @@ pub struct C_with_zero_length_array_2 {
}
#[test]
fn bindgen_test_layout_C_with_zero_length_array_2() {
+ const UNINIT: ::std::mem::MaybeUninit<C_with_zero_length_array_2> =
+ ::std::mem::MaybeUninit::uninit();
assert_eq!(
::std::mem::size_of::<C_with_zero_length_array_2>(),
4usize,
@@ -249,45 +229,33 @@ fn bindgen_test_layout_C_with_zero_length_array_2() {
4usize,
concat!("Alignment of ", stringify!(C_with_zero_length_array_2))
);
- fn test_field_a() {
- assert_eq!(
- unsafe {
- let uninit = ::std::mem::MaybeUninit::<
- C_with_zero_length_array_2,
- >::uninit();
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize
- },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(C_with_zero_length_array_2),
- "::",
- stringify!(a)
- )
- );
- }
- test_field_a();
- fn test_field_zero_length_array() {
- assert_eq!(
- unsafe {
- let uninit = ::std::mem::MaybeUninit::<
- C_with_zero_length_array_2,
- >::uninit();
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).zero_length_array) as usize -
- ptr as usize
- },
- 4usize,
- concat!(
- "Offset of field: ",
- stringify!(C_with_zero_length_array_2),
- "::",
- stringify!(zero_length_array)
- )
- );
- }
- test_field_zero_length_array();
+ 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!(C_with_zero_length_array_2),
+ "::",
+ stringify!(a)
+ )
+ );
+ assert_eq!(
+ unsafe {
+ let ptr = UNINIT.as_ptr();
+ ::std::ptr::addr_of!((*ptr).zero_length_array) as usize -
+ ptr as usize
+ },
+ 4usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(C_with_zero_length_array_2),
+ "::",
+ stringify!(zero_length_array)
+ )
+ );
}
#[repr(C)]
pub struct C_with_incomplete_array {
@@ -406,6 +374,8 @@ pub struct WithDtor {
}
#[test]
fn bindgen_test_layout_WithDtor() {
+ const UNINIT: ::std::mem::MaybeUninit<WithDtor> =
+ ::std::mem::MaybeUninit::uninit();
assert_eq!(
::std::mem::size_of::<WithDtor>(),
4usize,
@@ -416,23 +386,19 @@ fn bindgen_test_layout_WithDtor() {
4usize,
concat!("Alignment of ", stringify!(WithDtor))
);
- fn test_field_b() {
- assert_eq!(
- unsafe {
- let uninit = ::std::mem::MaybeUninit::<WithDtor>::uninit();
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).b) as usize - ptr as usize
- },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(WithDtor),
- "::",
- stringify!(b)
- )
- );
- }
- test_field_b();
+ assert_eq!(
+ unsafe {
+ let ptr = UNINIT.as_ptr();
+ ::std::ptr::addr_of!((*ptr).b) as usize - ptr as usize
+ },
+ 0usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(WithDtor),
+ "::",
+ stringify!(b)
+ )
+ );
}
#[repr(C)]
pub struct IncompleteArrayNonCopiable {
@@ -470,6 +436,8 @@ pub struct Union {
}
#[test]
fn bindgen_test_layout_Union() {
+ const UNINIT: ::std::mem::MaybeUninit<Union> =
+ ::std::mem::MaybeUninit::uninit();
assert_eq!(
::std::mem::size_of::<Union>(),
4usize,
@@ -480,40 +448,22 @@ fn bindgen_test_layout_Union() {
4usize,
concat!("Alignment of ", stringify!(Union))
);
- fn test_field_d() {
- assert_eq!(
- unsafe {
- let uninit = ::std::mem::MaybeUninit::<Union>::uninit();
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).d) as usize - ptr as usize
- },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(Union),
- "::",
- stringify!(d)
- )
- );
- }
- test_field_d();
- fn test_field_i() {
- assert_eq!(
- unsafe {
- let uninit = ::std::mem::MaybeUninit::<Union>::uninit();
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).i) as usize - ptr as usize
- },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(Union),
- "::",
- stringify!(i)
- )
- );
- }
- test_field_i();
+ assert_eq!(
+ unsafe {
+ let ptr = UNINIT.as_ptr();
+ ::std::ptr::addr_of!((*ptr).d) as usize - ptr as usize
+ },
+ 0usize,
+ concat!("Offset of field: ", stringify!(Union), "::", stringify!(d))
+ );
+ assert_eq!(
+ unsafe {
+ let ptr = UNINIT.as_ptr();
+ ::std::ptr::addr_of!((*ptr).i) as usize - ptr as usize
+ },
+ 0usize,
+ concat!("Offset of field: ", stringify!(Union), "::", stringify!(i))
+ );
}
impl Clone for Union {
fn clone(&self) -> Self {
@@ -527,6 +477,8 @@ pub struct WithUnion {
}
#[test]
fn bindgen_test_layout_WithUnion() {
+ const UNINIT: ::std::mem::MaybeUninit<WithUnion> =
+ ::std::mem::MaybeUninit::uninit();
assert_eq!(
::std::mem::size_of::<WithUnion>(),
4usize,
@@ -537,23 +489,19 @@ fn bindgen_test_layout_WithUnion() {
4usize,
concat!("Alignment of ", stringify!(WithUnion))
);
- fn test_field_data() {
- assert_eq!(
- unsafe {
- let uninit = ::std::mem::MaybeUninit::<WithUnion>::uninit();
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize
- },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(WithUnion),
- "::",
- stringify!(data)
- )
- );
- }
- test_field_data();
+ assert_eq!(
+ unsafe {
+ let ptr = UNINIT.as_ptr();
+ ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize
+ },
+ 0usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(WithUnion),
+ "::",
+ stringify!(data)
+ )
+ );
}
impl Clone for WithUnion {
fn clone(&self) -> Self {
diff --git a/tests/expectations/tests/derive-hash-struct-with-incomplete-array.rs b/tests/expectations/tests/derive-hash-struct-with-incomplete-array.rs
index abba4b28..48fc7ed1 100644
--- a/tests/expectations/tests/derive-hash-struct-with-incomplete-array.rs
+++ b/tests/expectations/tests/derive-hash-struct-with-incomplete-array.rs
@@ -43,6 +43,8 @@ pub struct test {
}
#[test]
fn bindgen_test_layout_test() {
+ const UNINIT: ::std::mem::MaybeUninit<test> =
+ ::std::mem::MaybeUninit::uninit();
assert_eq!(
::std::mem::size_of::<test>(),
4usize,
@@ -53,36 +55,28 @@ fn bindgen_test_layout_test() {
4usize,
concat!("Alignment of ", stringify!(test))
);
- fn test_field_a() {
- assert_eq!(
- unsafe {
- let uninit = ::std::mem::MaybeUninit::<test>::uninit();
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize
- },
- 0usize,
- concat!("Offset of field: ", stringify!(test), "::", stringify!(a))
- );
- }
- test_field_a();
- fn test_field_zero_length_array() {
- assert_eq!(
- unsafe {
- let uninit = ::std::mem::MaybeUninit::<test>::uninit();
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).zero_length_array) as usize -
- ptr as usize
- },
- 4usize,
- concat!(
- "Offset of field: ",
- stringify!(test),
- "::",
- stringify!(zero_length_array)
- )
- );
- }
- test_field_zero_length_array();
+ 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!(test), "::", stringify!(a))
+ );
+ assert_eq!(
+ unsafe {
+ let ptr = UNINIT.as_ptr();
+ ::std::ptr::addr_of!((*ptr).zero_length_array) as usize -
+ ptr as usize
+ },
+ 4usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(test),
+ "::",
+ stringify!(zero_length_array)
+ )
+ );
}
#[repr(C)]
#[derive(Debug, Default)]
diff --git a/tests/expectations/tests/issue-643-inner-struct.rs b/tests/expectations/tests/issue-643-inner-struct.rs
index 0fb586c4..ae1890c2 100644
--- a/tests/expectations/tests/issue-643-inner-struct.rs
+++ b/tests/expectations/tests/issue-643-inner-struct.rs
@@ -50,6 +50,8 @@ pub struct rte_ring_prod {
}
#[test]
fn bindgen_test_layout_rte_ring_prod() {
+ const UNINIT: ::std::mem::MaybeUninit<rte_ring_prod> =
+ ::std::mem::MaybeUninit::uninit();
assert_eq!(
::std::mem::size_of::<rte_ring_prod>(),
4usize,
@@ -60,23 +62,19 @@ fn bindgen_test_layout_rte_ring_prod() {
4usize,
concat!("Alignment of ", stringify!(rte_ring_prod))
);
- fn test_field_watermark() {
- assert_eq!(
- unsafe {
- let uninit = ::std::mem::MaybeUninit::<rte_ring_prod>::uninit();
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).watermark) as usize - ptr as usize
- },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(rte_ring_prod),
- "::",
- stringify!(watermark)
- )
- );
- }
- test_field_watermark();
+ assert_eq!(
+ unsafe {
+ let ptr = UNINIT.as_ptr();
+ ::std::ptr::addr_of!((*ptr).watermark) as usize - ptr as usize
+ },
+ 0usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(rte_ring_prod),
+ "::",
+ stringify!(watermark)
+ )
+ );
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
@@ -85,6 +83,8 @@ pub struct rte_ring_cons {
}
#[test]
fn bindgen_test_layout_rte_ring_cons() {
+ const UNINIT: ::std::mem::MaybeUninit<rte_ring_cons> =
+ ::std::mem::MaybeUninit::uninit();
assert_eq!(
::std::mem::size_of::<rte_ring_cons>(),
4usize,
@@ -95,23 +95,19 @@ fn bindgen_test_layout_rte_ring_cons() {
4usize,
concat!("Alignment of ", stringify!(rte_ring_cons))
);
- fn test_field_sc_dequeue() {
- assert_eq!(
- unsafe {
- let uninit = ::std::mem::MaybeUninit::<rte_ring_cons>::uninit();
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).sc_dequeue) as usize - ptr as usize
- },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(rte_ring_cons),
- "::",
- stringify!(sc_dequeue)
- )
- );
- }
- test_field_sc_dequeue();
+ assert_eq!(
+ unsafe {
+ let ptr = UNINIT.as_ptr();
+ ::std::ptr::addr_of!((*ptr).sc_dequeue) as usize - ptr as usize
+ },
+ 0usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(rte_ring_cons),
+ "::",
+ stringify!(sc_dequeue)
+ )
+ );
}
#[test]
fn bindgen_test_layout_rte_ring() {
diff --git a/tests/expectations/tests/layout_align.rs b/tests/expectations/tests/layout_align.rs
index 44df4c1c..a6d18d14 100644
--- a/tests/expectations/tests/layout_align.rs
+++ b/tests/expectations/tests/layout_align.rs
@@ -169,6 +169,8 @@ pub struct rte_eth_link {
}
#[test]
fn bindgen_test_layout_rte_eth_link() {
+ const UNINIT: ::std::mem::MaybeUninit<rte_eth_link> =
+ ::std::mem::MaybeUninit::uninit();
assert_eq!(
::std::mem::size_of::<rte_eth_link>(),
8usize,
@@ -179,23 +181,19 @@ fn bindgen_test_layout_rte_eth_link() {
8usize,
concat!("Alignment of ", stringify!(rte_eth_link))
);
- fn test_field_link_speed() {
- assert_eq!(
- unsafe {
- let uninit = ::std::mem::MaybeUninit::<rte_eth_link>::uninit();
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).link_speed) as usize - ptr as usize
- },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(rte_eth_link),
- "::",
- stringify!(link_speed)
- )
- );
- }
- test_field_link_speed();
+ assert_eq!(
+ unsafe {
+ let ptr = UNINIT.as_ptr();
+ ::std::ptr::addr_of!((*ptr).link_speed) as usize - ptr as usize
+ },
+ 0usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(rte_eth_link),
+ "::",
+ stringify!(link_speed)
+ )
+ );
}
impl rte_eth_link {
#[inline]
diff --git a/tests/expectations/tests/libclang-5/call-conv-field.rs b/tests/expectations/tests/libclang-5/call-conv-field.rs
index f83181ea..eb86ec2f 100644
--- a/tests/expectations/tests/libclang-5/call-conv-field.rs
+++ b/tests/expectations/tests/libclang-5/call-conv-field.rs
@@ -18,6 +18,8 @@ pub struct JNINativeInterface_ {
}
#[test]
fn bindgen_test_layout_JNINativeInterface_() {
+ const UNINIT: ::std::mem::MaybeUninit<JNINativeInterface_> =
+ ::std::mem::MaybeUninit::uninit();
assert_eq!(
::std::mem::size_of::<JNINativeInterface_>(),
16usize,
@@ -28,42 +30,32 @@ fn bindgen_test_layout_JNINativeInterface_() {
8usize,
concat!("Alignment of ", stringify!(JNINativeInterface_))
);
- fn test_field_GetVersion() {
- assert_eq!(
- unsafe {
- let uninit =
- ::std::mem::MaybeUninit::<JNINativeInterface_>::uninit();
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).GetVersion) as usize - ptr as usize
- },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(JNINativeInterface_),
- "::",
- stringify!(GetVersion)
- )
- );
- }
- test_field_GetVersion();
- fn test_field___hack() {
- assert_eq!(
- unsafe {
- let uninit =
- ::std::mem::MaybeUninit::<JNINativeInterface_>::uninit();
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).__hack) as usize - ptr as usize
- },
- 8usize,
- concat!(
- "Offset of field: ",
- stringify!(JNINativeInterface_),
- "::",
- stringify!(__hack)
- )
- );
- }
- test_field___hack();
+ assert_eq!(
+ unsafe {
+ let ptr = UNINIT.as_ptr();
+ ::std::ptr::addr_of!((*ptr).GetVersion) as usize - ptr as usize
+ },
+ 0usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(JNINativeInterface_),
+ "::",
+ stringify!(GetVersion)
+ )
+ );
+ assert_eq!(
+ unsafe {
+ let ptr = UNINIT.as_ptr();
+ ::std::ptr::addr_of!((*ptr).__hack) as usize - ptr as usize
+ },
+ 8usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(JNINativeInterface_),
+ "::",
+ stringify!(__hack)
+ )
+ );
}
extern "stdcall" {
pub fn bar();
diff --git a/tests/expectations/tests/libclang-5/type_alias_template_specialized.rs b/tests/expectations/tests/libclang-5/type_alias_template_specialized.rs
index 213d4cd6..3e655093 100644
--- a/tests/expectations/tests/libclang-5/type_alias_template_specialized.rs
+++ b/tests/expectations/tests/libclang-5/type_alias_template_specialized.rs
@@ -12,6 +12,8 @@ pub struct Rooted {
}
#[test]
fn bindgen_test_layout_Rooted() {
+ const UNINIT: ::std::mem::MaybeUninit<Rooted> =
+ ::std::mem::MaybeUninit::uninit();
assert_eq!(
::std::mem::size_of::<Rooted>(),
4usize,
@@ -22,23 +24,19 @@ fn bindgen_test_layout_Rooted() {
4usize,
concat!("Alignment of ", stringify!(Rooted))
);
- fn test_field_ptr() {
- assert_eq!(
- unsafe {
- let uninit = ::std::mem::MaybeUninit::<Rooted>::uninit();
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).ptr) as usize - ptr as usize
- },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(Rooted),
- "::",
- stringify!(ptr)
- )
- );
- }
- test_field_ptr();
+ assert_eq!(
+ unsafe {
+ let ptr = UNINIT.as_ptr();
+ ::std::ptr::addr_of!((*ptr).ptr) as usize - ptr as usize
+ },
+ 0usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(Rooted),
+ "::",
+ stringify!(ptr)
+ )
+ );
}
impl Default for Rooted {
fn default() -> Self {
diff --git a/tests/expectations/tests/zero-sized-array.rs b/tests/expectations/tests/zero-sized-array.rs
index c12afa59..358164d3 100644
--- a/tests/expectations/tests/zero-sized-array.rs
+++ b/tests/expectations/tests/zero-sized-array.rs
@@ -43,6 +43,8 @@ pub struct ZeroSizedArray {
}
#[test]
fn bindgen_test_layout_ZeroSizedArray() {
+ const UNINIT: ::std::mem::MaybeUninit<ZeroSizedArray> =
+ ::std::mem::MaybeUninit::uninit();
assert_eq!(
::std::mem::size_of::<ZeroSizedArray>(),
0usize,
@@ -53,24 +55,19 @@ fn bindgen_test_layout_ZeroSizedArray() {
1usize,
concat!("Alignment of ", stringify!(ZeroSizedArray))
);
- fn test_field_arr() {
- assert_eq!(
- unsafe {
- let uninit =
- ::std::mem::MaybeUninit::<ZeroSizedArray>::uninit();
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).arr) as usize - ptr as usize
- },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(ZeroSizedArray),
- "::",
- stringify!(arr)
- )
- );
- }
- test_field_arr();
+ assert_eq!(
+ unsafe {
+ let ptr = UNINIT.as_ptr();
+ ::std::ptr::addr_of!((*ptr).arr) as usize - ptr as usize
+ },
+ 0usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(ZeroSizedArray),
+ "::",
+ stringify!(arr)
+ )
+ );
}
/// And nor should this get an `_address` field.
#[repr(C)]
@@ -80,6 +77,8 @@ pub struct ContainsZeroSizedArray {
}
#[test]
fn bindgen_test_layout_ContainsZeroSizedArray() {
+ const UNINIT: ::std::mem::MaybeUninit<ContainsZeroSizedArray> =
+ ::std::mem::MaybeUninit::uninit();
assert_eq!(
::std::mem::size_of::<ContainsZeroSizedArray>(),
0usize,
@@ -90,24 +89,19 @@ fn bindgen_test_layout_ContainsZeroSizedArray() {
1usize,
concat!("Alignment of ", stringify!(ContainsZeroSizedArray))
);
- fn test_field_zsa() {
- assert_eq!(
- unsafe {
- let uninit =
- ::std::mem::MaybeUninit::<ContainsZeroSizedArray>::uninit();
- let ptr = uninit.as_ptr();
- ::std::ptr::addr_of!((*ptr).zsa) as usize - ptr as usize
- },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(ContainsZeroSizedArray),
- "::",
- stringify!(zsa)
- )
- );
- }
- test_field_zsa();
+ assert_eq!(
+ unsafe {
+ let ptr = UNINIT.as_ptr();
+ ::std::ptr::addr_of!((*ptr).zsa) as usize - ptr as usize
+ },
+ 0usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(ContainsZeroSizedArray),
+ "::",
+ stringify!(zsa)
+ )
+ );
}
/// Inheriting from ZeroSizedArray shouldn't cause an `_address` to be inserted
/// either.