summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/expectations/tests/class.rs14
-rw-r--r--tests/expectations/tests/class_1_0.rs14
-rw-r--r--tests/expectations/tests/derive-hash-struct-with-incomplete-array.rs14
-rw-r--r--tests/expectations/tests/issue-643-inner-struct.rs14
-rw-r--r--tests/expectations/tests/layout_align.rs5
-rw-r--r--tests/expectations/tests/layout_large_align_field.rs5
-rw-r--r--tests/expectations/tests/zero-size-array-align.rs95
-rw-r--r--tests/expectations/tests/zero-sized-array.rs5
-rw-r--r--tests/headers/zero-size-array-align.h5
9 files changed, 138 insertions, 33 deletions
diff --git a/tests/expectations/tests/class.rs b/tests/expectations/tests/class.rs
index f7639aac..f52f0f85 100644
--- a/tests/expectations/tests/class.rs
+++ b/tests/expectations/tests/class.rs
@@ -1,16 +1,19 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Default)]
-pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>);
+pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>, [T; 0]);
impl<T> __IncompleteArrayField<T> {
#[inline]
pub fn new() -> Self {
- __IncompleteArrayField(::std::marker::PhantomData)
+ __IncompleteArrayField(::std::marker::PhantomData, [])
}
#[inline]
pub unsafe fn as_ptr(&self) -> *const T {
@@ -40,7 +43,6 @@ impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
Self::new()
}
}
-impl<T> ::std::marker::Copy for __IncompleteArrayField<T> {}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct C {
diff --git a/tests/expectations/tests/class_1_0.rs b/tests/expectations/tests/class_1_0.rs
index a5639b25..b35e8814 100644
--- a/tests/expectations/tests/class_1_0.rs
+++ b/tests/expectations/tests/class_1_0.rs
@@ -1,16 +1,19 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Default)]
-pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>);
+pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>, [T; 0]);
impl<T> __IncompleteArrayField<T> {
#[inline]
pub fn new() -> Self {
- __IncompleteArrayField(::std::marker::PhantomData)
+ __IncompleteArrayField(::std::marker::PhantomData, [])
}
#[inline]
pub unsafe fn as_ptr(&self) -> *const T {
@@ -40,7 +43,6 @@ impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
Self::new()
}
}
-impl<T> ::std::marker::Copy for __IncompleteArrayField<T> {}
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl<T> __BindgenUnionField<T> {
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 e95c3391..8e87432f 100644
--- a/tests/expectations/tests/derive-hash-struct-with-incomplete-array.rs
+++ b/tests/expectations/tests/derive-hash-struct-with-incomplete-array.rs
@@ -1,16 +1,19 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Default)]
-pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>);
+pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>, [T; 0]);
impl<T> __IncompleteArrayField<T> {
#[inline]
pub fn new() -> Self {
- __IncompleteArrayField(::std::marker::PhantomData)
+ __IncompleteArrayField(::std::marker::PhantomData, [])
}
#[inline]
pub unsafe fn as_ptr(&self) -> *const T {
@@ -40,7 +43,6 @@ impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
Self::new()
}
}
-impl<T> ::std::marker::Copy for __IncompleteArrayField<T> {}
#[repr(C)]
#[derive(Debug, Default)]
pub struct test {
diff --git a/tests/expectations/tests/issue-643-inner-struct.rs b/tests/expectations/tests/issue-643-inner-struct.rs
index 83b52c22..a9696a6d 100644
--- a/tests/expectations/tests/issue-643-inner-struct.rs
+++ b/tests/expectations/tests/issue-643-inner-struct.rs
@@ -1,16 +1,19 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Default)]
-pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>);
+pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>, [T; 0]);
impl<T> __IncompleteArrayField<T> {
#[inline]
pub fn new() -> Self {
- __IncompleteArrayField(::std::marker::PhantomData)
+ __IncompleteArrayField(::std::marker::PhantomData, [])
}
#[inline]
pub unsafe fn as_ptr(&self) -> *const T {
@@ -40,7 +43,6 @@ impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
Self::new()
}
}
-impl<T> ::std::marker::Copy for __IncompleteArrayField<T> {}
#[repr(C)]
#[derive(Debug)]
pub struct rte_ring {
diff --git a/tests/expectations/tests/layout_align.rs b/tests/expectations/tests/layout_align.rs
index a1350b14..39fb2948 100644
--- a/tests/expectations/tests/layout_align.rs
+++ b/tests/expectations/tests/layout_align.rs
@@ -91,11 +91,11 @@ where
}
#[repr(C)]
#[derive(Default)]
-pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>);
+pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>, [T; 0]);
impl<T> __IncompleteArrayField<T> {
#[inline]
pub fn new() -> Self {
- __IncompleteArrayField(::std::marker::PhantomData)
+ __IncompleteArrayField(::std::marker::PhantomData, [])
}
#[inline]
pub unsafe fn as_ptr(&self) -> *const T {
@@ -125,7 +125,6 @@ impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
Self::new()
}
}
-impl<T> ::std::marker::Copy for __IncompleteArrayField<T> {}
#[repr(C)]
#[derive(Debug)]
pub struct rte_kni_fifo {
diff --git a/tests/expectations/tests/layout_large_align_field.rs b/tests/expectations/tests/layout_large_align_field.rs
index 5a865189..8b7be4ca 100644
--- a/tests/expectations/tests/layout_large_align_field.rs
+++ b/tests/expectations/tests/layout_large_align_field.rs
@@ -9,11 +9,11 @@
#[repr(C)]
#[derive(Default)]
-pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>);
+pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>, [T; 0]);
impl<T> __IncompleteArrayField<T> {
#[inline]
pub fn new() -> Self {
- __IncompleteArrayField(::std::marker::PhantomData)
+ __IncompleteArrayField(::std::marker::PhantomData, [])
}
#[inline]
pub unsafe fn as_ptr(&self) -> *const T {
@@ -43,7 +43,6 @@ impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
Self::new()
}
}
-impl<T> ::std::marker::Copy for __IncompleteArrayField<T> {}
pub const RTE_CACHE_LINE_SIZE: u32 = 64;
pub const RTE_LIBRTE_IP_FRAG_MAX_FRAG: u32 = 4;
pub const IP_LAST_FRAG_IDX: _bindgen_ty_1 = _bindgen_ty_1::IP_LAST_FRAG_IDX;
diff --git a/tests/expectations/tests/zero-size-array-align.rs b/tests/expectations/tests/zero-size-array-align.rs
new file mode 100644
index 00000000..9c60d14e
--- /dev/null
+++ b/tests/expectations/tests/zero-size-array-align.rs
@@ -0,0 +1,95 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+#[repr(C)]
+#[derive(Default)]
+pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>, [T; 0]);
+impl<T> __IncompleteArrayField<T> {
+ #[inline]
+ pub fn new() -> Self {
+ __IncompleteArrayField(::std::marker::PhantomData, [])
+ }
+ #[inline]
+ pub unsafe fn as_ptr(&self) -> *const T {
+ ::std::mem::transmute(self)
+ }
+ #[inline]
+ pub unsafe fn as_mut_ptr(&mut self) -> *mut T {
+ ::std::mem::transmute(self)
+ }
+ #[inline]
+ pub unsafe fn as_slice(&self, len: usize) -> &[T] {
+ ::std::slice::from_raw_parts(self.as_ptr(), len)
+ }
+ #[inline]
+ pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
+ ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
+ }
+}
+impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
+ fmt.write_str("__IncompleteArrayField")
+ }
+}
+impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
+ #[inline]
+ fn clone(&self) -> Self {
+ Self::new()
+ }
+}
+#[repr(C)]
+#[derive(Debug, Default)]
+pub struct dm_deps {
+ pub count: ::std::os::raw::c_uint,
+ pub filler: ::std::os::raw::c_uint,
+ pub device: __IncompleteArrayField<::std::os::raw::c_ulonglong>,
+}
+#[test]
+fn bindgen_test_layout_dm_deps() {
+ assert_eq!(
+ ::std::mem::size_of::<dm_deps>(),
+ 8usize,
+ concat!("Size of: ", stringify!(dm_deps))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<dm_deps>(),
+ 8usize,
+ concat!("Alignment of ", stringify!(dm_deps))
+ );
+ assert_eq!(
+ unsafe { &(*(::std::ptr::null::<dm_deps>())).count as *const _ as usize },
+ 0usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(dm_deps),
+ "::",
+ stringify!(count)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(::std::ptr::null::<dm_deps>())).filler as *const _ as usize },
+ 4usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(dm_deps),
+ "::",
+ stringify!(filler)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(::std::ptr::null::<dm_deps>())).device as *const _ as usize },
+ 8usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(dm_deps),
+ "::",
+ stringify!(device)
+ )
+ );
+}
diff --git a/tests/expectations/tests/zero-sized-array.rs b/tests/expectations/tests/zero-sized-array.rs
index 4464bb4b..e002251d 100644
--- a/tests/expectations/tests/zero-sized-array.rs
+++ b/tests/expectations/tests/zero-sized-array.rs
@@ -9,11 +9,11 @@
#[repr(C)]
#[derive(Default)]
-pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>);
+pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>, [T; 0]);
impl<T> __IncompleteArrayField<T> {
#[inline]
pub fn new() -> Self {
- __IncompleteArrayField(::std::marker::PhantomData)
+ __IncompleteArrayField(::std::marker::PhantomData, [])
}
#[inline]
pub unsafe fn as_ptr(&self) -> *const T {
@@ -43,7 +43,6 @@ impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
Self::new()
}
}
-impl<T> ::std::marker::Copy for __IncompleteArrayField<T> {}
/// Bizarrely enough, this should *not* get an `_address` field.
#[repr(C)]
#[derive(Debug, Default)]
diff --git a/tests/headers/zero-size-array-align.h b/tests/headers/zero-size-array-align.h
new file mode 100644
index 00000000..05b11bce
--- /dev/null
+++ b/tests/headers/zero-size-array-align.h
@@ -0,0 +1,5 @@
+struct dm_deps {
+ unsigned count;
+ unsigned filler;
+ unsigned long long device[0];
+};