summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergey Pepyakin <s.pepyakin@gmail.com>2017-09-23 01:48:19 +0300
committerSergey Pepyakin <s.pepyakin@gmail.com>2017-10-03 00:37:09 +0300
commitdde9376cf32511debbb4b0e068c6ca776d13349b (patch)
treed47244770a0fe187e7c2fec0db0366cfdbd17092 /tests
parentc66598d28b7ffe8b8e30a58e9268db50dd109986 (diff)
Derive partialeq "manually" when possible
Remove derive-partialeq-template-inst test. Add comments. Don't implement PartialEq for incomplete arrays Handle opaque bases and template instantiations Extract constrain_type. Extract `is whitelisted?` check Add failing partialeq-anonfield join for comps Fix: return insert if not whitelisted Delegate TypeRefs and alias to constrain_join. Delegate Template instantiations to constrain_join Add derive-partialeq-pointer.hpp test Update comment. Fix layout alignment larger that array limit Add missing test for derive-partialeq-anonfield.rs Clean Clean Fix typo in opaque-template-inst-member test Remove redudant stmt Add comment on can_supersede. Format impl_partialeq and leave a comment Extract requires_storage into it's own function. Clean
Diffstat (limited to 'tests')
-rw-r--r--tests/expectations/tests/class_1_0.rs404
-rw-r--r--tests/expectations/tests/derive-partialeq-anonfield.rs57
-rw-r--r--tests/expectations/tests/derive-partialeq-base.rs82
-rw-r--r--tests/expectations/tests/derive-partialeq-bitfield.rs130
-rw-r--r--tests/expectations/tests/derive-partialeq-core.rs50
-rw-r--r--tests/expectations/tests/derive-partialeq-pointer.rs129
-rw-r--r--tests/expectations/tests/derive-partialeq-union.rs56
-rw-r--r--tests/expectations/tests/derive-partialeq-union_1_0.rs104
-rw-r--r--tests/expectations/tests/issue-648-derive-debug-with-padding.rs10
-rw-r--r--tests/expectations/tests/layout_array.rs374
-rw-r--r--tests/expectations/tests/layout_array_too_long.rs318
-rw-r--r--tests/expectations/tests/opaque-template-inst-member.rs104
-rw-r--r--tests/headers/class_1_0.hpp2
-rw-r--r--tests/headers/derive-partialeq-anonfield.h5
-rw-r--r--tests/headers/derive-partialeq-base.hpp8
-rw-r--r--tests/headers/derive-partialeq-bitfield.hpp7
-rw-r--r--tests/headers/derive-partialeq-core.h5
-rw-r--r--tests/headers/derive-partialeq-pointer.hpp12
-rw-r--r--tests/headers/derive-partialeq-union.hpp7
-rw-r--r--tests/headers/derive-partialeq-union_1_0.hpp7
-rw-r--r--tests/headers/issue-648-derive-debug-with-padding.h2
-rw-r--r--tests/headers/layout_array.h2
-rw-r--r--tests/headers/layout_array_too_long.h2
-rw-r--r--tests/headers/opaque-template-inst-member.hpp8
24 files changed, 1480 insertions, 405 deletions
diff --git a/tests/expectations/tests/class_1_0.rs b/tests/expectations/tests/class_1_0.rs
index 8ccf4e01..669b7364 100644
--- a/tests/expectations/tests/class_1_0.rs
+++ b/tests/expectations/tests/class_1_0.rs
@@ -7,13 +7,15 @@
#[repr(C)]
#[derive(Default)]
pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>);
-impl <T> __IncompleteArrayField<T> {
+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) }
+ 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)
@@ -27,47 +29,61 @@ impl <T> __IncompleteArrayField<T> {
::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
}
}
-impl <T> ::std::fmt::Debug for __IncompleteArrayField<T> {
+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> {
+impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
#[inline]
- fn clone(&self) -> Self { Self::new() }
+ fn clone(&self) -> Self {
+ Self::new()
+ }
}
-impl <T> ::std::marker::Copy for __IncompleteArrayField<T> { }
+impl<T> ::std::marker::Copy for __IncompleteArrayField<T> {}
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
-impl <T> __BindgenUnionField<T> {
+impl<T> __BindgenUnionField<T> {
#[inline]
- pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
+ pub fn new() -> Self {
+ __BindgenUnionField(::std::marker::PhantomData)
+ }
#[inline]
- pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
+ pub unsafe fn as_ref(&self) -> &T {
+ ::std::mem::transmute(self)
+ }
#[inline]
- pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
+ pub unsafe fn as_mut(&mut self) -> &mut T {
+ ::std::mem::transmute(self)
+ }
}
-impl <T> ::std::default::Default for __BindgenUnionField<T> {
+impl<T> ::std::default::Default for __BindgenUnionField<T> {
#[inline]
- fn default() -> Self { Self::new() }
+ fn default() -> Self {
+ Self::new()
+ }
}
-impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
+impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
#[inline]
- fn clone(&self) -> Self { Self::new() }
+ fn clone(&self) -> Self {
+ Self::new()
+ }
}
-impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
-impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
+impl<T> ::std::fmt::Debug for __BindgenUnionField<T> {
fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
-impl <T> ::std::hash::Hash for __BindgenUnionField<T> {
- fn hash<H: ::std::hash::Hasher>(&self, _state: &mut H) { }
+impl<T> ::std::hash::Hash for __BindgenUnionField<T> {
+ fn hash<H: ::std::hash::Hasher>(&self, _state: &mut H) {}
}
-impl <T> ::std::cmp::PartialEq for __BindgenUnionField<T> {
- fn eq(&self, _other: &__BindgenUnionField<T>) -> bool { true }
+impl<T> ::std::cmp::PartialEq for __BindgenUnionField<T> {
+ fn eq(&self, _other: &__BindgenUnionField<T>) -> bool {
+ true
+ }
}
-impl <T> ::std::cmp::Eq for __BindgenUnionField<T> { }
+impl<T> ::std::cmp::Eq for __BindgenUnionField<T> {}
#[repr(C)]
#[derive(Copy)]
pub struct C {
@@ -76,25 +92,46 @@ pub struct C {
}
#[test]
fn bindgen_test_layout_C() {
- assert_eq!(::std::mem::size_of::<C>() , 40usize , concat ! (
- "Size of: " , stringify ! ( C ) ));
- assert_eq! (::std::mem::align_of::<C>() , 4usize , concat ! (
- "Alignment of " , stringify ! ( C ) ));
- assert_eq! (unsafe { & ( * ( 0 as * const C ) ) . a as * const _ as usize
- } , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( C ) , "::" , stringify
- ! ( a ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const C ) ) . big_array as * const _ as usize }
- , 4usize , concat ! (
- "Alignment of field: " , stringify ! ( C ) , "::" , stringify
- ! ( big_array ) ));
+ assert_eq!(
+ ::std::mem::size_of::<C>(),
+ 40usize,
+ concat!("Size of: ", stringify!(C))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<C>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(C))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const C)).a as *const _ as usize },
+ 0usize,
+ concat!("Alignment of field: ", stringify!(C), "::", stringify!(a))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const C)).big_array as *const _ as usize },
+ 4usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(C),
+ "::",
+ stringify!(big_array)
+ )
+ );
}
impl Clone for C {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for C {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+impl ::std::cmp::PartialEq for C {
+ fn eq(&self, other: &C) -> bool {
+ self.a == other.a && &self.big_array[..] == &other.big_array[..]
+ }
}
#[repr(C)]
pub struct C_with_zero_length_array {
@@ -104,33 +141,53 @@ pub struct C_with_zero_length_array {
}
#[test]
fn bindgen_test_layout_C_with_zero_length_array() {
- assert_eq!(::std::mem::size_of::<C_with_zero_length_array>() , 40usize ,
- concat ! (
- "Size of: " , stringify ! ( C_with_zero_length_array ) ));
- assert_eq! (::std::mem::align_of::<C_with_zero_length_array>() , 4usize ,
- concat ! (
- "Alignment of " , stringify ! ( C_with_zero_length_array ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const C_with_zero_length_array ) ) . a as *
- const _ as usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! (
- C_with_zero_length_array ) , "::" , stringify ! ( a ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const C_with_zero_length_array ) ) . big_array
- as * const _ as usize } , 4usize , concat ! (
- "Alignment of field: " , stringify ! (
- C_with_zero_length_array ) , "::" , stringify ! ( big_array )
- ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const C_with_zero_length_array ) ) .
- zero_length_array as * const _ as usize } , 37usize , concat !
- (
- "Alignment of field: " , stringify ! (
- C_with_zero_length_array ) , "::" , stringify ! (
- zero_length_array ) ));
+ assert_eq!(
+ ::std::mem::size_of::<C_with_zero_length_array>(),
+ 40usize,
+ concat!("Size of: ", stringify!(C_with_zero_length_array))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<C_with_zero_length_array>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(C_with_zero_length_array))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const C_with_zero_length_array)).a as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(C_with_zero_length_array),
+ "::",
+ stringify!(a)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const C_with_zero_length_array)).big_array as *const _ as usize },
+ 4usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(C_with_zero_length_array),
+ "::",
+ stringify!(big_array)
+ )
+ );
+ assert_eq!(
+ unsafe {
+ &(*(0 as *const C_with_zero_length_array)).zero_length_array as *const _ as usize
+ },
+ 37usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(C_with_zero_length_array),
+ "::",
+ stringify!(zero_length_array)
+ )
+ );
}
impl Default for C_with_zero_length_array {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
pub struct C_with_incomplete_array {
@@ -140,15 +197,21 @@ pub struct C_with_incomplete_array {
}
#[test]
fn bindgen_test_layout_C_with_incomplete_array() {
- assert_eq!(::std::mem::size_of::<C_with_incomplete_array>() , 40usize ,
- concat ! (
- "Size of: " , stringify ! ( C_with_incomplete_array ) ));
- assert_eq! (::std::mem::align_of::<C_with_incomplete_array>() , 4usize ,
- concat ! (
- "Alignment of " , stringify ! ( C_with_incomplete_array ) ));
+ assert_eq!(
+ ::std::mem::size_of::<C_with_incomplete_array>(),
+ 40usize,
+ concat!("Size of: ", stringify!(C_with_incomplete_array))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<C_with_incomplete_array>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(C_with_incomplete_array))
+ );
}
impl Default for C_with_incomplete_array {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
pub struct C_with_zero_length_array_and_incomplete_array {
@@ -159,17 +222,27 @@ pub struct C_with_zero_length_array_and_incomplete_array {
}
#[test]
fn bindgen_test_layout_C_with_zero_length_array_and_incomplete_array() {
- assert_eq!(::std::mem::size_of::<C_with_zero_length_array_and_incomplete_array>()
- , 40usize , concat ! (
- "Size of: " , stringify ! (
- C_with_zero_length_array_and_incomplete_array ) ));
- assert_eq! (::std::mem::align_of::<C_with_zero_length_array_and_incomplete_array>()
- , 4usize , concat ! (
- "Alignment of " , stringify ! (
- C_with_zero_length_array_and_incomplete_array ) ));
+ assert_eq!(
+ ::std::mem::size_of::<C_with_zero_length_array_and_incomplete_array>(),
+ 40usize,
+ concat!(
+ "Size of: ",
+ stringify!(C_with_zero_length_array_and_incomplete_array)
+ )
+ );
+ assert_eq!(
+ ::std::mem::align_of::<C_with_zero_length_array_and_incomplete_array>(),
+ 4usize,
+ concat!(
+ "Alignment of ",
+ stringify!(C_with_zero_length_array_and_incomplete_array)
+ )
+ );
}
impl Default for C_with_zero_length_array_and_incomplete_array {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Default, Hash, PartialEq, Eq)]
@@ -178,15 +251,26 @@ pub struct WithDtor {
}
#[test]
fn bindgen_test_layout_WithDtor() {
- assert_eq!(::std::mem::size_of::<WithDtor>() , 4usize , concat ! (
- "Size of: " , stringify ! ( WithDtor ) ));
- assert_eq! (::std::mem::align_of::<WithDtor>() , 4usize , concat ! (
- "Alignment of " , stringify ! ( WithDtor ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const WithDtor ) ) . b as * const _ as usize }
- , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( WithDtor ) , "::" ,
- stringify ! ( b ) ));
+ assert_eq!(
+ ::std::mem::size_of::<WithDtor>(),
+ 4usize,
+ concat!("Size of: ", stringify!(WithDtor))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<WithDtor>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(WithDtor))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const WithDtor)).b as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(WithDtor),
+ "::",
+ stringify!(b)
+ )
+ );
}
#[repr(C)]
pub struct IncompleteArrayNonCopiable {
@@ -195,16 +279,21 @@ pub struct IncompleteArrayNonCopiable {
}
#[test]
fn bindgen_test_layout_IncompleteArrayNonCopiable() {
- assert_eq!(::std::mem::size_of::<IncompleteArrayNonCopiable>() , 8usize ,
- concat ! (
- "Size of: " , stringify ! ( IncompleteArrayNonCopiable ) ));
- assert_eq! (::std::mem::align_of::<IncompleteArrayNonCopiable>() , 8usize
- , concat ! (
- "Alignment of " , stringify ! ( IncompleteArrayNonCopiable )
- ));
+ assert_eq!(
+ ::std::mem::size_of::<IncompleteArrayNonCopiable>(),
+ 8usize,
+ concat!("Size of: ", stringify!(IncompleteArrayNonCopiable))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<IncompleteArrayNonCopiable>(),
+ 8usize,
+ concat!("Alignment of ", stringify!(IncompleteArrayNonCopiable))
+ );
}
impl Default for IncompleteArrayNonCopiable {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq)]
@@ -215,23 +304,41 @@ pub struct Union {
}
#[test]
fn bindgen_test_layout_Union() {
- assert_eq!(::std::mem::size_of::<Union>() , 4usize , concat ! (
- "Size of: " , stringify ! ( Union ) ));
- assert_eq! (::std::mem::align_of::<Union>() , 4usize , concat ! (
- "Alignment of " , stringify ! ( Union ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const Union ) ) . d as * const _ as usize } ,
- 0usize , concat ! (
- "Alignment of field: " , stringify ! ( Union ) , "::" ,
- stringify ! ( d ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const Union ) ) . i as * const _ as usize } ,
- 0usize , concat ! (
- "Alignment of field: " , stringify ! ( Union ) , "::" ,
- stringify ! ( i ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Union>(),
+ 4usize,
+ concat!("Size of: ", stringify!(Union))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Union>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(Union))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const Union)).d as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(Union),
+ "::",
+ stringify!(d)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const Union)).i as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(Union),
+ "::",
+ stringify!(i)
+ )
+ );
}
impl Clone for Union {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq)]
@@ -240,18 +347,31 @@ pub struct WithUnion {
}
#[test]
fn bindgen_test_layout_WithUnion() {
- assert_eq!(::std::mem::size_of::<WithUnion>() , 4usize , concat ! (
- "Size of: " , stringify ! ( WithUnion ) ));
- assert_eq! (::std::mem::align_of::<WithUnion>() , 4usize , concat ! (
- "Alignment of " , stringify ! ( WithUnion ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const WithUnion ) ) . data as * const _ as
- usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( WithUnion ) , "::" ,
- stringify ! ( data ) ));
+ assert_eq!(
+ ::std::mem::size_of::<WithUnion>(),
+ 4usize,
+ concat!("Size of: ", stringify!(WithUnion))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<WithUnion>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(WithUnion))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const WithUnion)).data as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(WithUnion),
+ "::",
+ stringify!(data)
+ )
+ );
}
impl Clone for WithUnion {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
@@ -260,41 +380,49 @@ pub struct RealAbstractionWithTonsOfMethods {
}
#[test]
fn bindgen_test_layout_RealAbstractionWithTonsOfMethods() {
- assert_eq!(::std::mem::size_of::<RealAbstractionWithTonsOfMethods>() ,
- 1usize , concat ! (
- "Size of: " , stringify ! ( RealAbstractionWithTonsOfMethods )
- ));
- assert_eq! (::std::mem::align_of::<RealAbstractionWithTonsOfMethods>() ,
- 1usize , concat ! (
- "Alignment of " , stringify ! (
- RealAbstractionWithTonsOfMethods ) ));
+ assert_eq!(
+ ::std::mem::size_of::<RealAbstractionWithTonsOfMethods>(),
+ 1usize,
+ concat!("Size of: ", stringify!(RealAbstractionWithTonsOfMethods))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<RealAbstractionWithTonsOfMethods>(),
+ 1usize,
+ concat!(
+ "Alignment of ",
+ stringify!(RealAbstractionWithTonsOfMethods)
+ )
+ );
}
extern "C" {
#[link_name = "_ZNK32RealAbstractionWithTonsOfMethods3barEv"]
- pub fn RealAbstractionWithTonsOfMethods_bar(this:
- *const RealAbstractionWithTonsOfMethods);
+ pub fn RealAbstractionWithTonsOfMethods_bar(this: *const RealAbstractionWithTonsOfMethods);
}
extern "C" {
#[link_name = "_ZN32RealAbstractionWithTonsOfMethods3barEv"]
- pub fn RealAbstractionWithTonsOfMethods_bar1(this:
- *mut RealAbstractionWithTonsOfMethods);
+ pub fn RealAbstractionWithTonsOfMethods_bar1(this: *mut RealAbstractionWithTonsOfMethods);
}
extern "C" {
#[link_name = "_ZN32RealAbstractionWithTonsOfMethods3barEi"]
- pub fn RealAbstractionWithTonsOfMethods_bar2(this:
- *mut RealAbstractionWithTonsOfMethods,
- foo: ::std::os::raw::c_int);
+ pub fn RealAbstractionWithTonsOfMethods_bar2(
+ this: *mut RealAbstractionWithTonsOfMethods,
+ foo: ::std::os::raw::c_int,
+ );
}
extern "C" {
#[link_name = "_ZN32RealAbstractionWithTonsOfMethods3staEv"]
pub fn RealAbstractionWithTonsOfMethods_sta();
}
impl Clone for RealAbstractionWithTonsOfMethods {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl RealAbstractionWithTonsOfMethods {
#[inline]
- pub unsafe fn bar(&self) { RealAbstractionWithTonsOfMethods_bar(self) }
+ pub unsafe fn bar(&self) {
+ RealAbstractionWithTonsOfMethods_bar(self)
+ }
#[inline]
pub unsafe fn bar1(&mut self) {
RealAbstractionWithTonsOfMethods_bar1(self)
@@ -304,5 +432,7 @@ impl RealAbstractionWithTonsOfMethods {
RealAbstractionWithTonsOfMethods_bar2(self, foo)
}
#[inline]
- pub unsafe fn sta() { RealAbstractionWithTonsOfMethods_sta() }
+ pub unsafe fn sta() {
+ RealAbstractionWithTonsOfMethods_sta()
+ }
}
diff --git a/tests/expectations/tests/derive-partialeq-anonfield.rs b/tests/expectations/tests/derive-partialeq-anonfield.rs
new file mode 100644
index 00000000..6e3446d5
--- /dev/null
+++ b/tests/expectations/tests/derive-partialeq-anonfield.rs
@@ -0,0 +1,57 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
+
+#[repr(C)]
+#[derive(Copy)]
+pub struct rte_mbuf {
+ pub __bindgen_anon_1: rte_mbuf__bindgen_ty_1,
+}
+#[repr(C)]
+#[derive(Copy)]
+pub union rte_mbuf__bindgen_ty_1 {
+ _bindgen_union_align: [u8; 0usize],
+}
+#[test]
+fn bindgen_test_layout_rte_mbuf__bindgen_ty_1() {
+ assert_eq!(
+ ::std::mem::size_of::<rte_mbuf__bindgen_ty_1>(),
+ 0usize,
+ concat!("Size of: ", stringify!(rte_mbuf__bindgen_ty_1))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_mbuf__bindgen_ty_1>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(rte_mbuf__bindgen_ty_1))
+ );
+}
+impl Clone for rte_mbuf__bindgen_ty_1 {
+ fn clone(&self) -> Self {
+ *self
+ }
+}
+impl Default for rte_mbuf__bindgen_ty_1 {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+#[test]
+fn bindgen_test_layout_rte_mbuf() {
+ assert_eq!(
+ ::std::mem::size_of::<rte_mbuf>(),
+ 0usize,
+ concat!("Size of: ", stringify!(rte_mbuf))
+ );
+}
+impl Clone for rte_mbuf {
+ fn clone(&self) -> Self {
+ *self
+ }
+}
+impl Default for rte_mbuf {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
diff --git a/tests/expectations/tests/derive-partialeq-base.rs b/tests/expectations/tests/derive-partialeq-base.rs
new file mode 100644
index 00000000..12356655
--- /dev/null
+++ b/tests/expectations/tests/derive-partialeq-base.rs
@@ -0,0 +1,82 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
+
+#[repr(C)]
+#[derive(Copy)]
+pub struct Base {
+ pub large: [::std::os::raw::c_int; 33usize],
+}
+#[test]
+fn bindgen_test_layout_Base() {
+ assert_eq!(
+ ::std::mem::size_of::<Base>(),
+ 132usize,
+ concat!("Size of: ", stringify!(Base))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Base>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(Base))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const Base)).large as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(Base),
+ "::",
+ stringify!(large)
+ )
+ );
+}
+impl Clone for Base {
+ fn clone(&self) -> Self {
+ *self
+ }
+}
+impl Default for Base {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+impl ::std::cmp::PartialEq for Base {
+ fn eq(&self, other: &Base) -> bool {
+ &self.large[..] == &other.large[..]
+ }
+}
+#[repr(C)]
+#[derive(Copy)]
+pub struct ShouldDerivePartialEq {
+ pub _base: Base,
+}
+#[test]
+fn bindgen_test_layout_ShouldDerivePartialEq() {
+ assert_eq!(
+ ::std::mem::size_of::<ShouldDerivePartialEq>(),
+ 132usize,
+ concat!("Size of: ", stringify!(ShouldDerivePartialEq))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<ShouldDerivePartialEq>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(ShouldDerivePartialEq))
+ );
+}
+impl Clone for ShouldDerivePartialEq {
+ fn clone(&self) -> Self {
+ *self
+ }
+}
+impl Default for ShouldDerivePartialEq {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+impl ::std::cmp::PartialEq for ShouldDerivePartialEq {
+ fn eq(&self, other: &ShouldDerivePartialEq) -> bool {
+ self._base == other._base
+ }
+}
diff --git a/tests/expectations/tests/derive-partialeq-bitfield.rs b/tests/expectations/tests/derive-partialeq-bitfield.rs
new file mode 100644
index 00000000..b788f6c3
--- /dev/null
+++ b/tests/expectations/tests/derive-partialeq-bitfield.rs
@@ -0,0 +1,130 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
+
+#[repr(C)]
+#[derive(Copy)]
+pub struct C {
+ pub _bitfield_1: u8,
+ pub large_array: [::std::os::raw::c_int; 50usize],
+}
+#[test]
+fn bindgen_test_layout_C() {
+ assert_eq!(
+ ::std::mem::size_of::<C>(),
+ 204usize,
+ concat!("Size of: ", stringify!(C))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<C>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(C))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const C)).large_array as *const _ as usize },
+ 4usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(C),
+ "::",
+ stringify!(large_array)
+ )
+ );
+}
+impl Clone for C {
+ fn clone(&self) -> Self {
+ *self
+ }
+}
+impl Default for C {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+impl ::std::cmp::PartialEq for C {
+ fn eq(&self, other: &C) -> bool {
+ self.a() == other.a() && self.b() == other.b() &&
+ &self.large_array[..] == &other.large_array[..]
+ }
+}
+impl C {
+ #[inline]
+ pub fn a(&self) -> bool {
+ let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
+ unsafe {
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
+ };
+ let mask = 1u64 as u8;
+ let val = (unit_field_val & mask) >> 0usize;
+ unsafe { ::std::mem::transmute(val as u8) }
+ }
+ #[inline]
+ pub fn set_a(&mut self, val: bool) {
+ let mask = 1u64 as u8;
+ let val = val as u8 as u8;
+ let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
+ unsafe {
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
+ };
+ unit_field_val &= !mask;
+ unit_field_val |= (val << 0usize) & mask;
+ unsafe {
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ );
+ }
+ }
+ #[inline]
+ pub fn b(&self) -> bool {
+ let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
+ unsafe {
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
+ };
+ let mask = 254u64 as u8;
+ let val = (unit_field_val & mask) >> 1usize;
+ unsafe { ::std::mem::transmute(val as u8) }
+ }
+ #[inline]
+ pub fn set_b(&mut self, val: bool) {
+ let mask = 254u64 as u8;
+ let val = val as u8 as u8;
+ let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
+ unsafe {
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
+ };
+ unit_field_val &= !mask;
+ unit_field_val |= (val << 1usize) & mask;
+ unsafe {
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ );
+ }
+ }
+ #[inline]
+ pub fn new_bitfield_1(a: bool, b: bool) -> u8 {
+ ((0 | ((a as u8 as u8) << 0usize) & (1u64 as u8)) |
+ ((b as u8 as u8) << 1usize) & (254u64 as u8))
+ }
+}
diff --git a/tests/expectations/tests/derive-partialeq-core.rs b/tests/expectations/tests/derive-partialeq-core.rs
new file mode 100644
index 00000000..1660f178
--- /dev/null
+++ b/tests/expectations/tests/derive-partialeq-core.rs
@@ -0,0 +1,50 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
+extern crate core;
+
+#[repr(C)]
+#[derive(Copy)]
+pub struct C {
+ pub large_array: [::std::os::raw::c_int; 420usize],
+}
+#[test]
+fn bindgen_test_layout_C() {
+ assert_eq!(
+ ::core::mem::size_of::<C>(),
+ 1680usize,
+ concat!("Size of: ", stringify!(C))
+ );
+ assert_eq!(
+ ::core::mem::align_of::<C>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(C))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const C)).large_array as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(C),
+ "::",
+ stringify!(large_array)
+ )
+ );
+}
+impl Clone for C {
+ fn clone(&self) -> Self {
+ *self
+ }
+}
+impl Default for C {
+ fn default() -> Self {
+ unsafe { ::core::mem::zeroed() }
+ }
+}
+impl ::core::cmp::PartialEq for C {
+ fn eq(&self, other: &C) -> bool {
+ &self.large_array[..] == &other.large_array[..]
+ }
+}
diff --git a/tests/expectations/tests/derive-partialeq-pointer.rs b/tests/expectations/tests/derive-partialeq-pointer.rs
new file mode 100644
index 00000000..b1d3f04c
--- /dev/null
+++ b/tests/expectations/tests/derive-partialeq-pointer.rs
@@ -0,0 +1,129 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy, Hash, PartialEq, Eq)]
+pub struct Bar {
+ pub b: *mut a,
+}
+#[test]
+fn bindgen_test_layout_Bar() {
+ assert_eq!(
+ ::std::mem::size_of::<Bar>(),
+ 8usize,
+ concat!("Size of: ", stringify!(Bar))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Bar>(),
+ 8usize,
+ concat!("Alignment of ", stringify!(Bar))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const Bar)).b as *const _ as usize },
+ 0usize,
+ concat!("Alignment of field: ", stringify!(Bar), "::", stringify!(b))
+ );
+}
+impl Clone for Bar {
+ fn clone(&self) -> Self {
+ *self
+ }
+}
+impl Default for Bar {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+#[repr(C)]
+#[derive(Copy)]
+pub struct c {
+ pub __bindgen_anon_1: c__bindgen_ty_1,
+}
+#[repr(C)]
+#[derive(Copy)]
+pub union c__bindgen_ty_1 {
+ _bindgen_union_align: u8,
+ pub _address: u8,
+}
+#[test]
+fn bindgen_test_layout_c__bindgen_ty_1() {
+ assert_eq!(
+ ::std::mem::size_of::<c__bindgen_ty_1>(),
+ 1usize,
+ concat!("Size of: ", stringify!(c__bindgen_ty_1))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<c__bindgen_ty_1>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(c__bindgen_ty_1))
+ );
+}
+impl Clone for c__bindgen_ty_1 {
+ fn clone(&self) -> Self {
+ *self
+ }
+}
+impl Default for c__bindgen_ty_1 {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+#[test]
+fn bindgen_test_layout_c() {
+ assert_eq!(
+ ::std::mem::size_of::<c>(),
+ 1usize,
+ concat!("Size of: ", stringify!(c))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<c>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(c))
+ );
+}
+impl Clone for c {
+ fn clone(&self) -> Self {
+ *self
+ }
+}
+impl Default for c {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+#[repr(C)]
+#[derive(Copy)]
+pub struct a {
+ pub d: c,
+}
+#[test]
+fn bindgen_test_layout_a() {
+ assert_eq!(
+ ::std::mem::size_of::<a>(),
+ 1usize,
+ concat!("Size of: ", stringify!(a))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<a>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(a))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const a)).d as *const _ as usize },
+ 0usize,
+ concat!("Alignment of field: ", stringify!(a), "::", stringify!(d))
+ );
+}
+impl Clone for a {
+ fn clone(&self) -> Self {
+ *self
+ }
+}
+impl Default for a {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
diff --git a/tests/expectations/tests/derive-partialeq-union.rs b/tests/expectations/tests/derive-partialeq-union.rs
new file mode 100644
index 00000000..dfb5a5ae
--- /dev/null
+++ b/tests/expectations/tests/derive-partialeq-union.rs
@@ -0,0 +1,56 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
+
+#[repr(C)]
+#[derive(Copy)]
+pub union ShouldNotDerivePartialEq {
+ pub a: ::std::os::raw::c_char,
+ pub b: ::std::os::raw::c_int,
+ _bindgen_union_align: u32,
+}
+#[test]
+fn bindgen_test_layout_ShouldNotDerivePartialEq() {
+ assert_eq!(
+ ::std::mem::size_of::<ShouldNotDerivePartialEq>(),
+ 4usize,
+ concat!("Size of: ", stringify!(ShouldNotDerivePartialEq))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<ShouldNotDerivePartialEq>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(ShouldNotDerivePartialEq))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ShouldNotDerivePartialEq)).a as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ShouldNotDerivePartialEq),
+ "::",
+ stringify!(a)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ShouldNotDerivePartialEq)).b as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ShouldNotDerivePartialEq),
+ "::",
+ stringify!(b)
+ )
+ );
+}
+impl Clone for ShouldNotDerivePartialEq {
+ fn clone(&self) -> Self {
+ *self
+ }
+}
+impl Default for ShouldNotDerivePartialEq {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
diff --git a/tests/expectations/tests/derive-partialeq-union_1_0.rs b/tests/expectations/tests/derive-partialeq-union_1_0.rs
new file mode 100644
index 00000000..f5d30f03
--- /dev/null
+++ b/tests/expectations/tests/derive-partialeq-union_1_0.rs
@@ -0,0 +1,104 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
+
+#[repr(C)]
+pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
+impl<T> __BindgenUnionField<T> {
+ #[inline]
+ pub fn new() -> Self {
+ __BindgenUnionField(::std::marker::PhantomData)
+ }
+ #[inline]
+ pub unsafe fn as_ref(&self) -> &T {
+ ::std::mem::transmute(self)
+ }
+ #[inline]
+ pub unsafe fn as_mut(&mut self) -> &mut T {
+ ::std::mem::transmute(self)
+ }
+}
+impl<T> ::std::default::Default for __BindgenUnionField<T> {
+ #[inline]
+ fn default() -> Self {
+ Self::new()
+ }
+}
+impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
+ #[inline]
+ fn clone(&self) -> Self {
+ Self::new()
+ }
+}
+impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
+impl<T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
+impl<T> ::std::hash::Hash for __BindgenUnionField<T> {
+ fn hash<H: ::std::hash::Hasher>(&self, _state: &mut H) {}
+}
+impl<T> ::std::cmp::PartialEq for __BindgenUnionField<T> {
+ fn eq(&self, _other: &__BindgenUnionField<T>) -> bool {
+ true
+ }
+}
+impl<T> ::std::cmp::Eq for __BindgenUnionField<T> {}
+#[repr(C)]
+#[derive(Copy)]
+pub struct ShouldDerivePartialEq {
+ pub a: __BindgenUnionField<[::std::os::raw::c_char; 150usize]>,
+ pub b: __BindgenUnionField<::std::os::raw::c_int>,
+ pub bindgen_union_field: [u32; 38usize],
+}
+#[test]
+fn bindgen_test_layout_ShouldDerivePartialEq() {
+ assert_eq!(
+ ::std::mem::size_of::<ShouldDerivePartialEq>(),
+ 152usize,
+ concat!("Size of: ", stringify!(ShouldDerivePartialEq))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<ShouldDerivePartialEq>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(ShouldDerivePartialEq))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ShouldDerivePartialEq)).a as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ShouldDerivePartialEq),
+ "::",
+ stringify!(a)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ShouldDerivePartialEq)).b as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ShouldDerivePartialEq),
+ "::",
+ stringify!(b)
+ )
+ );
+}
+impl Clone for ShouldDerivePartialEq {
+ fn clone(&self) -> Self {
+ *self
+ }
+}
+impl Default for ShouldDerivePartialEq {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+impl ::std::cmp::PartialEq for ShouldDerivePartialEq {
+ fn eq(&self, other: &ShouldDerivePartialEq) -> bool {
+ &self.bindgen_union_field[..] == &other.bindgen_union_field[..]
+ }
+}
diff --git a/tests/expectations/tests/issue-648-derive-debug-with-padding.rs b/tests/expectations/tests/issue-648-derive-debug-with-padding.rs
index 27b5cfcd..11c318a2 100644
--- a/tests/expectations/tests/issue-648-derive-debug-with-padding.rs
+++ b/tests/expectations/tests/issue-648-derive-debug-with-padding.rs
@@ -43,6 +43,11 @@ impl Default for NoDebug {
unsafe { ::std::mem::zeroed() }
}
}
+impl ::std::cmp::PartialEq for NoDebug {
+ fn eq(&self, other: &NoDebug) -> bool {
+ self.c == other.c
+ }
+}
/// This should derive Debug/Hash/PartialEq/Eq because the padding size is less than the max derive
/// Debug/Hash/PartialEq/Eq impl for arrays. However, we conservatively don't derive Debug/Hash because
/// we determine Debug derive-ability before we compute padding, which happens at
@@ -92,3 +97,8 @@ impl Default for ShouldDeriveDebugButDoesNot {
unsafe { ::std::mem::zeroed() }
}
}
+impl ::std::cmp::PartialEq for ShouldDeriveDebugButDoesNot {
+ fn eq(&self, other: &ShouldDeriveDebugButDoesNot) -> bool {
+ self.c == other.c && self.d == other.d
+ }
+}
diff --git a/tests/expectations/tests/layout_array.rs b/tests/expectations/tests/layout_array.rs
index 9f2082ec..c1a15187 100644
--- a/tests/expectations/tests/layout_array.rs
+++ b/tests/expectations/tests/layout_array.rs
@@ -21,30 +21,32 @@ pub struct rte_mempool {
/// it will most likely point to a different type of data structure, and
/// will be transparent to the application programmer.
/// This function should set mp->pool_data.
-pub type rte_mempool_alloc_t =
- ::std::option::Option<unsafe extern "C" fn(mp: *mut rte_mempool)
- -> ::std::os::raw::c_int>;
+pub type rte_mempool_alloc_t = ::std::option::Option<
+ unsafe extern "C" fn(mp: *mut rte_mempool) -> ::std::os::raw::c_int,
+>;
/// Free the opaque private data pointed to by mp->pool_data pointer.
-pub type rte_mempool_free_t =
- ::std::option::Option<unsafe extern "C" fn(mp: *mut rte_mempool)>;
+pub type rte_mempool_free_t = ::std::option::Option<unsafe extern "C" fn(mp: *mut rte_mempool)>;
/// Enqueue an object into the external pool.
-pub type rte_mempool_enqueue_t =
- ::std::option::Option<unsafe extern "C" fn(mp: *mut rte_mempool,
- obj_table:
- *const *const ::std::os::raw::c_void,
- n: ::std::os::raw::c_uint)
- -> ::std::os::raw::c_int>;
+pub type rte_mempool_enqueue_t = ::std::option::Option<
+ unsafe extern "C" fn(
+ mp: *mut rte_mempool,
+ obj_table: *const *const ::std::os::raw::c_void,
+ n: ::std::os::raw::c_uint,
+ ) -> ::std::os::raw::c_int,
+>;
/// Dequeue an object from the external pool.
-pub type rte_mempool_dequeue_t =
- ::std::option::Option<unsafe extern "C" fn(mp: *mut rte_mempool,
- obj_table:
- *mut *mut ::std::os::raw::c_void,
- n: ::std::os::raw::c_uint)
- -> ::std::os::raw::c_int>;
+pub type rte_mempool_dequeue_t = ::std::option::Option<
+ unsafe extern "C" fn(
+ mp: *mut rte_mempool,
+ obj_table: *mut *mut ::std::os::raw::c_void,
+ n: ::std::os::raw::c_uint,
+ ) -> ::std::os::raw::c_int,
+>;
/// Return the number of available objects in the external pool.
-pub type rte_mempool_get_count =
- ::std::option::Option<unsafe extern "C" fn(mp: *const rte_mempool)
- -> ::std::os::raw::c_uint>;
+pub type rte_mempool_get_count = ::std::option::Option<
+ unsafe extern "C" fn(mp: *const rte_mempool)
+ -> ::std::os::raw::c_uint,
+>;
/// Structure defining mempool operations structure
#[repr(C)]
#[derive(Copy)]
@@ -65,44 +67,88 @@ pub struct rte_mempool_ops {
}
#[test]
fn bindgen_test_layout_rte_mempool_ops() {
- assert_eq!(::std::mem::size_of::<rte_mempool_ops>() , 128usize , concat !
- ( "Size of: " , stringify ! ( rte_mempool_ops ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const rte_mempool_ops ) ) . name as * const _
- as usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( rte_mempool_ops ) ,
- "::" , stringify ! ( name ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const rte_mempool_ops ) ) . alloc as * const _
- as usize } , 32usize , concat ! (
- "Alignment of field: " , stringify ! ( rte_mempool_ops ) ,
- "::" , stringify ! ( alloc ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const rte_mempool_ops ) ) . free as * const _
- as usize } , 40usize , concat ! (
- "Alignment of field: " , stringify ! ( rte_mempool_ops ) ,
- "::" , stringify ! ( free ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const rte_mempool_ops ) ) . enqueue as * const
- _ as usize } , 48usize , concat ! (
- "Alignment of field: " , stringify ! ( rte_mempool_ops ) ,
- "::" , stringify ! ( enqueue ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const rte_mempool_ops ) ) . dequeue as * const
- _ as usize } , 56usize , concat ! (
- "Alignment of field: " , stringify ! ( rte_mempool_ops ) ,
- "::" , stringify ! ( dequeue ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const rte_mempool_ops ) ) . get_count as *
- const _ as usize } , 64usize , concat ! (
- "Alignment of field: " , stringify ! ( rte_mempool_ops ) ,
- "::" , stringify ! ( get_count ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_mempool_ops>(),
+ 128usize,
+ concat!("Size of: ", stringify!(rte_mempool_ops))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const rte_mempool_ops)).name as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(rte_mempool_ops),
+ "::",
+ stringify!(name)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const rte_mempool_ops)).alloc as *const _ as usize },
+ 32usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(rte_mempool_ops),
+ "::",
+ stringify!(alloc)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const rte_mempool_ops)).free as *const _ as usize },
+ 40usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(rte_mempool_ops),
+ "::",
+ stringify!(free)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const rte_mempool_ops)).enqueue as *const _ as usize },
+ 48usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(rte_mempool_ops),
+ "::",
+ stringify!(enqueue)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const rte_mempool_ops)).dequeue as *const _ as usize },
+ 56usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(rte_mempool_ops),
+ "::",
+ stringify!(dequeue)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const rte_mempool_ops)).get_count as *const _ as usize },
+ 64usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(rte_mempool_ops),
+ "::",
+ stringify!(get_count)
+ )
+ );
}
impl Clone for rte_mempool_ops {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_mempool_ops {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+impl ::std::cmp::PartialEq for rte_mempool_ops {
+ fn eq(&self, other: &rte_mempool_ops) -> bool {
+ self.name == other.name && self.alloc == other.alloc && self.free == other.free
+ && self.enqueue == other.enqueue && self.dequeue == other.dequeue
+ && self.get_count == other.get_count
+ }
}
/// The rte_spinlock_t type.
#[repr(C)]
@@ -113,18 +159,31 @@ pub struct rte_spinlock_t {
}
#[test]
fn bindgen_test_layout_rte_spinlock_t() {
- assert_eq!(::std::mem::size_of::<rte_spinlock_t>() , 4usize , concat ! (
- "Size of: " , stringify ! ( rte_spinlock_t ) ));
- assert_eq! (::std::mem::align_of::<rte_spinlock_t>() , 4usize , concat ! (
- "Alignment of " , stringify ! ( rte_spinlock_t ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const rte_spinlock_t ) ) . locked as * const _
- as usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( rte_spinlock_t ) , "::"
- , stringify ! ( locked ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_spinlock_t>(),
+ 4usize,
+ concat!("Size of: ", stringify!(rte_spinlock_t))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_spinlock_t>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(rte_spinlock_t))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const rte_spinlock_t)).locked as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(rte_spinlock_t),
+ "::",
+ stringify!(locked)
+ )
+ );
}
impl Clone for rte_spinlock_t {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
/// Structure storing the table of registered ops structs, each of which contain
/// the function pointers for the mempool ops functions.
@@ -146,30 +205,51 @@ pub struct rte_mempool_ops_table {
}
#[test]
fn bindgen_test_layout_rte_mempool_ops_table() {
- assert_eq!(::std::mem::size_of::<rte_mempool_ops_table>() , 2112usize ,
- concat ! ( "Size of: " , stringify ! ( rte_mempool_ops_table )
- ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const rte_mempool_ops_table ) ) . sl as * const
- _ as usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( rte_mempool_ops_table )
- , "::" , stringify ! ( sl ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const rte_mempool_ops_table ) ) . num_ops as *
- const _ as usize } , 4usize , concat ! (
- "Alignment of field: " , stringify ! ( rte_mempool_ops_table )
- , "::" , stringify ! ( num_ops ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const rte_mempool_ops_table ) ) . ops as *
- const _ as usize } , 64usize , concat ! (
- "Alignment of field: " , stringify ! ( rte_mempool_ops_table )
- , "::" , stringify ! ( ops ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_mempool_ops_table>(),
+ 2112usize,
+ concat!("Size of: ", stringify!(rte_mempool_ops_table))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const rte_mempool_ops_table)).sl as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(rte_mempool_ops_table),
+ "::",
+ stringify!(sl)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const rte_mempool_ops_table)).num_ops as *const _ as usize },
+ 4usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(rte_mempool_ops_table),
+ "::",
+ stringify!(num_ops)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const rte_mempool_ops_table)).ops as *const _ as usize },
+ 64usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(rte_mempool_ops_table),
+ "::",
+ stringify!(ops)
+ )
+ );
}
impl Clone for rte_mempool_ops_table {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_mempool_ops_table {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
/// Structure to hold malloc heap
#[repr(C)]
@@ -187,56 +267,100 @@ pub struct malloc_heap__bindgen_ty_1 {
}
#[test]
fn bindgen_test_layout_malloc_heap__bindgen_ty_1() {
- assert_eq!(::std::mem::size_of::<malloc_heap__bindgen_ty_1>() , 8usize ,
- concat ! (
- "Size of: " , stringify ! ( malloc_heap__bindgen_ty_1 ) ));
- assert_eq! (::std::mem::align_of::<malloc_heap__bindgen_ty_1>() , 8usize ,
- concat ! (
- "Alignment of " , stringify ! ( malloc_heap__bindgen_ty_1 )
- ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const malloc_heap__bindgen_ty_1 ) ) . lh_first
- as * const _ as usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! (
- malloc_heap__bindgen_ty_1 ) , "::" , stringify ! ( lh_first )
- ));
+ assert_eq!(
+ ::std::mem::size_of::<malloc_heap__bindgen_ty_1>(),
+ 8usize,
+ concat!("Size of: ", stringify!(malloc_heap__bindgen_ty_1))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<malloc_heap__bindgen_ty_1>(),
+ 8usize,
+ concat!("Alignment of ", stringify!(malloc_heap__bindgen_ty_1))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const malloc_heap__bindgen_ty_1)).lh_first as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(malloc_heap__bindgen_ty_1),
+ "::",
+ stringify!(lh_first)
+ )
+ );
}
impl Clone for malloc_heap__bindgen_ty_1 {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for malloc_heap__bindgen_ty_1 {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[test]
fn bindgen_test_layout_malloc_heap() {
- assert_eq!(::std::mem::size_of::<malloc_heap>() , 128usize , concat ! (
- "Size of: " , stringify ! ( malloc_heap ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const malloc_heap ) ) . lock as * const _ as
- usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( malloc_heap ) , "::" ,
- stringify ! ( lock ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const malloc_heap ) ) . free_head as * const _
- as usize } , 8usize , concat ! (
- "Alignment of field: " , stringify ! ( malloc_heap ) , "::" ,
- stringify ! ( free_head ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const malloc_heap ) ) . alloc_count as * const
- _ as usize } , 112usize , concat ! (
- "Alignment of field: " , stringify ! ( malloc_heap ) , "::" ,
- stringify ! ( alloc_count ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const malloc_heap ) ) . total_size as * const _
- as usize } , 120usize , concat ! (
- "Alignment of field: " , stringify ! ( malloc_heap ) , "::" ,
- stringify ! ( total_size ) ));
+ assert_eq!(
+ ::std::mem::size_of::<malloc_heap>(),
+ 128usize,
+ concat!("Size of: ", stringify!(malloc_heap))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const malloc_heap)).lock as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(malloc_heap),
+ "::",
+ stringify!(lock)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const malloc_heap)).free_head as *const _ as usize },
+ 8usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(malloc_heap),
+ "::",
+ stringify!(free_head)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const malloc_heap)).alloc_count as *const _ as usize },
+ 112usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(malloc_heap),
+ "::",
+ stringify!(alloc_count)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const malloc_heap)).total_size as *const _ as usize },
+ 120usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(malloc_heap),
+ "::",
+ stringify!(total_size)
+ )
+ );
}
impl Clone for malloc_heap {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for malloc_heap {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+impl ::std::cmp::PartialEq for malloc_heap {
+ fn eq(&self, other: &malloc_heap) -> bool {
+ self.lock == other.lock && self.free_head == other.free_head
+ && self.alloc_count == other.alloc_count && self.total_size == other.total_size
+ }
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
@@ -244,5 +368,7 @@ pub struct malloc_elem {
pub _address: u8,
}
impl Clone for malloc_elem {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
diff --git a/tests/expectations/tests/layout_array_too_long.rs b/tests/expectations/tests/layout_array_too_long.rs
index 1a3da41e..6cfd85a4 100644
--- a/tests/expectations/tests/layout_array_too_long.rs
+++ b/tests/expectations/tests/layout_array_too_long.rs
@@ -31,31 +31,56 @@ pub struct ip_frag {
}
#[test]
fn bindgen_test_layout_ip_frag() {
- assert_eq!(::std::mem::size_of::<ip_frag>() , 16usize , concat ! (
- "Size of: " , stringify ! ( ip_frag ) ));
- assert_eq! (::std::mem::align_of::<ip_frag>() , 8usize , concat ! (
- "Alignment of " , stringify ! ( ip_frag ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ip_frag ) ) . ofs as * const _ as usize }
- , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( ip_frag ) , "::" ,
- stringify ! ( ofs ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ip_frag ) ) . len as * const _ as usize }
- , 2usize , concat ! (
- "Alignment of field: " , stringify ! ( ip_frag ) , "::" ,
- stringify ! ( len ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ip_frag ) ) . mb as * const _ as usize }
- , 8usize , concat ! (
- "Alignment of field: " , stringify ! ( ip_frag ) , "::" ,
- stringify ! ( mb ) ));
+ assert_eq!(
+ ::std::mem::size_of::<ip_frag>(),
+ 16usize,
+ concat!("Size of: ", stringify!(ip_frag))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<ip_frag>(),
+ 8usize,
+ concat!("Alignment of ", stringify!(ip_frag))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ip_frag)).ofs as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ip_frag),
+ "::",
+ stringify!(ofs)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ip_frag)).len as *const _ as usize },
+ 2usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ip_frag),
+ "::",
+ stringify!(len)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ip_frag)).mb as *const _ as usize },
+ 8usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ip_frag),
+ "::",
+ stringify!(mb)
+ )
+ );
}
impl Clone for ip_frag {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for ip_frag {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
/// @internal <src addr, dst_addr, id> to uniquely indetify fragmented datagram.
#[repr(C)]
@@ -70,28 +95,51 @@ pub struct ip_frag_key {
}
#[test]
fn bindgen_test_layout_ip_frag_key() {
- assert_eq!(::std::mem::size_of::<ip_frag_key>() , 40usize , concat ! (
- "Size of: " , stringify ! ( ip_frag_key ) ));
- assert_eq! (::std::mem::align_of::<ip_frag_key>() , 8usize , concat ! (
- "Alignment of " , stringify ! ( ip_frag_key ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ip_frag_key ) ) . src_dst as * const _ as
- usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( ip_frag_key ) , "::" ,
- stringify ! ( src_dst ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ip_frag_key ) ) . id as * const _ as
- usize } , 32usize , concat ! (
- "Alignment of field: " , stringify ! ( ip_frag_key ) , "::" ,
- stringify ! ( id ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ip_frag_key ) ) . key_len as * const _ as
- usize } , 36usize , concat ! (
- "Alignment of field: " , stringify ! ( ip_frag_key ) , "::" ,
- stringify ! ( key_len ) ));
+ assert_eq!(
+ ::std::mem::size_of::<ip_frag_key>(),
+ 40usize,
+ concat!("Size of: ", stringify!(ip_frag_key))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<ip_frag_key>(),
+ 8usize,
+ concat!("Alignment of ", stringify!(ip_frag_key))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ip_frag_key)).src_dst as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ip_frag_key),
+ "::",
+ stringify!(src_dst)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ip_frag_key)).id as *const _ as usize },
+ 32usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ip_frag_key),
+ "::",
+ stringify!(id)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ip_frag_key)).key_len as *const _ as usize },
+ 36usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ip_frag_key),
+ "::",
+ stringify!(key_len)
+ )
+ );
}
impl Clone for ip_frag_key {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
/// @internal Fragmented packet to reassemble.
/// First two entries in the frags[] array are for the last and first fragments.
@@ -122,77 +170,141 @@ pub struct ip_frag_pkt__bindgen_ty_1 {
}
#[test]
fn bindgen_test_layout_ip_frag_pkt__bindgen_ty_1() {
- assert_eq!(::std::mem::size_of::<ip_frag_pkt__bindgen_ty_1>() , 16usize ,
- concat ! (
- "Size of: " , stringify ! ( ip_frag_pkt__bindgen_ty_1 ) ));
- assert_eq! (::std::mem::align_of::<ip_frag_pkt__bindgen_ty_1>() , 8usize ,
- concat ! (
- "Alignment of " , stringify ! ( ip_frag_pkt__bindgen_ty_1 )
- ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ip_frag_pkt__bindgen_ty_1 ) ) . tqe_next
- as * const _ as usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! (
- ip_frag_pkt__bindgen_ty_1 ) , "::" , stringify ! ( tqe_next )
- ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ip_frag_pkt__bindgen_ty_1 ) ) . tqe_prev
- as * const _ as usize } , 8usize , concat ! (
- "Alignment of field: " , stringify ! (
- ip_frag_pkt__bindgen_ty_1 ) , "::" , stringify ! ( tqe_prev )
- ));
+ assert_eq!(
+ ::std::mem::size_of::<ip_frag_pkt__bindgen_ty_1>(),
+ 16usize,
+ concat!("Size of: ", stringify!(ip_frag_pkt__bindgen_ty_1))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<ip_frag_pkt__bindgen_ty_1>(),
+ 8usize,
+ concat!("Alignment of ", stringify!(ip_frag_pkt__bindgen_ty_1))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ip_frag_pkt__bindgen_ty_1)).tqe_next as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ip_frag_pkt__bindgen_ty_1),
+ "::",
+ stringify!(tqe_next)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ip_frag_pkt__bindgen_ty_1)).tqe_prev as *const _ as usize },
+ 8usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ip_frag_pkt__bindgen_ty_1),
+ "::",
+ stringify!(tqe_prev)
+ )
+ );
}
impl Clone for ip_frag_pkt__bindgen_ty_1 {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for ip_frag_pkt__bindgen_ty_1 {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[test]
fn bindgen_test_layout_ip_frag_pkt() {
- assert_eq!(::std::mem::size_of::<ip_frag_pkt>() , 192usize , concat ! (
- "Size of: " , stringify ! ( ip_frag_pkt ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ip_frag_pkt ) ) . lru as * const _ as
- usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" ,
- stringify ! ( lru ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ip_frag_pkt ) ) . key as * const _ as
- usize } , 16usize , concat ! (
- "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" ,
- stringify ! ( key ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ip_frag_pkt ) ) . start as * const _ as
- usize } , 56usize , concat ! (
- "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" ,
- stringify ! ( start ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ip_frag_pkt ) ) . total_size as * const _
- as usize } , 64usize , concat ! (
- "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" ,
- stringify ! ( total_size ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ip_frag_pkt ) ) . frag_size as * const _
- as usize } , 68usize , concat ! (
- "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" ,
- stringify ! ( frag_size ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ip_frag_pkt ) ) . last_idx as * const _
- as usize } , 72usize , concat ! (
- "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" ,
- stringify ! ( last_idx ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ip_frag_pkt ) ) . frags as * const _ as
- usize } , 80usize , concat ! (
- "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" ,
- stringify ! ( frags ) ));
+ assert_eq!(
+ ::std::mem::size_of::<ip_frag_pkt>(),
+ 192usize,
+ concat!("Size of: ", stringify!(ip_frag_pkt))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ip_frag_pkt)).lru as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ip_frag_pkt),
+ "::",
+ stringify!(lru)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ip_frag_pkt)).key as *const _ as usize },
+ 16usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ip_frag_pkt),
+ "::",
+ stringify!(key)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ip_frag_pkt)).start as *const _ as usize },
+ 56usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ip_frag_pkt),
+ "::",
+ stringify!(start)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ip_frag_pkt)).total_size as *const _ as usize },
+ 64usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ip_frag_pkt),
+ "::",
+ stringify!(total_size)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ip_frag_pkt)).frag_size as *const _ as usize },
+ 68usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ip_frag_pkt),
+ "::",
+ stringify!(frag_size)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ip_frag_pkt)).last_idx as *const _ as usize },
+ 72usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ip_frag_pkt),
+ "::",
+ stringify!(last_idx)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ip_frag_pkt)).frags as *const _ as usize },
+ 80usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ip_frag_pkt),
+ "::",
+ stringify!(frags)
+ )
+ );
}
impl Clone for ip_frag_pkt {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for ip_frag_pkt {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+impl ::std::cmp::PartialEq for ip_frag_pkt {
+ fn eq(&self, other: &ip_frag_pkt) -> bool {
+ self.lru == other.lru && self.key == other.key && self.start == other.start &&
+ self.total_size == other.total_size && self.frag_size == other.frag_size &&
+ self.last_idx == other.last_idx && self.frags == other.frags
+ }
}
/// < fragment mbuf
#[repr(C)]
@@ -201,5 +313,7 @@ pub struct rte_mbuf {
pub _address: u8,
}
impl Clone for rte_mbuf {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
diff --git a/tests/expectations/tests/opaque-template-inst-member.rs b/tests/expectations/tests/opaque-template-inst-member.rs
index 0bef4c86..f686150c 100644
--- a/tests/expectations/tests/opaque-template-inst-member.rs
+++ b/tests/expectations/tests/opaque-template-inst-member.rs
@@ -6,10 +6,9 @@
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
-pub struct OpaqueTemplate {
-}
-/// This should not end up deriving Debug/Hash/PartialEq because its `mBlah` field cannot derive
-/// Debug/Hash/PartialEq because the instantiation's definition cannot derive Debug/Hash/PartialEq.
+pub struct OpaqueTemplate {}
+/// This should not end up deriving Debug/Hash because its `mBlah` field cannot derive
+/// Debug/Hash because the instantiation's definition cannot derive Debug/Hash.
#[repr(C)]
pub struct ContainsOpaqueTemplate {
pub mBlah: [u32; 101usize],
@@ -17,27 +16,48 @@ pub struct ContainsOpaqueTemplate {
}
#[test]
fn bindgen_test_layout_ContainsOpaqueTemplate() {
- assert_eq!(::std::mem::size_of::<ContainsOpaqueTemplate>() , 408usize ,
- concat ! ( "Size of: " , stringify ! ( ContainsOpaqueTemplate )
- ));
- assert_eq! (::std::mem::align_of::<ContainsOpaqueTemplate>() , 4usize ,
- concat ! (
- "Alignment of " , stringify ! ( ContainsOpaqueTemplate ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ContainsOpaqueTemplate ) ) . mBlah as *
- const _ as usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( ContainsOpaqueTemplate
- ) , "::" , stringify ! ( mBlah ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ContainsOpaqueTemplate ) ) . mBaz as *
- const _ as usize } , 404usize , concat ! (
- "Alignment of field: " , stringify ! ( ContainsOpaqueTemplate
- ) , "::" , stringify ! ( mBaz ) ));
+ assert_eq!(
+ ::std::mem::size_of::<ContainsOpaqueTemplate>(),
+ 408usize,
+ concat!("Size of: ", stringify!(ContainsOpaqueTemplate))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<ContainsOpaqueTemplate>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(ContainsOpaqueTemplate))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ContainsOpaqueTemplate)).mBlah as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ContainsOpaqueTemplate),
+ "::",
+ stringify!(mBlah)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ContainsOpaqueTemplate)).mBaz as *const _ as usize },
+ 404usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ContainsOpaqueTemplate),
+ "::",
+ stringify!(mBaz)
+ )
+ );
}
impl Default for ContainsOpaqueTemplate {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+impl ::std::cmp::PartialEq for ContainsOpaqueTemplate {
+ fn eq(&self, other: &ContainsOpaqueTemplate) -> bool {
+ &self.mBlah[..] == &other.mBlah[..] && self.mBaz == other.mBaz
+ }
}
-/// This shold not end up deriving Debug/Hash/PartialEq either, for similar reasons, although
+/// This should not end up deriving Debug/Hash either, for similar reasons, although
/// we're exercising base member edges now.
#[repr(C)]
pub struct InheritsOpaqueTemplate {
@@ -46,18 +66,34 @@ pub struct InheritsOpaqueTemplate {
}
#[test]
fn bindgen_test_layout_InheritsOpaqueTemplate() {
- assert_eq!(::std::mem::size_of::<InheritsOpaqueTemplate>() , 416usize ,
- concat ! ( "Size of: " , stringify ! ( InheritsOpaqueTemplate )
- ));
- assert_eq! (::std::mem::align_of::<InheritsOpaqueTemplate>() , 8usize ,
- concat ! (
- "Alignment of " , stringify ! ( InheritsOpaqueTemplate ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const InheritsOpaqueTemplate ) ) . wow as *
- const _ as usize } , 408usize , concat ! (
- "Alignment of field: " , stringify ! ( InheritsOpaqueTemplate
- ) , "::" , stringify ! ( wow ) ));
+ assert_eq!(
+ ::std::mem::size_of::<InheritsOpaqueTemplate>(),
+ 416usize,
+ concat!("Size of: ", stringify!(InheritsOpaqueTemplate))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<InheritsOpaqueTemplate>(),
+ 8usize,
+ concat!("Alignment of ", stringify!(InheritsOpaqueTemplate))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const InheritsOpaqueTemplate)).wow as *const _ as usize },
+ 408usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(InheritsOpaqueTemplate),
+ "::",
+ stringify!(wow)
+ )
+ );
}
impl Default for InheritsOpaqueTemplate {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+impl ::std::cmp::PartialEq for InheritsOpaqueTemplate {
+ fn eq(&self, other: &InheritsOpaqueTemplate) -> bool {
+ &self._base[..] == &other._base[..] && self.wow == other.wow
+ }
}
diff --git a/tests/headers/class_1_0.hpp b/tests/headers/class_1_0.hpp
index ee00c2b7..6fa01e95 100644
--- a/tests/headers/class_1_0.hpp
+++ b/tests/headers/class_1_0.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq
+// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --impl-partialeq --with-derive-eq
class C {
int a;
diff --git a/tests/headers/derive-partialeq-anonfield.h b/tests/headers/derive-partialeq-anonfield.h
new file mode 100644
index 00000000..3bbe2bc3
--- /dev/null
+++ b/tests/headers/derive-partialeq-anonfield.h
@@ -0,0 +1,5 @@
+// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --impl-partialeq
+
+struct rte_mbuf {
+ union {};
+} __attribute__((__aligned__(64)));
diff --git a/tests/headers/derive-partialeq-base.hpp b/tests/headers/derive-partialeq-base.hpp
new file mode 100644
index 00000000..989cbe69
--- /dev/null
+++ b/tests/headers/derive-partialeq-base.hpp
@@ -0,0 +1,8 @@
+// bindgen-flags: --with-derive-partialeq --impl-partialeq
+
+class Base {
+ int large[33];
+};
+
+class ShouldDerivePartialEq: Base {
+};
diff --git a/tests/headers/derive-partialeq-bitfield.hpp b/tests/headers/derive-partialeq-bitfield.hpp
new file mode 100644
index 00000000..ac2cac63
--- /dev/null
+++ b/tests/headers/derive-partialeq-bitfield.hpp
@@ -0,0 +1,7 @@
+// bindgen-flags: --with-derive-partialeq --impl-partialeq
+
+class C {
+ bool a: 1;
+ bool b: 7;
+ int large_array[50];
+};
diff --git a/tests/headers/derive-partialeq-core.h b/tests/headers/derive-partialeq-core.h
new file mode 100644
index 00000000..6da5b786
--- /dev/null
+++ b/tests/headers/derive-partialeq-core.h
@@ -0,0 +1,5 @@
+// bindgen-flags: --with-derive-partialeq --impl-partialeq --use-core --raw-line "extern crate core;"
+
+struct C {
+ int large_array[420];
+};
diff --git a/tests/headers/derive-partialeq-pointer.hpp b/tests/headers/derive-partialeq-pointer.hpp
new file mode 100644
index 00000000..ce971e07
--- /dev/null
+++ b/tests/headers/derive-partialeq-pointer.hpp
@@ -0,0 +1,12 @@
+// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq
+
+struct a;
+class Bar {
+ a *b;
+};
+struct c {
+ union {};
+};
+struct a {
+ c d;
+};
diff --git a/tests/headers/derive-partialeq-union.hpp b/tests/headers/derive-partialeq-union.hpp
new file mode 100644
index 00000000..887506d0
--- /dev/null
+++ b/tests/headers/derive-partialeq-union.hpp
@@ -0,0 +1,7 @@
+// bindgen-flags: --with-derive-partialeq --impl-partialeq
+
+// Deriving PartialEq for rust unions is not supported.
+union ShouldNotDerivePartialEq {
+ char a;
+ int b;
+};
diff --git a/tests/headers/derive-partialeq-union_1_0.hpp b/tests/headers/derive-partialeq-union_1_0.hpp
new file mode 100644
index 00000000..846a00dd
--- /dev/null
+++ b/tests/headers/derive-partialeq-union_1_0.hpp
@@ -0,0 +1,7 @@
+// bindgen-flags: --rust-target 1.0 --with-derive-partialeq --impl-partialeq
+
+// This should manually derive PartialEq.
+union ShouldDerivePartialEq {
+ char a[150];
+ int b;
+};
diff --git a/tests/headers/issue-648-derive-debug-with-padding.h b/tests/headers/issue-648-derive-debug-with-padding.h
index c9ec0210..f528c100 100644
--- a/tests/headers/issue-648-derive-debug-with-padding.h
+++ b/tests/headers/issue-648-derive-debug-with-padding.h
@@ -1,4 +1,4 @@
-// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq
+// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --impl-partialeq
/**
* We emit a `[u8; 63usize]` padding field for this struct, which cannot derive
* Debug/Hash because 63 is over the hard coded limit. (Yes, this struct doesn't end
diff --git a/tests/headers/layout_array.h b/tests/headers/layout_array.h
index 6a20f7c3..239e52b1 100644
--- a/tests/headers/layout_array.h
+++ b/tests/headers/layout_array.h
@@ -1,4 +1,4 @@
-// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq
+// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --impl-partialeq
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
diff --git a/tests/headers/layout_array_too_long.h b/tests/headers/layout_array_too_long.h
index a3ef3d20..1d8b1b63 100644
--- a/tests/headers/layout_array_too_long.h
+++ b/tests/headers/layout_array_too_long.h
@@ -1,4 +1,4 @@
-// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum .*
+// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --impl-partialeq --rustified-enum .*
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
diff --git a/tests/headers/opaque-template-inst-member.hpp b/tests/headers/opaque-template-inst-member.hpp
index 4cb3dd72..6516aa56 100644
--- a/tests/headers/opaque-template-inst-member.hpp
+++ b/tests/headers/opaque-template-inst-member.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --opaque-type 'OpaqueTemplate' --with-derive-hash --with-derive-partialeq --with-derive-eq
+// bindgen-flags: --opaque-type 'OpaqueTemplate' --with-derive-hash --with-derive-partialeq --impl-partialeq --with-derive-eq
template<typename T>
class OpaqueTemplate {
@@ -6,14 +6,14 @@ class OpaqueTemplate {
bool mCannotDebug[400];
};
-/// This should not end up deriving Debug/Hash/PartialEq because its `mBlah` field cannot derive
-/// Debug/Hash/PartialEq because the instantiation's definition cannot derive Debug/Hash/PartialEq.
+/// This should not end up deriving Debug/Hash because its `mBlah` field cannot derive
+/// Debug/Hash because the instantiation's definition cannot derive Debug/Hash.
class ContainsOpaqueTemplate {
OpaqueTemplate<int> mBlah;
int mBaz;
};
-/// This shold not end up deriving Debug/Hash/PartialEq either, for similar reasons, although
+/// This should not end up deriving Debug/Hash either, for similar reasons, although
/// we're exercising base member edges now.
class InheritsOpaqueTemplate : public OpaqueTemplate<bool> {
char* wow;