diff options
author | Nick Fitzgerald <fitzgen@gmail.com> | 2017-10-13 13:48:50 -0700 |
---|---|---|
committer | Nick Fitzgerald <fitzgen@gmail.com> | 2017-10-13 13:48:50 -0700 |
commit | 02c46bb7059b09b9d25a4e6f45e405c4c6fbbf45 (patch) | |
tree | 9581e94d7fc2e61aa57ec4661bc4799c99fd4cf0 | |
parent | 8582a90ee76384df63876c879646da0c1555166b (diff) |
Run `rustfmt` on all of the test expectations
235 files changed, 10263 insertions, 4856 deletions
diff --git a/tests/expectations/tests/16-byte-alignment.rs b/tests/expectations/tests/16-byte-alignment.rs index 86103656..4b764daa 100644 --- a/tests/expectations/tests/16-byte-alignment.rs +++ b/tests/expectations/tests/16-byte-alignment.rs @@ -26,76 +26,127 @@ pub struct rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 { } #[test] fn bindgen_test_layout_rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1>() - , 4usize , concat ! ( - "Size of: " , stringify ! ( - rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1>() - , 2usize , concat ! ( - "Alignment of " , stringify ! ( - rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( - * ( 0 as * const rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) - ) . dport as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) , "::" , - stringify ! ( dport ) )); - assert_eq! (unsafe { - & ( - * ( 0 as * const rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) - ) . sport as * const _ as usize } , 2usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) , "::" , - stringify ! ( sport ) )); + assert_eq!( + ::std::mem::size_of::<rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1>(), + 4usize, + concat!( + "Size of: ", + stringify!(rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1>(), + 2usize, + concat!( + "Alignment of ", + stringify!(rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(0 as *const rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1)).dport as *const _ as usize + }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(dport) + ) + ); + assert_eq!( + unsafe { + &(*(0 as *const rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1)).sport as *const _ as usize + }, + 2usize, + concat!( + "Alignment of field: ", + stringify!(rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(sport) + ) + ); } impl Clone for rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_rte_ipv4_tuple__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<rte_ipv4_tuple__bindgen_ty_1>() , 4usize - , concat ! ( - "Size of: " , stringify ! ( rte_ipv4_tuple__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<rte_ipv4_tuple__bindgen_ty_1>() , - 4usize , concat ! ( - "Alignment of " , stringify ! ( rte_ipv4_tuple__bindgen_ty_1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ipv4_tuple__bindgen_ty_1 ) ) . - sctp_tag as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_ipv4_tuple__bindgen_ty_1 ) , "::" , stringify ! ( sctp_tag - ) )); + assert_eq!( + ::std::mem::size_of::<rte_ipv4_tuple__bindgen_ty_1>(), + 4usize, + concat!("Size of: ", stringify!(rte_ipv4_tuple__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<rte_ipv4_tuple__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(rte_ipv4_tuple__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_ipv4_tuple__bindgen_ty_1)).sctp_tag as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(rte_ipv4_tuple__bindgen_ty_1), + "::", + stringify!(sctp_tag) + ) + ); } impl Clone for rte_ipv4_tuple__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for rte_ipv4_tuple__bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[test] fn bindgen_test_layout_rte_ipv4_tuple() { - assert_eq!(::std::mem::size_of::<rte_ipv4_tuple>() , 12usize , concat ! ( - "Size of: " , stringify ! ( rte_ipv4_tuple ) )); - assert_eq! (::std::mem::align_of::<rte_ipv4_tuple>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( rte_ipv4_tuple ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ipv4_tuple ) ) . src_addr as * const - _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ipv4_tuple ) , "::" - , stringify ! ( src_addr ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ipv4_tuple ) ) . dst_addr as * const - _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ipv4_tuple ) , "::" - , stringify ! ( dst_addr ) )); + assert_eq!( + ::std::mem::size_of::<rte_ipv4_tuple>(), + 12usize, + concat!("Size of: ", stringify!(rte_ipv4_tuple)) + ); + assert_eq!( + ::std::mem::align_of::<rte_ipv4_tuple>(), + 4usize, + concat!("Alignment of ", stringify!(rte_ipv4_tuple)) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_ipv4_tuple)).src_addr as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(rte_ipv4_tuple), + "::", + stringify!(src_addr) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_ipv4_tuple)).dst_addr as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(rte_ipv4_tuple), + "::", + stringify!(dst_addr) + ) + ); } impl Clone for rte_ipv4_tuple { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for rte_ipv4_tuple { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Copy)] @@ -119,76 +170,127 @@ pub struct rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 { } #[test] fn bindgen_test_layout_rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1>() - , 4usize , concat ! ( - "Size of: " , stringify ! ( - rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1>() - , 2usize , concat ! ( - "Alignment of " , stringify ! ( - rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( - * ( 0 as * const rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) - ) . dport as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) , "::" , - stringify ! ( dport ) )); - assert_eq! (unsafe { - & ( - * ( 0 as * const rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) - ) . sport as * const _ as usize } , 2usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) , "::" , - stringify ! ( sport ) )); + assert_eq!( + ::std::mem::size_of::<rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1>(), + 4usize, + concat!( + "Size of: ", + stringify!(rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1>(), + 2usize, + concat!( + "Alignment of ", + stringify!(rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(0 as *const rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1)).dport as *const _ as usize + }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(dport) + ) + ); + assert_eq!( + unsafe { + &(*(0 as *const rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1)).sport as *const _ as usize + }, + 2usize, + concat!( + "Alignment of field: ", + stringify!(rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(sport) + ) + ); } impl Clone for rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_rte_ipv6_tuple__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<rte_ipv6_tuple__bindgen_ty_1>() , 4usize - , concat ! ( - "Size of: " , stringify ! ( rte_ipv6_tuple__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<rte_ipv6_tuple__bindgen_ty_1>() , - 4usize , concat ! ( - "Alignment of " , stringify ! ( rte_ipv6_tuple__bindgen_ty_1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ipv6_tuple__bindgen_ty_1 ) ) . - sctp_tag as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_ipv6_tuple__bindgen_ty_1 ) , "::" , stringify ! ( sctp_tag - ) )); + assert_eq!( + ::std::mem::size_of::<rte_ipv6_tuple__bindgen_ty_1>(), + 4usize, + concat!("Size of: ", stringify!(rte_ipv6_tuple__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<rte_ipv6_tuple__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(rte_ipv6_tuple__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_ipv6_tuple__bindgen_ty_1)).sctp_tag as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(rte_ipv6_tuple__bindgen_ty_1), + "::", + stringify!(sctp_tag) + ) + ); } impl Clone for rte_ipv6_tuple__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for rte_ipv6_tuple__bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[test] fn bindgen_test_layout_rte_ipv6_tuple() { - assert_eq!(::std::mem::size_of::<rte_ipv6_tuple>() , 36usize , concat ! ( - "Size of: " , stringify ! ( rte_ipv6_tuple ) )); - assert_eq! (::std::mem::align_of::<rte_ipv6_tuple>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( rte_ipv6_tuple ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ipv6_tuple ) ) . src_addr as * const - _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ipv6_tuple ) , "::" - , stringify ! ( src_addr ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ipv6_tuple ) ) . dst_addr as * const - _ as usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ipv6_tuple ) , "::" - , stringify ! ( dst_addr ) )); + assert_eq!( + ::std::mem::size_of::<rte_ipv6_tuple>(), + 36usize, + concat!("Size of: ", stringify!(rte_ipv6_tuple)) + ); + assert_eq!( + ::std::mem::align_of::<rte_ipv6_tuple>(), + 4usize, + concat!("Alignment of ", stringify!(rte_ipv6_tuple)) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_ipv6_tuple)).src_addr as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(rte_ipv6_tuple), + "::", + stringify!(src_addr) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_ipv6_tuple)).dst_addr as *const _ as usize }, + 16usize, + concat!( + "Alignment of field: ", + stringify!(rte_ipv6_tuple), + "::", + stringify!(dst_addr) + ) + ); } impl Clone for rte_ipv6_tuple { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for rte_ipv6_tuple { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Copy)] @@ -199,22 +301,39 @@ pub union rte_thash_tuple { } #[test] fn bindgen_test_layout_rte_thash_tuple() { - assert_eq!(::std::mem::size_of::<rte_thash_tuple>() , 48usize , concat ! ( - "Size of: " , stringify ! ( rte_thash_tuple ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_thash_tuple ) ) . v4 as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_thash_tuple ) , - "::" , stringify ! ( v4 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_thash_tuple ) ) . v6 as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_thash_tuple ) , - "::" , stringify ! ( v6 ) )); + assert_eq!( + ::std::mem::size_of::<rte_thash_tuple>(), + 48usize, + concat!("Size of: ", stringify!(rte_thash_tuple)) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_thash_tuple)).v4 as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(rte_thash_tuple), + "::", + stringify!(v4) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_thash_tuple)).v6 as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(rte_thash_tuple), + "::", + stringify!(v6) + ) + ); } impl Clone for rte_thash_tuple { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for rte_thash_tuple { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/16-byte-alignment_1_0.rs b/tests/expectations/tests/16-byte-alignment_1_0.rs index 98cb1a49..712bc519 100644 --- a/tests/expectations/tests/16-byte-alignment_1_0.rs +++ b/tests/expectations/tests/16-byte-alignment_1_0.rs @@ -6,35 +6,47 @@ #[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(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_ipv4_tuple { @@ -57,70 +69,117 @@ pub struct rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 { } #[test] fn bindgen_test_layout_rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1>() - , 4usize , concat ! ( - "Size of: " , stringify ! ( - rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1>() - , 2usize , concat ! ( - "Alignment of " , stringify ! ( - rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( - * ( 0 as * const rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) - ) . dport as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) , "::" , - stringify ! ( dport ) )); - assert_eq! (unsafe { - & ( - * ( 0 as * const rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) - ) . sport as * const _ as usize } , 2usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) , "::" , - stringify ! ( sport ) )); + assert_eq!( + ::std::mem::size_of::<rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1>(), + 4usize, + concat!( + "Size of: ", + stringify!(rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1>(), + 2usize, + concat!( + "Alignment of ", + stringify!(rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(0 as *const rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1)).dport as *const _ as usize + }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(dport) + ) + ); + assert_eq!( + unsafe { + &(*(0 as *const rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1)).sport as *const _ as usize + }, + 2usize, + concat!( + "Alignment of field: ", + stringify!(rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(sport) + ) + ); } impl Clone for rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_rte_ipv4_tuple__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<rte_ipv4_tuple__bindgen_ty_1>() , 4usize - , concat ! ( - "Size of: " , stringify ! ( rte_ipv4_tuple__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<rte_ipv4_tuple__bindgen_ty_1>() , - 4usize , concat ! ( - "Alignment of " , stringify ! ( rte_ipv4_tuple__bindgen_ty_1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ipv4_tuple__bindgen_ty_1 ) ) . - sctp_tag as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_ipv4_tuple__bindgen_ty_1 ) , "::" , stringify ! ( sctp_tag - ) )); + assert_eq!( + ::std::mem::size_of::<rte_ipv4_tuple__bindgen_ty_1>(), + 4usize, + concat!("Size of: ", stringify!(rte_ipv4_tuple__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<rte_ipv4_tuple__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(rte_ipv4_tuple__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_ipv4_tuple__bindgen_ty_1)).sctp_tag as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(rte_ipv4_tuple__bindgen_ty_1), + "::", + stringify!(sctp_tag) + ) + ); } impl Clone for rte_ipv4_tuple__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_rte_ipv4_tuple() { - assert_eq!(::std::mem::size_of::<rte_ipv4_tuple>() , 12usize , concat ! ( - "Size of: " , stringify ! ( rte_ipv4_tuple ) )); - assert_eq! (::std::mem::align_of::<rte_ipv4_tuple>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( rte_ipv4_tuple ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ipv4_tuple ) ) . src_addr as * const - _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ipv4_tuple ) , "::" - , stringify ! ( src_addr ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ipv4_tuple ) ) . dst_addr as * const - _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ipv4_tuple ) , "::" - , stringify ! ( dst_addr ) )); + assert_eq!( + ::std::mem::size_of::<rte_ipv4_tuple>(), + 12usize, + concat!("Size of: ", stringify!(rte_ipv4_tuple)) + ); + assert_eq!( + ::std::mem::align_of::<rte_ipv4_tuple>(), + 4usize, + concat!("Alignment of ", stringify!(rte_ipv4_tuple)) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_ipv4_tuple)).src_addr as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(rte_ipv4_tuple), + "::", + stringify!(src_addr) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_ipv4_tuple)).dst_addr as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(rte_ipv4_tuple), + "::", + stringify!(dst_addr) + ) + ); } impl Clone for rte_ipv4_tuple { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] @@ -144,70 +203,117 @@ pub struct rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 { } #[test] fn bindgen_test_layout_rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1>() - , 4usize , concat ! ( - "Size of: " , stringify ! ( - rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1>() - , 2usize , concat ! ( - "Alignment of " , stringify ! ( - rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( - * ( 0 as * const rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) - ) . dport as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) , "::" , - stringify ! ( dport ) )); - assert_eq! (unsafe { - & ( - * ( 0 as * const rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) - ) . sport as * const _ as usize } , 2usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) , "::" , - stringify ! ( sport ) )); + assert_eq!( + ::std::mem::size_of::<rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1>(), + 4usize, + concat!( + "Size of: ", + stringify!(rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1>(), + 2usize, + concat!( + "Alignment of ", + stringify!(rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(0 as *const rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1)).dport as *const _ as usize + }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(dport) + ) + ); + assert_eq!( + unsafe { + &(*(0 as *const rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1)).sport as *const _ as usize + }, + 2usize, + concat!( + "Alignment of field: ", + stringify!(rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(sport) + ) + ); } impl Clone for rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_rte_ipv6_tuple__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<rte_ipv6_tuple__bindgen_ty_1>() , 4usize - , concat ! ( - "Size of: " , stringify ! ( rte_ipv6_tuple__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<rte_ipv6_tuple__bindgen_ty_1>() , - 4usize , concat ! ( - "Alignment of " , stringify ! ( rte_ipv6_tuple__bindgen_ty_1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ipv6_tuple__bindgen_ty_1 ) ) . - sctp_tag as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_ipv6_tuple__bindgen_ty_1 ) , "::" , stringify ! ( sctp_tag - ) )); + assert_eq!( + ::std::mem::size_of::<rte_ipv6_tuple__bindgen_ty_1>(), + 4usize, + concat!("Size of: ", stringify!(rte_ipv6_tuple__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<rte_ipv6_tuple__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(rte_ipv6_tuple__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_ipv6_tuple__bindgen_ty_1)).sctp_tag as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(rte_ipv6_tuple__bindgen_ty_1), + "::", + stringify!(sctp_tag) + ) + ); } impl Clone for rte_ipv6_tuple__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_rte_ipv6_tuple() { - assert_eq!(::std::mem::size_of::<rte_ipv6_tuple>() , 36usize , concat ! ( - "Size of: " , stringify ! ( rte_ipv6_tuple ) )); - assert_eq! (::std::mem::align_of::<rte_ipv6_tuple>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( rte_ipv6_tuple ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ipv6_tuple ) ) . src_addr as * const - _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ipv6_tuple ) , "::" - , stringify ! ( src_addr ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ipv6_tuple ) ) . dst_addr as * const - _ as usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ipv6_tuple ) , "::" - , stringify ! ( dst_addr ) )); + assert_eq!( + ::std::mem::size_of::<rte_ipv6_tuple>(), + 36usize, + concat!("Size of: ", stringify!(rte_ipv6_tuple)) + ); + assert_eq!( + ::std::mem::align_of::<rte_ipv6_tuple>(), + 4usize, + concat!("Alignment of ", stringify!(rte_ipv6_tuple)) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_ipv6_tuple)).src_addr as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(rte_ipv6_tuple), + "::", + stringify!(src_addr) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_ipv6_tuple)).dst_addr as *const _ as usize }, + 16usize, + concat!( + "Alignment of field: ", + stringify!(rte_ipv6_tuple), + "::", + stringify!(dst_addr) + ) + ); } impl Clone for rte_ipv6_tuple { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Copy)] @@ -218,22 +324,39 @@ pub struct rte_thash_tuple { } #[test] fn bindgen_test_layout_rte_thash_tuple() { - assert_eq!(::std::mem::size_of::<rte_thash_tuple>() , 48usize , concat ! ( - "Size of: " , stringify ! ( rte_thash_tuple ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_thash_tuple ) ) . v4 as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_thash_tuple ) , - "::" , stringify ! ( v4 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_thash_tuple ) ) . v6 as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_thash_tuple ) , - "::" , stringify ! ( v6 ) )); + assert_eq!( + ::std::mem::size_of::<rte_thash_tuple>(), + 48usize, + concat!("Size of: ", stringify!(rte_thash_tuple)) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_thash_tuple)).v4 as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(rte_thash_tuple), + "::", + stringify!(v4) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_thash_tuple)).v6 as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(rte_thash_tuple), + "::", + stringify!(v6) + ) + ); } impl Clone for rte_thash_tuple { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for rte_thash_tuple { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/accessors.rs b/tests/expectations/tests/accessors.rs index df1732c4..3c8953e6 100644 --- a/tests/expectations/tests/accessors.rs +++ b/tests/expectations/tests/accessors.rs @@ -17,33 +17,61 @@ pub struct SomeAccessors { } #[test] fn bindgen_test_layout_SomeAccessors() { - assert_eq!(::std::mem::size_of::<SomeAccessors>() , 16usize , concat ! ( - "Size of: " , stringify ! ( SomeAccessors ) )); - assert_eq! (::std::mem::align_of::<SomeAccessors>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( SomeAccessors ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const SomeAccessors ) ) . mNoAccessor as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( SomeAccessors ) , "::" - , stringify ! ( mNoAccessor ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const SomeAccessors ) ) . mBothAccessors as * - const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( SomeAccessors ) , "::" - , stringify ! ( mBothAccessors ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const SomeAccessors ) ) . mUnsafeAccessors as * - const _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( SomeAccessors ) , "::" - , stringify ! ( mUnsafeAccessors ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const SomeAccessors ) ) . mImmutableAccessor as - * const _ as usize } , 12usize , concat ! ( - "Alignment of field: " , stringify ! ( SomeAccessors ) , "::" - , stringify ! ( mImmutableAccessor ) )); + assert_eq!( + ::std::mem::size_of::<SomeAccessors>(), + 16usize, + concat!("Size of: ", stringify!(SomeAccessors)) + ); + assert_eq!( + ::std::mem::align_of::<SomeAccessors>(), + 4usize, + concat!("Alignment of ", stringify!(SomeAccessors)) + ); + assert_eq!( + unsafe { &(*(0 as *const SomeAccessors)).mNoAccessor as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(SomeAccessors), + "::", + stringify!(mNoAccessor) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const SomeAccessors)).mBothAccessors as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(SomeAccessors), + "::", + stringify!(mBothAccessors) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const SomeAccessors)).mUnsafeAccessors as *const _ as usize }, + 8usize, + concat!( + "Alignment of field: ", + stringify!(SomeAccessors), + "::", + stringify!(mUnsafeAccessors) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const SomeAccessors)).mImmutableAccessor as *const _ as usize }, + 12usize, + concat!( + "Alignment of field: ", + stringify!(SomeAccessors), + "::", + stringify!(mImmutableAccessor) + ) + ); } impl Clone for SomeAccessors { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl SomeAccessors { #[inline] @@ -59,8 +87,7 @@ impl SomeAccessors { &self.mUnsafeAccessors } #[inline] - pub unsafe fn get_mUnsafeAccessors_mut(&mut self) - -> &mut ::std::os::raw::c_int { + pub unsafe fn get_mUnsafeAccessors_mut(&mut self) -> &mut ::std::os::raw::c_int { &mut self.mUnsafeAccessors } #[inline] @@ -77,23 +104,41 @@ pub struct AllAccessors { } #[test] fn bindgen_test_layout_AllAccessors() { - assert_eq!(::std::mem::size_of::<AllAccessors>() , 8usize , concat ! ( - "Size of: " , stringify ! ( AllAccessors ) )); - assert_eq! (::std::mem::align_of::<AllAccessors>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( AllAccessors ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const AllAccessors ) ) . mBothAccessors as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( AllAccessors ) , "::" , - stringify ! ( mBothAccessors ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const AllAccessors ) ) . mAlsoBothAccessors as - * const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( AllAccessors ) , "::" , - stringify ! ( mAlsoBothAccessors ) )); + assert_eq!( + ::std::mem::size_of::<AllAccessors>(), + 8usize, + concat!("Size of: ", stringify!(AllAccessors)) + ); + assert_eq!( + ::std::mem::align_of::<AllAccessors>(), + 4usize, + concat!("Alignment of ", stringify!(AllAccessors)) + ); + assert_eq!( + unsafe { &(*(0 as *const AllAccessors)).mBothAccessors as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(AllAccessors), + "::", + stringify!(mBothAccessors) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const AllAccessors)).mAlsoBothAccessors as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(AllAccessors), + "::", + stringify!(mAlsoBothAccessors) + ) + ); } impl Clone for AllAccessors { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl AllAccessors { #[inline] @@ -109,8 +154,7 @@ impl AllAccessors { &self.mAlsoBothAccessors } #[inline] - pub fn get_mAlsoBothAccessors_mut(&mut self) - -> &mut ::std::os::raw::c_int { + pub fn get_mAlsoBothAccessors_mut(&mut self) -> &mut ::std::os::raw::c_int { &mut self.mAlsoBothAccessors } } @@ -123,24 +167,41 @@ pub struct AllUnsafeAccessors { } #[test] fn bindgen_test_layout_AllUnsafeAccessors() { - assert_eq!(::std::mem::size_of::<AllUnsafeAccessors>() , 8usize , concat ! - ( "Size of: " , stringify ! ( AllUnsafeAccessors ) )); - assert_eq! (::std::mem::align_of::<AllUnsafeAccessors>() , 4usize , concat - ! ( "Alignment of " , stringify ! ( AllUnsafeAccessors ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const AllUnsafeAccessors ) ) . mBothAccessors - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( AllUnsafeAccessors ) , - "::" , stringify ! ( mBothAccessors ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const AllUnsafeAccessors ) ) . - mAlsoBothAccessors as * const _ as usize } , 4usize , concat ! - ( - "Alignment of field: " , stringify ! ( AllUnsafeAccessors ) , - "::" , stringify ! ( mAlsoBothAccessors ) )); + assert_eq!( + ::std::mem::size_of::<AllUnsafeAccessors>(), + 8usize, + concat!("Size of: ", stringify!(AllUnsafeAccessors)) + ); + assert_eq!( + ::std::mem::align_of::<AllUnsafeAccessors>(), + 4usize, + concat!("Alignment of ", stringify!(AllUnsafeAccessors)) + ); + assert_eq!( + unsafe { &(*(0 as *const AllUnsafeAccessors)).mBothAccessors as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(AllUnsafeAccessors), + "::", + stringify!(mBothAccessors) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const AllUnsafeAccessors)).mAlsoBothAccessors as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(AllUnsafeAccessors), + "::", + stringify!(mAlsoBothAccessors) + ) + ); } impl Clone for AllUnsafeAccessors { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl AllUnsafeAccessors { #[inline] @@ -148,8 +209,7 @@ impl AllUnsafeAccessors { &self.mBothAccessors } #[inline] - pub unsafe fn get_mBothAccessors_mut(&mut self) - -> &mut ::std::os::raw::c_int { + pub unsafe fn get_mBothAccessors_mut(&mut self) -> &mut ::std::os::raw::c_int { &mut self.mBothAccessors } #[inline] @@ -157,8 +217,7 @@ impl AllUnsafeAccessors { &self.mAlsoBothAccessors } #[inline] - pub unsafe fn get_mAlsoBothAccessors_mut(&mut self) - -> &mut ::std::os::raw::c_int { + pub unsafe fn get_mAlsoBothAccessors_mut(&mut self) -> &mut ::std::os::raw::c_int { &mut self.mAlsoBothAccessors } } @@ -176,35 +235,61 @@ pub struct ContradictAccessors { } #[test] fn bindgen_test_layout_ContradictAccessors() { - assert_eq!(::std::mem::size_of::<ContradictAccessors>() , 16usize , concat - ! ( "Size of: " , stringify ! ( ContradictAccessors ) )); - assert_eq! (::std::mem::align_of::<ContradictAccessors>() , 4usize , - concat ! ( - "Alignment of " , stringify ! ( ContradictAccessors ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ContradictAccessors ) ) . mBothAccessors - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( ContradictAccessors ) , - "::" , stringify ! ( mBothAccessors ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ContradictAccessors ) ) . mNoAccessors as - * const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( ContradictAccessors ) , - "::" , stringify ! ( mNoAccessors ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ContradictAccessors ) ) . - mUnsafeAccessors as * const _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( ContradictAccessors ) , - "::" , stringify ! ( mUnsafeAccessors ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ContradictAccessors ) ) . - mImmutableAccessor as * const _ as usize } , 12usize , concat - ! ( - "Alignment of field: " , stringify ! ( ContradictAccessors ) , - "::" , stringify ! ( mImmutableAccessor ) )); + assert_eq!( + ::std::mem::size_of::<ContradictAccessors>(), + 16usize, + concat!("Size of: ", stringify!(ContradictAccessors)) + ); + assert_eq!( + ::std::mem::align_of::<ContradictAccessors>(), + 4usize, + concat!("Alignment of ", stringify!(ContradictAccessors)) + ); + assert_eq!( + unsafe { &(*(0 as *const ContradictAccessors)).mBothAccessors as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(ContradictAccessors), + "::", + stringify!(mBothAccessors) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const ContradictAccessors)).mNoAccessors as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(ContradictAccessors), + "::", + stringify!(mNoAccessors) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const ContradictAccessors)).mUnsafeAccessors as *const _ as usize }, + 8usize, + concat!( + "Alignment of field: ", + stringify!(ContradictAccessors), + "::", + stringify!(mUnsafeAccessors) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const ContradictAccessors)).mImmutableAccessor as *const _ as usize }, + 12usize, + concat!( + "Alignment of field: ", + stringify!(ContradictAccessors), + "::", + stringify!(mImmutableAccessor) + ) + ); } impl Clone for ContradictAccessors { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl ContradictAccessors { #[inline] @@ -220,8 +305,7 @@ impl ContradictAccessors { &self.mUnsafeAccessors } #[inline] - pub unsafe fn get_mUnsafeAccessors_mut(&mut self) - -> &mut ::std::os::raw::c_int { + pub unsafe fn get_mUnsafeAccessors_mut(&mut self) -> &mut ::std::os::raw::c_int { &mut self.mUnsafeAccessors } #[inline] @@ -237,22 +321,37 @@ pub struct Replaced { } #[test] fn bindgen_test_layout_Replaced() { - assert_eq!(::std::mem::size_of::<Replaced>() , 4usize , concat ! ( - "Size of: " , stringify ! ( Replaced ) )); - assert_eq! (::std::mem::align_of::<Replaced>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Replaced ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Replaced ) ) . mAccessor as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Replaced ) , "::" , - stringify ! ( mAccessor ) )); + assert_eq!( + ::std::mem::size_of::<Replaced>(), + 4usize, + concat!("Size of: ", stringify!(Replaced)) + ); + assert_eq!( + ::std::mem::align_of::<Replaced>(), + 4usize, + concat!("Alignment of ", stringify!(Replaced)) + ); + assert_eq!( + unsafe { &(*(0 as *const Replaced)).mAccessor as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Replaced), + "::", + stringify!(mAccessor) + ) + ); } impl Clone for Replaced { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Replaced { #[inline] - pub fn get_mAccessor(&self) -> &::std::os::raw::c_int { &self.mAccessor } + pub fn get_mAccessor(&self) -> &::std::os::raw::c_int { + &self.mAccessor + } #[inline] pub fn get_mAccessor_mut(&mut self) -> &mut ::std::os::raw::c_int { &mut self.mAccessor @@ -266,22 +365,37 @@ pub struct Wrapper { } #[test] fn bindgen_test_layout_Wrapper() { - assert_eq!(::std::mem::size_of::<Wrapper>() , 4usize , concat ! ( - "Size of: " , stringify ! ( Wrapper ) )); - assert_eq! (::std::mem::align_of::<Wrapper>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Wrapper ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Wrapper ) ) . mReplaced as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Wrapper ) , "::" , - stringify ! ( mReplaced ) )); + assert_eq!( + ::std::mem::size_of::<Wrapper>(), + 4usize, + concat!("Size of: ", stringify!(Wrapper)) + ); + assert_eq!( + ::std::mem::align_of::<Wrapper>(), + 4usize, + concat!("Alignment of ", stringify!(Wrapper)) + ); + assert_eq!( + unsafe { &(*(0 as *const Wrapper)).mReplaced as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Wrapper), + "::", + stringify!(mReplaced) + ) + ); } impl Clone for Wrapper { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Wrapper { #[inline] - pub fn get_mReplaced(&self) -> &Replaced { &self.mReplaced } + pub fn get_mReplaced(&self) -> &Replaced { + &self.mReplaced + } #[inline] pub fn get_mReplaced_mut(&mut self) -> &mut Replaced { &mut self.mReplaced diff --git a/tests/expectations/tests/anon_enum.rs b/tests/expectations/tests/anon_enum.rs index b1004274..b185aae5 100644 --- a/tests/expectations/tests/anon_enum.rs +++ b/tests/expectations/tests/anon_enum.rs @@ -13,27 +13,50 @@ pub struct Test { pub const Test_T_NONE: Test__bindgen_ty_1 = Test__bindgen_ty_1::T_NONE; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Test__bindgen_ty_1 { T_NONE = 0, } +pub enum Test__bindgen_ty_1 { + T_NONE = 0, +} #[test] fn bindgen_test_layout_Test() { - assert_eq!(::std::mem::size_of::<Test>() , 8usize , concat ! ( - "Size of: " , stringify ! ( Test ) )); - assert_eq! (::std::mem::align_of::<Test>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Test ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . foo as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . bar as * const _ as usize } , - 4usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( bar ) )); + assert_eq!( + ::std::mem::size_of::<Test>(), + 8usize, + concat!("Size of: ", stringify!(Test)) + ); + assert_eq!( + ::std::mem::align_of::<Test>(), + 4usize, + concat!("Alignment of ", stringify!(Test)) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).foo as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(foo) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).bar as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(bar) + ) + ); } impl Clone for Test { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Baz { Foo = 0, Bar = 1, } +pub enum Baz { + Foo = 0, + Bar = 1, +} diff --git a/tests/expectations/tests/anon_enum_trait.rs b/tests/expectations/tests/anon_enum_trait.rs index f0c1d364..c037a08b 100644 --- a/tests/expectations/tests/anon_enum_trait.rs +++ b/tests/expectations/tests/anon_enum_trait.rs @@ -13,19 +13,16 @@ pub type DataType_value_type<_Tp> = _Tp; pub type DataType_work_type<_Tp> = DataType_value_type<_Tp>; pub type DataType_channel_type<_Tp> = DataType_value_type<_Tp>; pub type DataType_vec_type<_Tp> = DataType_value_type<_Tp>; -pub const DataType_generic_type: DataType__bindgen_ty_1 = - DataType__bindgen_ty_1::generic_type; -pub const DataType_depth: DataType__bindgen_ty_1 = - DataType__bindgen_ty_1::generic_type; -pub const DataType_channels: DataType__bindgen_ty_1 = - DataType__bindgen_ty_1::generic_type; -pub const DataType_fmt: DataType__bindgen_ty_1 = - DataType__bindgen_ty_1::generic_type; -pub const DataType_type_: DataType__bindgen_ty_1 = - DataType__bindgen_ty_1::generic_type; +pub const DataType_generic_type: DataType__bindgen_ty_1 = DataType__bindgen_ty_1::generic_type; +pub const DataType_depth: DataType__bindgen_ty_1 = DataType__bindgen_ty_1::generic_type; +pub const DataType_channels: DataType__bindgen_ty_1 = DataType__bindgen_ty_1::generic_type; +pub const DataType_fmt: DataType__bindgen_ty_1 = DataType__bindgen_ty_1::generic_type; +pub const DataType_type_: DataType__bindgen_ty_1 = DataType__bindgen_ty_1::generic_type; #[repr(i32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum DataType__bindgen_ty_1 { generic_type = 0, } +pub enum DataType__bindgen_ty_1 { + generic_type = 0, +} #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct Foo { @@ -35,14 +32,24 @@ pub const Foo_Bar: Foo__bindgen_ty_1 = Foo__bindgen_ty_1::Bar; pub const Foo_Baz: Foo__bindgen_ty_1 = Foo__bindgen_ty_1::Bar; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Foo__bindgen_ty_1 { Bar = 0, } +pub enum Foo__bindgen_ty_1 { + Bar = 0, +} #[test] fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::<Foo>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::<Foo>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::<Foo>(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::<Foo>(), + 1usize, + concat!("Alignment of ", stringify!(Foo)) + ); } impl Clone for Foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/anon_enum_whitelist.rs b/tests/expectations/tests/anon_enum_whitelist.rs index d3f54275..c639410f 100644 --- a/tests/expectations/tests/anon_enum_whitelist.rs +++ b/tests/expectations/tests/anon_enum_whitelist.rs @@ -8,4 +8,7 @@ pub const NODE_FLAG_FOO: _bindgen_ty_1 = _bindgen_ty_1::NODE_FLAG_FOO; pub const NODE_FLAG_BAR: _bindgen_ty_1 = _bindgen_ty_1::NODE_FLAG_BAR; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum _bindgen_ty_1 { NODE_FLAG_FOO = 0, NODE_FLAG_BAR = 1, } +pub enum _bindgen_ty_1 { + NODE_FLAG_FOO = 0, + NODE_FLAG_BAR = 1, +} diff --git a/tests/expectations/tests/anon_struct_in_union.rs b/tests/expectations/tests/anon_struct_in_union.rs index 783a62cf..87329d1a 100644 --- a/tests/expectations/tests/anon_struct_in_union.rs +++ b/tests/expectations/tests/anon_struct_in_union.rs @@ -22,53 +22,90 @@ pub struct s__bindgen_ty_1_inner { } #[test] fn bindgen_test_layout_s__bindgen_ty_1_inner() { - assert_eq!(::std::mem::size_of::<s__bindgen_ty_1_inner>() , 4usize , - concat ! ( "Size of: " , stringify ! ( s__bindgen_ty_1_inner ) - )); - assert_eq! (::std::mem::align_of::<s__bindgen_ty_1_inner>() , 4usize , - concat ! ( - "Alignment of " , stringify ! ( s__bindgen_ty_1_inner ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const s__bindgen_ty_1_inner ) ) . b as * const - _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( s__bindgen_ty_1_inner ) - , "::" , stringify ! ( b ) )); + assert_eq!( + ::std::mem::size_of::<s__bindgen_ty_1_inner>(), + 4usize, + concat!("Size of: ", stringify!(s__bindgen_ty_1_inner)) + ); + assert_eq!( + ::std::mem::align_of::<s__bindgen_ty_1_inner>(), + 4usize, + concat!("Alignment of ", stringify!(s__bindgen_ty_1_inner)) + ); + assert_eq!( + unsafe { &(*(0 as *const s__bindgen_ty_1_inner)).b as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(s__bindgen_ty_1_inner), + "::", + stringify!(b) + ) + ); } impl Clone for s__bindgen_ty_1_inner { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_s__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<s__bindgen_ty_1>() , 4usize , concat ! ( - "Size of: " , stringify ! ( s__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<s__bindgen_ty_1>() , 4usize , concat ! - ( "Alignment of " , stringify ! ( s__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const s__bindgen_ty_1 ) ) . field as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( s__bindgen_ty_1 ) , - "::" , stringify ! ( field ) )); + assert_eq!( + ::std::mem::size_of::<s__bindgen_ty_1>(), + 4usize, + concat!("Size of: ", stringify!(s__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<s__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(s__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const s__bindgen_ty_1)).field as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(s__bindgen_ty_1), + "::", + stringify!(field) + ) + ); } impl Clone for s__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for s__bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[test] fn bindgen_test_layout_s() { - assert_eq!(::std::mem::size_of::<s>() , 4usize , concat ! ( - "Size of: " , stringify ! ( s ) )); - assert_eq! (::std::mem::align_of::<s>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( s ) )); - assert_eq! (unsafe { & ( * ( 0 as * const s ) ) . u as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( s ) , "::" , stringify - ! ( u ) )); + assert_eq!( + ::std::mem::size_of::<s>(), + 4usize, + concat!("Size of: ", stringify!(s)) + ); + assert_eq!( + ::std::mem::align_of::<s>(), + 4usize, + concat!("Alignment of ", stringify!(s)) + ); + assert_eq!( + unsafe { &(*(0 as *const s)).u as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(s), "::", stringify!(u)) + ); } impl Clone for s { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for s { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/anon_struct_in_union_1_0.rs b/tests/expectations/tests/anon_struct_in_union_1_0.rs index 8c29f8e4..8e2e6bea 100644 --- a/tests/expectations/tests/anon_struct_in_union_1_0.rs +++ b/tests/expectations/tests/anon_struct_in_union_1_0.rs @@ -6,35 +6,47 @@ #[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(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct s { @@ -53,47 +65,80 @@ pub struct s__bindgen_ty_1_inner { } #[test] fn bindgen_test_layout_s__bindgen_ty_1_inner() { - assert_eq!(::std::mem::size_of::<s__bindgen_ty_1_inner>() , 4usize , - concat ! ( "Size of: " , stringify ! ( s__bindgen_ty_1_inner ) - )); - assert_eq! (::std::mem::align_of::<s__bindgen_ty_1_inner>() , 4usize , - concat ! ( - "Alignment of " , stringify ! ( s__bindgen_ty_1_inner ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const s__bindgen_ty_1_inner ) ) . b as * const - _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( s__bindgen_ty_1_inner ) - , "::" , stringify ! ( b ) )); + assert_eq!( + ::std::mem::size_of::<s__bindgen_ty_1_inner>(), + 4usize, + concat!("Size of: ", stringify!(s__bindgen_ty_1_inner)) + ); + assert_eq!( + ::std::mem::align_of::<s__bindgen_ty_1_inner>(), + 4usize, + concat!("Alignment of ", stringify!(s__bindgen_ty_1_inner)) + ); + assert_eq!( + unsafe { &(*(0 as *const s__bindgen_ty_1_inner)).b as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(s__bindgen_ty_1_inner), + "::", + stringify!(b) + ) + ); } impl Clone for s__bindgen_ty_1_inner { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_s__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<s__bindgen_ty_1>() , 4usize , concat ! ( - "Size of: " , stringify ! ( s__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<s__bindgen_ty_1>() , 4usize , concat ! - ( "Alignment of " , stringify ! ( s__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const s__bindgen_ty_1 ) ) . field as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( s__bindgen_ty_1 ) , - "::" , stringify ! ( field ) )); + assert_eq!( + ::std::mem::size_of::<s__bindgen_ty_1>(), + 4usize, + concat!("Size of: ", stringify!(s__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<s__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(s__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const s__bindgen_ty_1)).field as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(s__bindgen_ty_1), + "::", + stringify!(field) + ) + ); } impl Clone for s__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_s() { - assert_eq!(::std::mem::size_of::<s>() , 4usize , concat ! ( - "Size of: " , stringify ! ( s ) )); - assert_eq! (::std::mem::align_of::<s>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( s ) )); - assert_eq! (unsafe { & ( * ( 0 as * const s ) ) . u as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( s ) , "::" , stringify - ! ( u ) )); + assert_eq!( + ::std::mem::size_of::<s>(), + 4usize, + concat!("Size of: ", stringify!(s)) + ); + assert_eq!( + ::std::mem::align_of::<s>(), + 4usize, + concat!("Alignment of ", stringify!(s)) + ); + assert_eq!( + unsafe { &(*(0 as *const s)).u as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(s), "::", stringify!(u)) + ); } impl Clone for s { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/anon_union.rs b/tests/expectations/tests/anon_union.rs index f2da118d..fdf01a7a 100644 --- a/tests/expectations/tests/anon_union.rs +++ b/tests/expectations/tests/anon_union.rs @@ -15,7 +15,9 @@ pub const TErrorResult_UnionState_HasException: TErrorResult_UnionState = TErrorResult_UnionState::HasMessage; #[repr(i32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum TErrorResult_UnionState { HasMessage = 0, } +pub enum TErrorResult_UnionState { + HasMessage = 0, +} #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct TErrorResult_Message { @@ -33,10 +35,14 @@ pub union TErrorResult__bindgen_ty_1 { _bindgen_union_align: u64, } impl Default for TErrorResult__bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } impl Default for TErrorResult { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] pub struct ErrorResult { @@ -44,20 +50,38 @@ pub struct ErrorResult { } #[test] fn bindgen_test_layout_ErrorResult() { - assert_eq!(::std::mem::size_of::<ErrorResult>() , 24usize , concat ! ( - "Size of: " , stringify ! ( ErrorResult ) )); - assert_eq! (::std::mem::align_of::<ErrorResult>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( ErrorResult ) )); + assert_eq!( + ::std::mem::size_of::<ErrorResult>(), + 24usize, + concat!("Size of: ", stringify!(ErrorResult)) + ); + assert_eq!( + ::std::mem::align_of::<ErrorResult>(), + 8usize, + concat!("Alignment of ", stringify!(ErrorResult)) + ); } impl Default for ErrorResult { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[test] fn __bindgen_test_layout_TErrorResult_open0_int_close0_instantiation() { - assert_eq!(::std::mem::size_of::<TErrorResult>() , 24usize , concat ! ( - "Size of template specialization: " , stringify ! ( - TErrorResult ) )); - assert_eq!(::std::mem::align_of::<TErrorResult>() , 8usize , concat ! ( - "Alignment of template specialization: " , stringify ! ( - TErrorResult ) )); + assert_eq!( + ::std::mem::size_of::<TErrorResult>(), + 24usize, + concat!( + "Size of template specialization: ", + stringify!(TErrorResult) + ) + ); + assert_eq!( + ::std::mem::align_of::<TErrorResult>(), + 8usize, + concat!( + "Alignment of template specialization: ", + stringify!(TErrorResult) + ) + ); } diff --git a/tests/expectations/tests/anon_union_1_0.rs b/tests/expectations/tests/anon_union_1_0.rs index b96928d4..8d19c9fc 100644 --- a/tests/expectations/tests/anon_union_1_0.rs +++ b/tests/expectations/tests/anon_union_1_0.rs @@ -6,35 +6,47 @@ #[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(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct TErrorResult { @@ -47,7 +59,9 @@ pub const TErrorResult_UnionState_HasException: TErrorResult_UnionState = TErrorResult_UnionState::HasMessage; #[repr(i32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum TErrorResult_UnionState { HasMessage = 0, } +pub enum TErrorResult_UnionState { + HasMessage = 0, +} #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct TErrorResult_Message { @@ -66,7 +80,9 @@ pub struct TErrorResult__bindgen_ty_1 { pub bindgen_union_field: u64, } impl Default for TErrorResult { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] @@ -75,23 +91,43 @@ pub struct ErrorResult { } #[test] fn bindgen_test_layout_ErrorResult() { - assert_eq!(::std::mem::size_of::<ErrorResult>() , 24usize , concat ! ( - "Size of: " , stringify ! ( ErrorResult ) )); - assert_eq! (::std::mem::align_of::<ErrorResult>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( ErrorResult ) )); + assert_eq!( + ::std::mem::size_of::<ErrorResult>(), + 24usize, + concat!("Size of: ", stringify!(ErrorResult)) + ); + assert_eq!( + ::std::mem::align_of::<ErrorResult>(), + 8usize, + concat!("Alignment of ", stringify!(ErrorResult)) + ); } impl Clone for ErrorResult { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for ErrorResult { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[test] fn __bindgen_test_layout_TErrorResult_open0_int_close0_instantiation() { - assert_eq!(::std::mem::size_of::<TErrorResult>() , 24usize , concat ! ( - "Size of template specialization: " , stringify ! ( - TErrorResult ) )); - assert_eq!(::std::mem::align_of::<TErrorResult>() , 8usize , concat ! ( - "Alignment of template specialization: " , stringify ! ( - TErrorResult ) )); + assert_eq!( + ::std::mem::size_of::<TErrorResult>(), + 24usize, + concat!( + "Size of template specialization: ", + stringify!(TErrorResult) + ) + ); + assert_eq!( + ::std::mem::align_of::<TErrorResult>(), + 8usize, + concat!( + "Alignment of template specialization: ", + stringify!(TErrorResult) + ) + ); } diff --git a/tests/expectations/tests/anonymous-template-types.rs b/tests/expectations/tests/anonymous-template-types.rs index 532e2427..0fedfe45 100644 --- a/tests/expectations/tests/anonymous-template-types.rs +++ b/tests/expectations/tests/anonymous-template-types.rs @@ -10,8 +10,10 @@ pub struct Foo<T> { pub t_member: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } -impl <T> Default for Foo<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for Foo<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] @@ -24,8 +26,10 @@ pub struct Quux<V> { pub v_member: V, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<V>>, } -impl <V> Default for Quux<V> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<V> Default for Quux<V> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] diff --git a/tests/expectations/tests/bad-namespace-parenthood-inheritance.rs b/tests/expectations/tests/bad-namespace-parenthood-inheritance.rs index 3bd9bec0..901bec60 100644 --- a/tests/expectations/tests/bad-namespace-parenthood-inheritance.rs +++ b/tests/expectations/tests/bad-namespace-parenthood-inheritance.rs @@ -10,7 +10,9 @@ pub struct std_char_traits { pub _address: u8, } impl Default for std_char_traits { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] diff --git a/tests/expectations/tests/base-to-derived.rs b/tests/expectations/tests/base-to-derived.rs index 0a9e1c35..7042226c 100644 --- a/tests/expectations/tests/base-to-derived.rs +++ b/tests/expectations/tests/base-to-derived.rs @@ -11,11 +11,19 @@ pub struct false_type { } #[test] fn bindgen_test_layout_false_type() { - assert_eq!(::std::mem::size_of::<false_type>() , 1usize , concat ! ( - "Size of: " , stringify ! ( false_type ) )); - assert_eq! (::std::mem::align_of::<false_type>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( false_type ) )); + assert_eq!( + ::std::mem::size_of::<false_type>(), + 1usize, + concat!("Size of: ", stringify!(false_type)) + ); + assert_eq!( + ::std::mem::align_of::<false_type>(), + 1usize, + concat!("Alignment of ", stringify!(false_type)) + ); } impl Clone for false_type { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/bitfield-enum-basic.rs b/tests/expectations/tests/bitfield-enum-basic.rs index ebb3fef4..b7c24fb2 100644 --- a/tests/expectations/tests/bitfield-enum-basic.rs +++ b/tests/expectations/tests/bitfield-enum-basic.rs @@ -9,28 +9,30 @@ pub const Foo_Baz: Foo = Foo(4); pub const Foo_Duplicated: Foo = Foo(4); pub const Foo_Negative: Foo = Foo(-3); impl ::std::ops::BitOr<Foo> for Foo { - type - Output - = - Self; + type Output = Self; #[inline] - fn bitor(self, other: Self) -> Self { Foo(self.0 | other.0) } + fn bitor(self, other: Self) -> Self { + Foo(self.0 | other.0) + } } impl ::std::ops::BitOrAssign for Foo { #[inline] - fn bitor_assign(&mut self, rhs: Foo) { self.0 |= rhs.0; } + fn bitor_assign(&mut self, rhs: Foo) { + self.0 |= rhs.0; + } } impl ::std::ops::BitAnd<Foo> for Foo { - type - Output - = - Self; + type Output = Self; #[inline] - fn bitand(self, other: Self) -> Self { Foo(self.0 & other.0) } + fn bitand(self, other: Self) -> Self { + Foo(self.0 & other.0) + } } impl ::std::ops::BitAndAssign for Foo { #[inline] - fn bitand_assign(&mut self, rhs: Foo) { self.0 &= rhs.0; } + fn bitand_assign(&mut self, rhs: Foo) { + self.0 &= rhs.0; + } } #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] @@ -40,28 +42,30 @@ pub const Buz_Baz: Buz = Buz(4); pub const Buz_Duplicated: Buz = Buz(4); pub const Buz_Negative: Buz = Buz(-3); impl ::std::ops::BitOr<Buz> for Buz { - type - Output - = - Self; + type Output = Self; #[inline] - fn bitor(self, other: Self) -> Self { Buz(self.0 | other.0) } + fn bitor(self, other: Self) -> Self { + Buz(self.0 | other.0) + } } impl ::std::ops::BitOrAssign for Buz { #[inline] - fn bitor_assign(&mut self, rhs: Buz) { self.0 |= rhs.0; } + fn bitor_assign(&mut self, rhs: Buz) { + self.0 |= rhs.0; + } } impl ::std::ops::BitAnd<Buz> for Buz { - type - Output - = - Self; + type Output = Self; #[inline] - fn bitand(self, other: Self) -> Self { Buz(self.0 & other.0) } + fn bitand(self, other: Self) -> Self { + Buz(self.0 & other.0) + } } impl ::std::ops::BitAndAssign for Buz { #[inline] - fn bitand_assign(&mut self, rhs: Buz) { self.0 &= rhs.0; } + fn bitand_assign(&mut self, rhs: Buz) { + self.0 &= rhs.0; + } } #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] @@ -69,28 +73,30 @@ pub struct Buz(pub ::std::os::raw::c_schar); pub const NS_FOO: _bindgen_ty_1 = _bindgen_ty_1(1); pub const NS_BAR: _bindgen_ty_1 = _bindgen_ty_1(2); impl ::std::ops::BitOr<_bindgen_ty_1> for _bindgen_ty_1 { - type - Output - = - Self; + type Output = Self; #[inline] - fn bitor(self, other: Self) -> Self { _bindgen_ty_1(self.0 | other.0) } + fn bitor(self, other: Self) -> Self { + _bindgen_ty_1(self.0 | other.0) + } } impl ::std::ops::BitOrAssign for _bindgen_ty_1 { #[inline] - fn bitor_assign(&mut self, rhs: _bindgen_ty_1) { self.0 |= rhs.0; } + fn bitor_assign(&mut self, rhs: _bindgen_ty_1) { + self.0 |= rhs.0; + } } impl ::std::ops::BitAnd<_bindgen_ty_1> for _bindgen_ty_1 { - type - Output - = - Self; + type Output = Self; #[inline] - fn bitand(self, other: Self) -> Self { _bindgen_ty_1(self.0 & other.0) } + fn bitand(self, other: Self) -> Self { + _bindgen_ty_1(self.0 & other.0) + } } impl ::std::ops::BitAndAssign for _bindgen_ty_1 { #[inline] - fn bitand_assign(&mut self, rhs: _bindgen_ty_1) { self.0 &= rhs.0; } + fn bitand_assign(&mut self, rhs: _bindgen_ty_1) { + self.0 &= rhs.0; + } } #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] @@ -103,10 +109,7 @@ pub struct Dummy { pub const Dummy_DUMMY_FOO: Dummy__bindgen_ty_1 = Dummy__bindgen_ty_1(1); pub const Dummy_DUMMY_BAR: Dummy__bindgen_ty_1 = Dummy__bindgen_ty_1(2); impl ::std::ops::BitOr<Dummy__bindgen_ty_1> for Dummy__bindgen_ty_1 { - type - Output - = - Self; + type Output = Self; #[inline] fn bitor(self, other: Self) -> Self { Dummy__bindgen_ty_1(self.0 | other.0) @@ -114,13 +117,12 @@ impl ::std::ops::BitOr<Dummy__bindgen_ty_1> for Dummy__bindgen_ty_1 { } impl ::std::ops::BitOrAssign for Dummy__bindgen_ty_1 { #[inline] - fn bitor_assign(&mut self, rhs: Dummy__bindgen_ty_1) { self.0 |= rhs.0; } + fn bitor_assign(&mut self, rhs: Dummy__bindgen_ty_1) { + self.0 |= rhs.0; + } } impl ::std::ops::BitAnd<Dummy__bindgen_ty_1> for Dummy__bindgen_ty_1 { - type - Output - = - Self; + type Output = Self; #[inline] fn bitand(self, other: Self) -> Self { Dummy__bindgen_ty_1(self.0 & other.0) @@ -128,18 +130,28 @@ impl ::std::ops::BitAnd<Dummy__bindgen_ty_1> for Dummy__bindgen_ty_1 { } impl ::std::ops::BitAndAssign for Dummy__bindgen_ty_1 { #[inline] - fn bitand_assign(&mut self, rhs: Dummy__bindgen_ty_1) { self.0 &= rhs.0; } + fn bitand_assign(&mut self, rhs: Dummy__bindgen_ty_1) { + self.0 &= rhs.0; + } } #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct Dummy__bindgen_ty_1(pub ::std::os::raw::c_uint); #[test] fn bindgen_test_layout_Dummy() { - assert_eq!(::std::mem::size_of::<Dummy>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Dummy ) )); - assert_eq! (::std::mem::align_of::<Dummy>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Dummy ) )); + assert_eq!( + ::std::mem::size_of::<Dummy>(), + 1usize, + concat!("Size of: ", stringify!(Dummy)) + ); + assert_eq!( + ::std::mem::align_of::<Dummy>(), + 1usize, + concat!("Alignment of ", stringify!(Dummy)) + ); } impl Clone for Dummy { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/bitfield-large.rs b/tests/expectations/tests/bitfield-large.rs index 5606f64e..facc7338 100644 --- a/tests/expectations/tests/bitfield-large.rs +++ b/tests/expectations/tests/bitfield-large.rs @@ -11,11 +11,16 @@ pub struct HasBigBitfield { } #[test] fn bindgen_test_layout_HasBigBitfield() { - assert_eq!(::std::mem::size_of::<HasBigBitfield>() , 16usize , concat ! ( - "Size of: " , stringify ! ( HasBigBitfield ) )); + assert_eq!( + ::std::mem::size_of::<HasBigBitfield>(), + 16usize, + concat!("Size of: ", stringify!(HasBigBitfield)) + ); } impl Clone for HasBigBitfield { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy)] @@ -24,9 +29,14 @@ pub struct HasTwoBigBitfields { } #[test] fn bindgen_test_layout_HasTwoBigBitfields() { - assert_eq!(::std::mem::size_of::<HasTwoBigBitfields>() , 16usize , concat - ! ( "Size of: " , stringify ! ( HasTwoBigBitfields ) )); + assert_eq!( + ::std::mem::size_of::<HasTwoBigBitfields>(), + 16usize, + concat!("Size of: ", stringify!(HasTwoBigBitfields)) + ); } impl Clone for HasTwoBigBitfields { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/c-empty-layout.rs b/tests/expectations/tests/c-empty-layout.rs index c599b01b..65420810 100644 --- a/tests/expectations/tests/c-empty-layout.rs +++ b/tests/expectations/tests/c-empty-layout.rs @@ -6,15 +6,22 @@ #[repr(C)] #[derive(Debug, Default, Copy)] -pub struct Foo { -} +pub struct Foo {} #[test] fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::<Foo>() , 0usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::<Foo>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::<Foo>(), + 0usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::<Foo>(), + 1usize, + concat!("Alignment of ", stringify!(Foo)) + ); } impl Clone for Foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/canonical_path_without_namespacing.rs b/tests/expectations/tests/canonical_path_without_namespacing.rs index 8272aebc..cf14bf20 100644 --- a/tests/expectations/tests/canonical_path_without_namespacing.rs +++ b/tests/expectations/tests/canonical_path_without_namespacing.rs @@ -11,13 +11,21 @@ pub struct Bar { } #[test] fn bindgen_test_layout_Bar() { - assert_eq!(::std::mem::size_of::<Bar>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::<Bar>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Bar ) )); + assert_eq!( + ::std::mem::size_of::<Bar>(), + 1usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::<Bar>(), + 1usize, + concat!("Alignment of ", stringify!(Bar)) + ); } impl Clone for Bar { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } extern "C" { #[link_name = "\u{1}_Z3bazPN3foo3BarE"] diff --git a/tests/expectations/tests/char.rs b/tests/expectations/tests/char.rs index 1e45c743..daad07b4 100644 --- a/tests/expectations/tests/char.rs +++ b/tests/expectations/tests/char.rs @@ -25,71 +25,139 @@ pub struct Test { } #[test] fn bindgen_test_layout_Test() { - assert_eq!(::std::mem::size_of::<Test>() , 12usize , concat ! ( - "Size of: " , stringify ! ( Test ) )); - assert_eq! (::std::mem::align_of::<Test>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Test ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . ch as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( ch ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . u as * const _ as usize } , - 1usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( u ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . d as * const _ as usize } , - 2usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( d ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . cch as * const _ as usize } , - 3usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( cch ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . cu as * const _ as usize } , - 4usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( cu ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . cd as * const _ as usize } , - 5usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( cd ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . Cch as * const _ as usize } , - 6usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( Cch ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . Cu as * const _ as usize } , - 7usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( Cu ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . Cd as * const _ as usize } , - 8usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( Cd ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . Ccch as * const _ as usize } , - 9usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( Ccch ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . Ccu as * const _ as usize } , - 10usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( Ccu ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . Ccd as * const _ as usize } , - 11usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( Ccd ) )); + assert_eq!( + ::std::mem::size_of::<Test>(), + 12usize, + concat!("Size of: ", stringify!(Test)) + ); + assert_eq!( + ::std::mem::align_of::<Test>(), + 1usize, + concat!("Alignment of ", stringify!(Test)) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).ch as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(ch) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).u as *const _ as usize }, + 1usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(u) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).d as *const _ as usize }, + 2usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(d) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).cch as *const _ as usize }, + 3usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(cch) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).cu as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(cu) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).cd as *const _ as usize }, + 5usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(cd) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).Cch as *const _ as usize }, + 6usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(Cch) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).Cu as *const _ as usize }, + 7usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(Cu) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).Cd as *const _ as usize }, + 8usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(Cd) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).Ccch as *const _ as usize }, + 9usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(Ccch) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).Ccu as *const _ as usize }, + 10usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(Ccu) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).Ccd as *const _ as usize }, + 11usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(Ccd) + ) + ); } impl Clone for Test { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/class.rs b/tests/expectations/tests/class.rs index d7ee8b52..351f041a 100644 --- a/tests/expectations/tests/class.rs +++ b/tests/expectations/tests/class.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,16 +29,18 @@ 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)] #[derive(Copy)] pub struct C { @@ -45,25 +49,41 @@ 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() } + } } #[repr(C)] pub struct C_with_zero_length_array { @@ -73,33 +93,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 { @@ -109,15 +149,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 { @@ -128,17 +174,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)] @@ -147,15 +203,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 { @@ -164,16 +231,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(Copy)] @@ -184,26 +256,46 @@ pub union 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 + } } impl Default for Union { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Copy)] @@ -212,21 +304,36 @@ 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 + } } impl Default for WithUnion { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] @@ -235,41 +342,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 = "\u{1}_ZNK32RealAbstractionWithTonsOfMethods3barEv"] - pub fn RealAbstractionWithTonsOfMethods_bar(this: - *const RealAbstractionWithTonsOfMethods); + pub fn RealAbstractionWithTonsOfMethods_bar(this: *const RealAbstractionWithTonsOfMethods); } extern "C" { #[link_name = "\u{1}_ZN32RealAbstractionWithTonsOfMethods3barEv"] - pub fn RealAbstractionWithTonsOfMethods_bar1(this: - *mut RealAbstractionWithTonsOfMethods); + pub fn RealAbstractionWithTonsOfMethods_bar1(this: *mut RealAbstractionWithTonsOfMethods); } extern "C" { #[link_name = "\u{1}_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 = "\u{1}_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) @@ -279,5 +394,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/class_nested.rs b/tests/expectations/tests/class_nested.rs index cb99f81b..32b01f86 100644 --- a/tests/expectations/tests/class_nested.rs +++ b/tests/expectations/tests/class_nested.rs @@ -125,10 +125,17 @@ fn __bindgen_test_layout_A_D_open0_int_close0_instantiation() { 4usize, concat!( "Size of template specialization: ", - stringify ! ( A_D < :: std :: os :: raw :: c_int > ) + stringify!(A_D<::std::os::raw::c_int>) + ) + ); + assert_eq!( + ::std::mem::align_of::<A_D<::std::os::raw::c_int>>(), + 4usize, + concat!( + "Alignment of template specialization: ", + stringify!(A_D<::std::os::raw::c_int>) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < A_D < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( A_D < :: std :: os :: raw :: c_int > ) ) ); } extern "C" { #[link_name = "\u{1}baz"] @@ -141,9 +148,26 @@ pub struct D { } #[test] fn bindgen_test_layout_D() { - assert_eq ! ( :: std :: mem :: size_of :: < D > ( ) , 4usize , concat ! ( "Size of: " , stringify ! ( D ) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < D > ( ) , 4usize , concat ! ( "Alignment of " , stringify ! ( D ) ) ); - assert_eq ! ( unsafe { & ( * ( 0 as * const D ) ) . member as * const _ as usize } , 0usize , concat ! ( "Alignment of field: " , stringify ! ( D ) , "::" , stringify ! ( member ) ) ); + assert_eq!( + ::std::mem::size_of::<D>(), + 4usize, + concat!("Size of: ", stringify!(D)) + ); + assert_eq!( + ::std::mem::align_of::<D>(), + 4usize, + concat!("Alignment of ", stringify!(D)) + ); + assert_eq!( + unsafe { &(*(0 as *const D)).member as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(D), + "::", + stringify!(member) + ) + ); } impl Clone for D { fn clone(&self) -> Self { diff --git a/tests/expectations/tests/class_no_members.rs b/tests/expectations/tests/class_no_members.rs index 7fc05c5f..c41f0b04 100644 --- a/tests/expectations/tests/class_no_members.rs +++ b/tests/expectations/tests/class_no_members.rs @@ -11,13 +11,21 @@ pub struct whatever { } #[test] fn bindgen_test_layout_whatever() { - assert_eq!(::std::mem::size_of::<whatever>() , 1usize , concat ! ( - "Size of: " , stringify ! ( whatever ) )); - assert_eq! (::std::mem::align_of::<whatever>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( whatever ) )); + assert_eq!( + ::std::mem::size_of::<whatever>(), + 1usize, + concat!("Size of: ", stringify!(whatever)) + ); + assert_eq!( + ::std::mem::align_of::<whatever>(), + 1usize, + concat!("Alignment of ", stringify!(whatever)) + ); } impl Clone for whatever { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] @@ -26,13 +34,21 @@ pub struct whatever_child { } #[test] fn bindgen_test_layout_whatever_child() { - assert_eq!(::std::mem::size_of::<whatever_child>() , 1usize , concat ! ( - "Size of: " , stringify ! ( whatever_child ) )); - assert_eq! (::std::mem::align_of::<whatever_child>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( whatever_child ) )); + assert_eq!( + ::std::mem::size_of::<whatever_child>(), + 1usize, + concat!("Size of: ", stringify!(whatever_child)) + ); + assert_eq!( + ::std::mem::align_of::<whatever_child>(), + 1usize, + concat!("Alignment of ", stringify!(whatever_child)) + ); } impl Clone for whatever_child { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] @@ -41,20 +57,29 @@ pub struct whatever_child_with_member { } #[test] fn bindgen_test_layout_whatever_child_with_member() { - assert_eq!(::std::mem::size_of::<whatever_child_with_member>() , 4usize , - concat ! ( - "Size of: " , stringify ! ( whatever_child_with_member ) )); - assert_eq! (::std::mem::align_of::<whatever_child_with_member>() , 4usize - , concat ! ( - "Alignment of " , stringify ! ( whatever_child_with_member ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const whatever_child_with_member ) ) . m_member - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - whatever_child_with_member ) , "::" , stringify ! ( m_member ) - )); + assert_eq!( + ::std::mem::size_of::<whatever_child_with_member>(), + 4usize, + concat!("Size of: ", stringify!(whatever_child_with_member)) + ); + assert_eq!( + ::std::mem::align_of::<whatever_child_with_member>(), + 4usize, + concat!("Alignment of ", stringify!(whatever_child_with_member)) + ); + assert_eq!( + unsafe { &(*(0 as *const whatever_child_with_member)).m_member as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(whatever_child_with_member), + "::", + stringify!(m_member) + ) + ); } impl Clone for whatever_child_with_member { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/class_static.rs b/tests/expectations/tests/class_static.rs index 93ab9542..e03938a0 100644 --- a/tests/expectations/tests/class_static.rs +++ b/tests/expectations/tests/class_static.rs @@ -15,18 +15,25 @@ extern "C" { } extern "C" { #[link_name = "\u{1}_ZN7MyClass26example_check_no_collisionE"] - pub static mut MyClass_example_check_no_collision: - *const ::std::os::raw::c_int; + pub static mut MyClass_example_check_no_collision: *const ::std::os::raw::c_int; } #[test] fn bindgen_test_layout_MyClass() { - assert_eq!(::std::mem::size_of::<MyClass>() , 1usize , concat ! ( - "Size of: " , stringify ! ( MyClass ) )); - assert_eq! (::std::mem::align_of::<MyClass>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( MyClass ) )); + assert_eq!( + ::std::mem::size_of::<MyClass>(), + 1usize, + concat!("Size of: ", stringify!(MyClass)) + ); + assert_eq!( + ::std::mem::align_of::<MyClass>(), + 1usize, + concat!("Alignment of ", stringify!(MyClass)) + ); } impl Clone for MyClass { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } extern "C" { #[link_name = "\u{1}_ZL26example_check_no_collision"] diff --git a/tests/expectations/tests/class_static_const.rs b/tests/expectations/tests/class_static_const.rs index 9a4b5425..945236de 100644 --- a/tests/expectations/tests/class_static_const.rs +++ b/tests/expectations/tests/class_static_const.rs @@ -14,11 +14,19 @@ pub const A_b: i32 = 63; pub const A_c: u32 = 255; #[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!( + ::std::mem::size_of::<A>(), + 1usize, + concat!("Size of: ", stringify!(A)) + ); + assert_eq!( + ::std::mem::align_of::<A>(), + 1usize, + concat!("Alignment of ", stringify!(A)) + ); } impl Clone for A { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/class_with_dtor.rs b/tests/expectations/tests/class_with_dtor.rs index 08e3aa88..36ad6307 100644 --- a/tests/expectations/tests/class_with_dtor.rs +++ b/tests/expectations/tests/class_with_dtor.rs @@ -56,8 +56,15 @@ fn __bindgen_test_layout_HandleWithDtor_open0_int_close0_instantiation() { 8usize, concat!( "Size of template specialization: ", - stringify ! ( HandleWithDtor < :: std :: os :: raw :: c_int > ) + stringify!(HandleWithDtor<::std::os::raw::c_int>) + ) + ); + assert_eq!( + ::std::mem::align_of::<HandleWithDtor<::std::os::raw::c_int>>(), + 8usize, + concat!( + "Alignment of template specialization: ", + stringify!(HandleWithDtor<::std::os::raw::c_int>) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < HandleWithDtor < :: std :: os :: raw :: c_int > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( HandleWithDtor < :: std :: os :: raw :: c_int > ) ) ); } diff --git a/tests/expectations/tests/class_with_inner_struct.rs b/tests/expectations/tests/class_with_inner_struct.rs index 03df6008..f471a757 100644 --- a/tests/expectations/tests/class_with_inner_struct.rs +++ b/tests/expectations/tests/class_with_inner_struct.rs @@ -19,23 +19,41 @@ pub struct A_Segment { } #[test] fn bindgen_test_layout_A_Segment() { - assert_eq!(::std::mem::size_of::<A_Segment>() , 8usize , concat ! ( - "Size of: " , stringify ! ( A_Segment ) )); - assert_eq! (::std::mem::align_of::<A_Segment>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( A_Segment ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const A_Segment ) ) . begin as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( A_Segment ) , "::" , - stringify ! ( begin ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const A_Segment ) ) . end as * const _ as usize - } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( A_Segment ) , "::" , - stringify ! ( end ) )); + assert_eq!( + ::std::mem::size_of::<A_Segment>(), + 8usize, + concat!("Size of: ", stringify!(A_Segment)) + ); + assert_eq!( + ::std::mem::align_of::<A_Segment>(), + 4usize, + concat!("Alignment of ", stringify!(A_Segment)) + ); + assert_eq!( + unsafe { &(*(0 as *const A_Segment)).begin as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(A_Segment), + "::", + stringify!(begin) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const A_Segment)).end as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(A_Segment), + "::", + stringify!(end) + ) + ); } impl Clone for A_Segment { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Copy)] @@ -45,21 +63,36 @@ pub union A__bindgen_ty_1 { } #[test] fn bindgen_test_layout_A__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<A__bindgen_ty_1>() , 4usize , concat ! ( - "Size of: " , stringify ! ( A__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<A__bindgen_ty_1>() , 4usize , concat ! - ( "Alignment of " , stringify ! ( A__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const A__bindgen_ty_1 ) ) . f as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( A__bindgen_ty_1 ) , - "::" , stringify ! ( f ) )); + assert_eq!( + ::std::mem::size_of::<A__bindgen_ty_1>(), + 4usize, + concat!("Size of: ", stringify!(A__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<A__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(A__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const A__bindgen_ty_1)).f as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(A__bindgen_ty_1), + "::", + stringify!(f) + ) + ); } impl Clone for A__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for A__bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Copy)] @@ -69,43 +102,74 @@ pub union A__bindgen_ty_2 { } #[test] fn bindgen_test_layout_A__bindgen_ty_2() { - assert_eq!(::std::mem::size_of::<A__bindgen_ty_2>() , 4usize , concat ! ( - "Size of: " , stringify ! ( A__bindgen_ty_2 ) )); - assert_eq! (::std::mem::align_of::<A__bindgen_ty_2>() , 4usize , concat ! - ( "Alignment of " , stringify ! ( A__bindgen_ty_2 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const A__bindgen_ty_2 ) ) . d as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( A__bindgen_ty_2 ) , - "::" , stringify ! ( d ) )); + assert_eq!( + ::std::mem::size_of::<A__bindgen_ty_2>(), + 4usize, + concat!("Size of: ", stringify!(A__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::<A__bindgen_ty_2>(), + 4usize, + concat!("Alignment of ", stringify!(A__bindgen_ty_2)) + ); + assert_eq!( + unsafe { &(*(0 as *const A__bindgen_ty_2)).d as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(A__bindgen_ty_2), + "::", + stringify!(d) + ) + ); } impl Clone for A__bindgen_ty_2 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for A__bindgen_ty_2 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[test] fn bindgen_test_layout_A() { - assert_eq!(::std::mem::size_of::<A>() , 12usize , concat ! ( - "Size of: " , stringify ! ( A ) )); - assert_eq! (::std::mem::align_of::<A>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( A ) )); - assert_eq! (unsafe { & ( * ( 0 as * const A ) ) . c as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( A ) , "::" , stringify - ! ( c ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const A ) ) . named_union as * const _ as usize - } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( A ) , "::" , stringify - ! ( named_union ) )); + assert_eq!( + ::std::mem::size_of::<A>(), + 12usize, + concat!("Size of: ", stringify!(A)) + ); + assert_eq!( + ::std::mem::align_of::<A>(), + 4usize, + concat!("Alignment of ", stringify!(A)) + ); + assert_eq!( + unsafe { &(*(0 as *const A)).c as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(A), "::", stringify!(c)) + ); + assert_eq!( + unsafe { &(*(0 as *const A)).named_union as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(A), + "::", + stringify!(named_union) + ) + ); } impl Clone for A { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for A { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] @@ -120,37 +184,64 @@ pub struct B_Segment { } #[test] fn bindgen_test_layout_B_Segment() { - assert_eq!(::std::mem::size_of::<B_Segment>() , 8usize , concat ! ( - "Size of: " , stringify ! ( B_Segment ) )); - assert_eq! (::std::mem::align_of::<B_Segment>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( B_Segment ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const B_Segment ) ) . begin as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( B_Segment ) , "::" , - stringify ! ( begin ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const B_Segment ) ) . end as * const _ as usize - } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( B_Segment ) , "::" , - stringify ! ( end ) )); + assert_eq!( + ::std::mem::size_of::<B_Segment>(), + 8usize, + concat!("Size of: ", stringify!(B_Segment)) + ); + assert_eq!( + ::std::mem::align_of::<B_Segment>(), + 4usize, + concat!("Alignment of ", stringify!(B_Segment)) + ); + assert_eq!( + unsafe { &(*(0 as *const B_Segment)).begin as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(B_Segment), + "::", + stringify!(begin) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const B_Segment)).end as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(B_Segment), + "::", + stringify!(end) + ) + ); } impl Clone for B_Segment { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_B() { - assert_eq!(::std::mem::size_of::<B>() , 4usize , concat ! ( - "Size of: " , stringify ! ( B ) )); - assert_eq! (::std::mem::align_of::<B>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( B ) )); - assert_eq! (unsafe { & ( * ( 0 as * const B ) ) . d as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( B ) , "::" , stringify - ! ( d ) )); + assert_eq!( + ::std::mem::size_of::<B>(), + 4usize, + concat!("Size of: ", stringify!(B)) + ); + assert_eq!( + ::std::mem::align_of::<B>(), + 4usize, + concat!("Alignment of ", stringify!(B)) + ); + assert_eq!( + unsafe { &(*(0 as *const B)).d as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(B), "::", stringify!(d)) + ); } impl Clone for B { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(i32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] @@ -183,40 +274,61 @@ pub struct C__bindgen_ty_1__bindgen_ty_1 { } #[test] fn bindgen_test_layout_C__bindgen_ty_1__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<C__bindgen_ty_1__bindgen_ty_1>() , - 16usize , concat ! ( - "Size of: " , stringify ! ( C__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<C__bindgen_ty_1__bindgen_ty_1>() , - 4usize , concat ! ( - "Alignment of " , stringify ! ( C__bindgen_ty_1__bindgen_ty_1 - ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_1 ) ) . mX1 - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - C__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( mX1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_1 ) ) . mY1 - as * const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( - C__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( mY1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_1 ) ) . mX2 - as * const _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( - C__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( mX2 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_1 ) ) . mY2 - as * const _ as usize } , 12usize , concat ! ( - "Alignment of field: " , stringify ! ( - C__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( mY2 ) - )); + assert_eq!( + ::std::mem::size_of::<C__bindgen_ty_1__bindgen_ty_1>(), + 16usize, + concat!("Size of: ", stringify!(C__bindgen_ty_1__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<C__bindgen_ty_1__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(C__bindgen_ty_1__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const C__bindgen_ty_1__bindgen_ty_1)).mX1 as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(C__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(mX1) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const C__bindgen_ty_1__bindgen_ty_1)).mY1 as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(C__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(mY1) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const C__bindgen_ty_1__bindgen_ty_1)).mX2 as *const _ as usize }, + 8usize, + concat!( + "Alignment of field: ", + stringify!(C__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(mX2) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const C__bindgen_ty_1__bindgen_ty_1)).mY2 as *const _ as usize }, + 12usize, + concat!( + "Alignment of field: ", + stringify!(C__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(mY2) + ) + ); } impl Clone for C__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] @@ -226,49 +338,79 @@ pub struct C__bindgen_ty_1__bindgen_ty_2 { } #[test] fn bindgen_test_layout_C__bindgen_ty_1__bindgen_ty_2() { - assert_eq!(::std::mem::size_of::<C__bindgen_ty_1__bindgen_ty_2>() , 8usize - , concat ! ( - "Size of: " , stringify ! ( C__bindgen_ty_1__bindgen_ty_2 ) )); - assert_eq! (::std::mem::align_of::<C__bindgen_ty_1__bindgen_ty_2>() , - 4usize , concat ! ( - "Alignment of " , stringify ! ( C__bindgen_ty_1__bindgen_ty_2 - ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_2 ) ) . - mStepSyntax as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - C__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( - mStepSyntax ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_2 ) ) . - mSteps as * const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( - C__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( mSteps - ) )); + assert_eq!( + ::std::mem::size_of::<C__bindgen_ty_1__bindgen_ty_2>(), + 8usize, + concat!("Size of: ", stringify!(C__bindgen_ty_1__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::<C__bindgen_ty_1__bindgen_ty_2>(), + 4usize, + concat!("Alignment of ", stringify!(C__bindgen_ty_1__bindgen_ty_2)) + ); + assert_eq!( + unsafe { &(*(0 as *const C__bindgen_ty_1__bindgen_ty_2)).mStepSyntax as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(C__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(mStepSyntax) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const C__bindgen_ty_1__bindgen_ty_2)).mSteps as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(C__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(mSteps) + ) + ); } impl Clone for C__bindgen_ty_1__bindgen_ty_2 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for C__bindgen_ty_1__bindgen_ty_2 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[test] fn bindgen_test_layout_C__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<C__bindgen_ty_1>() , 16usize , concat ! ( - "Size of: " , stringify ! ( C__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<C__bindgen_ty_1>() , 4usize , concat ! - ( "Alignment of " , stringify ! ( C__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C__bindgen_ty_1 ) ) . mFunc as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( C__bindgen_ty_1 ) , - "::" , stringify ! ( mFunc ) )); + assert_eq!( + ::std::mem::size_of::<C__bindgen_ty_1>(), + 16usize, + concat!("Size of: ", stringify!(C__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<C__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(C__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const C__bindgen_ty_1)).mFunc as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(C__bindgen_ty_1), + "::", + stringify!(mFunc) + ) + ); } impl Clone for C__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for C__bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] @@ -278,38 +420,67 @@ pub struct C_Segment { } #[test] fn bindgen_test_layout_C_Segment() { - assert_eq!(::std::mem::size_of::<C_Segment>() , 8usize , concat ! ( - "Size of: " , stringify ! ( C_Segment ) )); - assert_eq! (::std::mem::align_of::<C_Segment>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( C_Segment ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C_Segment ) ) . begin as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( C_Segment ) , "::" , - stringify ! ( begin ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C_Segment ) ) . end as * const _ as usize - } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( C_Segment ) , "::" , - stringify ! ( end ) )); + assert_eq!( + ::std::mem::size_of::<C_Segment>(), + 8usize, + concat!("Size of: ", stringify!(C_Segment)) + ); + assert_eq!( + ::std::mem::align_of::<C_Segment>(), + 4usize, + concat!("Alignment of ", stringify!(C_Segment)) + ); + assert_eq!( + unsafe { &(*(0 as *const C_Segment)).begin as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(C_Segment), + "::", + stringify!(begin) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const C_Segment)).end as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(C_Segment), + "::", + stringify!(end) + ) + ); } impl Clone for C_Segment { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_C() { - assert_eq!(::std::mem::size_of::<C>() , 20usize , 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 ) ) . d as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( d ) )); + assert_eq!( + ::std::mem::size_of::<C>(), + 20usize, + 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)).d as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(C), "::", stringify!(d)) + ); } 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() } + } } diff --git a/tests/expectations/tests/class_with_inner_struct_1_0.rs b/tests/expectations/tests/class_with_inner_struct_1_0.rs index 42376dee..07a2fe48 100644 --- a/tests/expectations/tests/class_with_inner_struct_1_0.rs +++ b/tests/expectations/tests/class_with_inner_struct_1_0.rs @@ -6,35 +6,47 @@ #[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(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct A { @@ -50,23 +62,41 @@ pub struct A_Segment { } #[test] fn bindgen_test_layout_A_Segment() { - assert_eq!(::std::mem::size_of::<A_Segment>() , 8usize , concat ! ( - "Size of: " , stringify ! ( A_Segment ) )); - assert_eq! (::std::mem::align_of::<A_Segment>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( A_Segment ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const A_Segment ) ) . begin as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( A_Segment ) , "::" , - stringify ! ( begin ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const A_Segment ) ) . end as * const _ as usize - } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( A_Segment ) , "::" , - stringify ! ( end ) )); + assert_eq!( + ::std::mem::size_of::<A_Segment>(), + 8usize, + concat!("Size of: ", stringify!(A_Segment)) + ); + assert_eq!( + ::std::mem::align_of::<A_Segment>(), + 4usize, + concat!("Alignment of ", stringify!(A_Segment)) + ); + assert_eq!( + unsafe { &(*(0 as *const A_Segment)).begin as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(A_Segment), + "::", + stringify!(begin) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const A_Segment)).end as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(A_Segment), + "::", + stringify!(end) + ) + ); } impl Clone for A_Segment { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] @@ -76,18 +106,31 @@ pub struct A__bindgen_ty_1 { } #[test] fn bindgen_test_layout_A__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<A__bindgen_ty_1>() , 4usize , concat ! ( - "Size of: " , stringify ! ( A__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<A__bindgen_ty_1>() , 4usize , concat ! - ( "Alignment of " , stringify ! ( A__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const A__bindgen_ty_1 ) ) . f as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( A__bindgen_ty_1 ) , - "::" , stringify ! ( f ) )); + assert_eq!( + ::std::mem::size_of::<A__bindgen_ty_1>(), + 4usize, + concat!("Size of: ", stringify!(A__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<A__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(A__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const A__bindgen_ty_1)).f as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(A__bindgen_ty_1), + "::", + stringify!(f) + ) + ); } impl Clone for A__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] @@ -97,37 +140,64 @@ pub struct A__bindgen_ty_2 { } #[test] fn bindgen_test_layout_A__bindgen_ty_2() { - assert_eq!(::std::mem::size_of::<A__bindgen_ty_2>() , 4usize , concat ! ( - "Size of: " , stringify ! ( A__bindgen_ty_2 ) )); - assert_eq! (::std::mem::align_of::<A__bindgen_ty_2>() , 4usize , concat ! - ( "Alignment of " , stringify ! ( A__bindgen_ty_2 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const A__bindgen_ty_2 ) ) . d as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( A__bindgen_ty_2 ) , - "::" , stringify ! ( d ) )); + assert_eq!( + ::std::mem::size_of::<A__bindgen_ty_2>(), + 4usize, + concat!("Size of: ", stringify!(A__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::<A__bindgen_ty_2>(), + 4usize, + concat!("Alignment of ", stringify!(A__bindgen_ty_2)) + ); + assert_eq!( + unsafe { &(*(0 as *const A__bindgen_ty_2)).d as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(A__bindgen_ty_2), + "::", + stringify!(d) + ) + ); } impl Clone for A__bindgen_ty_2 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_A() { - assert_eq!(::std::mem::size_of::<A>() , 12usize , concat ! ( - "Size of: " , stringify ! ( A ) )); - assert_eq! (::std::mem::align_of::<A>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( A ) )); - assert_eq! (unsafe { & ( * ( 0 as * const A ) ) . c as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( A ) , "::" , stringify - ! ( c ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const A ) ) . named_union as * const _ as usize - } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( A ) , "::" , stringify - ! ( named_union ) )); + assert_eq!( + ::std::mem::size_of::<A>(), + 12usize, + concat!("Size of: ", stringify!(A)) + ); + assert_eq!( + ::std::mem::align_of::<A>(), + 4usize, + concat!("Alignment of ", stringify!(A)) + ); + assert_eq!( + unsafe { &(*(0 as *const A)).c as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(A), "::", stringify!(c)) + ); + assert_eq!( + unsafe { &(*(0 as *const A)).named_union as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(A), + "::", + stringify!(named_union) + ) + ); } impl Clone for A { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] @@ -142,37 +212,64 @@ pub struct B_Segment { } #[test] fn bindgen_test_layout_B_Segment() { - assert_eq!(::std::mem::size_of::<B_Segment>() , 8usize , concat ! ( - "Size of: " , stringify ! ( B_Segment ) )); - assert_eq! (::std::mem::align_of::<B_Segment>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( B_Segment ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const B_Segment ) ) . begin as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( B_Segment ) , "::" , - stringify ! ( begin ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const B_Segment ) ) . end as * const _ as usize - } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( B_Segment ) , "::" , - stringify ! ( end ) )); + assert_eq!( + ::std::mem::size_of::<B_Segment>(), + 8usize, + concat!("Size of: ", stringify!(B_Segment)) + ); + assert_eq!( + ::std::mem::align_of::<B_Segment>(), + 4usize, + concat!("Alignment of ", stringify!(B_Segment)) + ); + assert_eq!( + unsafe { &(*(0 as *const B_Segment)).begin as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(B_Segment), + "::", + stringify!(begin) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const B_Segment)).end as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(B_Segment), + "::", + stringify!(end) + ) + ); } impl Clone for B_Segment { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_B() { - assert_eq!(::std::mem::size_of::<B>() , 4usize , concat ! ( - "Size of: " , stringify ! ( B ) )); - assert_eq! (::std::mem::align_of::<B>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( B ) )); - assert_eq! (unsafe { & ( * ( 0 as * const B ) ) . d as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( B ) , "::" , stringify - ! ( d ) )); + assert_eq!( + ::std::mem::size_of::<B>(), + 4usize, + concat!("Size of: ", stringify!(B)) + ); + assert_eq!( + ::std::mem::align_of::<B>(), + 4usize, + concat!("Alignment of ", stringify!(B)) + ); + assert_eq!( + unsafe { &(*(0 as *const B)).d as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(B), "::", stringify!(d)) + ); } impl Clone for B { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(i32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] @@ -205,40 +302,61 @@ pub struct C__bindgen_ty_1__bindgen_ty_1 { } #[test] fn bindgen_test_layout_C__bindgen_ty_1__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<C__bindgen_ty_1__bindgen_ty_1>() , - 16usize , concat ! ( - "Size of: " , stringify ! ( C__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<C__bindgen_ty_1__bindgen_ty_1>() , - 4usize , concat ! ( - "Alignment of " , stringify ! ( C__bindgen_ty_1__bindgen_ty_1 - ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_1 ) ) . mX1 - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - C__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( mX1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_1 ) ) . mY1 - as * const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( - C__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( mY1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_1 ) ) . mX2 - as * const _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( - C__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( mX2 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_1 ) ) . mY2 - as * const _ as usize } , 12usize , concat ! ( - "Alignment of field: " , stringify ! ( - C__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( mY2 ) - )); + assert_eq!( + ::std::mem::size_of::<C__bindgen_ty_1__bindgen_ty_1>(), + 16usize, + concat!("Size of: ", stringify!(C__bindgen_ty_1__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<C__bindgen_ty_1__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(C__bindgen_ty_1__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const C__bindgen_ty_1__bindgen_ty_1)).mX1 as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(C__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(mX1) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const C__bindgen_ty_1__bindgen_ty_1)).mY1 as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(C__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(mY1) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const C__bindgen_ty_1__bindgen_ty_1)).mX2 as *const _ as usize }, + 8usize, + concat!( + "Alignment of field: ", + stringify!(C__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(mX2) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const C__bindgen_ty_1__bindgen_ty_1)).mY2 as *const _ as usize }, + 12usize, + concat!( + "Alignment of field: ", + stringify!(C__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(mY2) + ) + ); } impl Clone for C__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] @@ -248,46 +366,74 @@ pub struct C__bindgen_ty_1__bindgen_ty_2 { } #[test] fn bindgen_test_layout_C__bindgen_ty_1__bindgen_ty_2() { - assert_eq!(::std::mem::size_of::<C__bindgen_ty_1__bindgen_ty_2>() , 8usize - , concat ! ( - "Size of: " , stringify ! ( C__bindgen_ty_1__bindgen_ty_2 ) )); - assert_eq! (::std::mem::align_of::<C__bindgen_ty_1__bindgen_ty_2>() , - 4usize , concat ! ( - "Alignment of " , stringify ! ( C__bindgen_ty_1__bindgen_ty_2 - ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_2 ) ) . - mStepSyntax as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - C__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( - mStepSyntax ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_2 ) ) . - mSteps as * const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( - C__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( mSteps - ) )); + assert_eq!( + ::std::mem::size_of::<C__bindgen_ty_1__bindgen_ty_2>(), + 8usize, + concat!("Size of: ", stringify!(C__bindgen_ty_1__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::<C__bindgen_ty_1__bindgen_ty_2>(), + 4usize, + concat!("Alignment of ", stringify!(C__bindgen_ty_1__bindgen_ty_2)) + ); + assert_eq!( + unsafe { &(*(0 as *const C__bindgen_ty_1__bindgen_ty_2)).mStepSyntax as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(C__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(mStepSyntax) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const C__bindgen_ty_1__bindgen_ty_2)).mSteps as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(C__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(mSteps) + ) + ); } impl Clone for C__bindgen_ty_1__bindgen_ty_2 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for C__bindgen_ty_1__bindgen_ty_2 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[test] fn bindgen_test_layout_C__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<C__bindgen_ty_1>() , 16usize , concat ! ( - "Size of: " , stringify ! ( C__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<C__bindgen_ty_1>() , 4usize , concat ! - ( "Alignment of " , stringify ! ( C__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C__bindgen_ty_1 ) ) . mFunc as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( C__bindgen_ty_1 ) , - "::" , stringify ! ( mFunc ) )); + assert_eq!( + ::std::mem::size_of::<C__bindgen_ty_1>(), + 16usize, + concat!("Size of: ", stringify!(C__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<C__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(C__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const C__bindgen_ty_1)).mFunc as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(C__bindgen_ty_1), + "::", + stringify!(mFunc) + ) + ); } impl Clone for C__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] @@ -297,35 +443,62 @@ pub struct C_Segment { } #[test] fn bindgen_test_layout_C_Segment() { - assert_eq!(::std::mem::size_of::<C_Segment>() , 8usize , concat ! ( - "Size of: " , stringify ! ( C_Segment ) )); - assert_eq! (::std::mem::align_of::<C_Segment>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( C_Segment ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C_Segment ) ) . begin as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( C_Segment ) , "::" , - stringify ! ( begin ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C_Segment ) ) . end as * const _ as usize - } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( C_Segment ) , "::" , - stringify ! ( end ) )); + assert_eq!( + ::std::mem::size_of::<C_Segment>(), + 8usize, + concat!("Size of: ", stringify!(C_Segment)) + ); + assert_eq!( + ::std::mem::align_of::<C_Segment>(), + 4usize, + concat!("Alignment of ", stringify!(C_Segment)) + ); + assert_eq!( + unsafe { &(*(0 as *const C_Segment)).begin as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(C_Segment), + "::", + stringify!(begin) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const C_Segment)).end as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(C_Segment), + "::", + stringify!(end) + ) + ); } impl Clone for C_Segment { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_C() { - assert_eq!(::std::mem::size_of::<C>() , 20usize , 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 ) ) . d as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( d ) )); + assert_eq!( + ::std::mem::size_of::<C>(), + 20usize, + 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)).d as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(C), "::", stringify!(d)) + ); } impl Clone for C { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/class_with_typedef.rs b/tests/expectations/tests/class_with_typedef.rs index 480b6b34..90648fcc 100644 --- a/tests/expectations/tests/class_with_typedef.rs +++ b/tests/expectations/tests/class_with_typedef.rs @@ -18,33 +18,46 @@ pub type C_MyInt = ::std::os::raw::c_int; pub type C_Lookup = *const ::std::os::raw::c_char; #[test] fn bindgen_test_layout_C() { - assert_eq!(::std::mem::size_of::<C>() , 72usize , concat ! ( - "Size of: " , stringify ! ( C ) )); - assert_eq! (::std::mem::align_of::<C>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( C ) )); - assert_eq! (unsafe { & ( * ( 0 as * const C ) ) . c as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( c ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C ) ) . ptr as * const _ as usize } , - 8usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( ptr ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C ) ) . arr as * const _ as usize } , - 16usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( arr ) )); - assert_eq! (unsafe { & ( * ( 0 as * const C ) ) . d as * const _ as usize - } , 56usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( d ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C ) ) . other_ptr as * const _ as usize } - , 64usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( other_ptr ) )); + assert_eq!( + ::std::mem::size_of::<C>(), + 72usize, + concat!("Size of: ", stringify!(C)) + ); + assert_eq!( + ::std::mem::align_of::<C>(), + 8usize, + concat!("Alignment of ", stringify!(C)) + ); + assert_eq!( + unsafe { &(*(0 as *const C)).c as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(C), "::", stringify!(c)) + ); + assert_eq!( + unsafe { &(*(0 as *const C)).ptr as *const _ as usize }, + 8usize, + concat!("Alignment of field: ", stringify!(C), "::", stringify!(ptr)) + ); + assert_eq!( + unsafe { &(*(0 as *const C)).arr as *const _ as usize }, + 16usize, + concat!("Alignment of field: ", stringify!(C), "::", stringify!(arr)) + ); + assert_eq!( + unsafe { &(*(0 as *const C)).d as *const _ as usize }, + 56usize, + concat!("Alignment of field: ", stringify!(C), "::", stringify!(d)) + ); + assert_eq!( + unsafe { &(*(0 as *const C)).other_ptr as *const _ as usize }, + 64usize, + concat!( + "Alignment of field: ", + stringify!(C), + "::", + stringify!(other_ptr) + ) + ); } extern "C" { #[link_name = "\u{1}_ZN1C6methodEi"] @@ -63,14 +76,20 @@ extern "C" { pub fn C_anotherMethod(this: *mut C, c: AnotherInt); } 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 C { #[inline] - pub unsafe fn method(&mut self, c: C_MyInt) { C_method(self, c) } + pub unsafe fn method(&mut self, c: C_MyInt) { + C_method(self, c) + } #[inline] pub unsafe fn methodRef(&mut self, c: *mut C_MyInt) { C_methodRef(self, c) @@ -92,19 +111,29 @@ pub struct D { } #[test] fn bindgen_test_layout_D() { - assert_eq!(::std::mem::size_of::<D>() , 80usize , concat ! ( - "Size of: " , stringify ! ( D ) )); - assert_eq! (::std::mem::align_of::<D>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( D ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const D ) ) . ptr as * const _ as usize } , - 72usize , concat ! ( - "Alignment of field: " , stringify ! ( D ) , "::" , stringify - ! ( ptr ) )); + assert_eq!( + ::std::mem::size_of::<D>(), + 80usize, + concat!("Size of: ", stringify!(D)) + ); + assert_eq!( + ::std::mem::align_of::<D>(), + 8usize, + concat!("Alignment of ", stringify!(D)) + ); + assert_eq!( + unsafe { &(*(0 as *const D)).ptr as *const _ as usize }, + 72usize, + concat!("Alignment of field: ", stringify!(D), "::", stringify!(ptr)) + ); } impl Clone for D { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for D { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/comment-indent.rs b/tests/expectations/tests/comment-indent.rs index 127c1b0e..3563da26 100644 --- a/tests/expectations/tests/comment-indent.rs +++ b/tests/expectations/tests/comment-indent.rs @@ -26,23 +26,39 @@ pub mod root { } #[test] fn bindgen_test_layout_Foo_Bar() { - assert_eq!(::std::mem::size_of::<Foo_Bar>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo_Bar ) )); - assert_eq! (::std::mem::align_of::<Foo_Bar>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo_Bar ) )); + assert_eq!( + ::std::mem::size_of::<Foo_Bar>(), + 1usize, + concat!("Size of: ", stringify!(Foo_Bar)) + ); + assert_eq!( + ::std::mem::align_of::<Foo_Bar>(), + 1usize, + concat!("Alignment of ", stringify!(Foo_Bar)) + ); } impl Clone for Foo_Bar { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::<Foo>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::<Foo>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::<Foo>(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::<Foo>(), + 1usize, + concat!("Alignment of ", stringify!(Foo)) + ); } impl Clone for Foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } pub mod test { #[allow(unused_imports)] @@ -63,18 +79,31 @@ pub mod root { } #[test] fn bindgen_test_layout_Baz() { - assert_eq!(::std::mem::size_of::<Baz>() , 4usize , concat ! ( - "Size of: " , stringify ! ( Baz ) )); - assert_eq! (::std::mem::align_of::<Baz>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Baz ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Baz ) ) . member as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Baz ) , "::" , - stringify ! ( member ) )); + assert_eq!( + ::std::mem::size_of::<Baz>(), + 4usize, + concat!("Size of: ", stringify!(Baz)) + ); + assert_eq!( + ::std::mem::align_of::<Baz>(), + 4usize, + concat!("Alignment of ", stringify!(Baz)) + ); + assert_eq!( + unsafe { &(*(0 as *const Baz)).member as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Baz), + "::", + stringify!(member) + ) + ); } impl Clone for Baz { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } /// I'm in an inline namespace, and as such I shouldn't get generated inside /// a rust module, except when the relevant option is specified. Also, this @@ -86,15 +115,23 @@ pub mod root { } #[test] fn bindgen_test_layout_InInlineNS() { - assert_eq!(::std::mem::size_of::<InInlineNS>() , 1usize , concat ! - ( "Size of: " , stringify ! ( InInlineNS ) )); - assert_eq! (::std::mem::align_of::<InInlineNS>() , 1usize , concat - ! ( "Alignment of " , stringify ! ( InInlineNS ) )); + assert_eq!( + ::std::mem::size_of::<InInlineNS>(), + 1usize, + concat!("Size of: ", stringify!(InInlineNS)) + ); + assert_eq!( + ::std::mem::align_of::<InInlineNS>(), + 1usize, + concat!("Alignment of ", stringify!(InInlineNS)) + ); } impl Clone for InInlineNS { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } - + #[repr(C)] #[derive(Debug, Default, Copy)] pub struct Bazz { @@ -102,13 +139,21 @@ pub mod root { } #[test] fn bindgen_test_layout_Bazz() { - assert_eq!(::std::mem::size_of::<Bazz>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Bazz ) )); - assert_eq! (::std::mem::align_of::<Bazz>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Bazz ) )); + assert_eq!( + ::std::mem::size_of::<Bazz>(), + 1usize, + concat!("Size of: ", stringify!(Bazz)) + ); + assert_eq!( + ::std::mem::align_of::<Bazz>(), + 1usize, + concat!("Alignment of ", stringify!(Bazz)) + ); } impl Clone for Bazz { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } } } diff --git a/tests/expectations/tests/complex.rs b/tests/expectations/tests/complex.rs index 6159f979..67721d06 100644 --- a/tests/expectations/tests/complex.rs +++ b/tests/expectations/tests/complex.rs @@ -17,18 +17,31 @@ pub struct TestDouble { } #[test] fn bindgen_test_layout_TestDouble() { - assert_eq!(::std::mem::size_of::<TestDouble>() , 16usize , concat ! ( - "Size of: " , stringify ! ( TestDouble ) )); - assert_eq! (::std::mem::align_of::<TestDouble>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( TestDouble ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const TestDouble ) ) . mMember as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( TestDouble ) , "::" , - stringify ! ( mMember ) )); + assert_eq!( + ::std::mem::size_of::<TestDouble>(), + 16usize, + concat!("Size of: ", stringify!(TestDouble)) + ); + assert_eq!( + ::std::mem::align_of::<TestDouble>(), + 8usize, + concat!("Alignment of ", stringify!(TestDouble)) + ); + assert_eq!( + unsafe { &(*(0 as *const TestDouble)).mMember as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(TestDouble), + "::", + stringify!(mMember) + ) + ); } impl Clone for TestDouble { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] @@ -37,21 +50,36 @@ pub struct TestDoublePtr { } #[test] fn bindgen_test_layout_TestDoublePtr() { - assert_eq!(::std::mem::size_of::<TestDoublePtr>() , 8usize , concat ! ( - "Size of: " , stringify ! ( TestDoublePtr ) )); - assert_eq! (::std::mem::align_of::<TestDoublePtr>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( TestDoublePtr ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const TestDoublePtr ) ) . mMember as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( TestDoublePtr ) , "::" - , stringify ! ( mMember ) )); + assert_eq!( + ::std::mem::size_of::<TestDoublePtr>(), + 8usize, + concat!("Size of: ", stringify!(TestDoublePtr)) + ); + assert_eq!( + ::std::mem::align_of::<TestDoublePtr>(), + 8usize, + concat!("Alignment of ", stringify!(TestDoublePtr)) + ); + assert_eq!( + unsafe { &(*(0 as *const TestDoublePtr)).mMember as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(TestDoublePtr), + "::", + stringify!(mMember) + ) + ); } impl Clone for TestDoublePtr { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for TestDoublePtr { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Default, Copy, PartialEq)] @@ -60,18 +88,31 @@ pub struct TestFloat { } #[test] fn bindgen_test_layout_TestFloat() { - assert_eq!(::std::mem::size_of::<TestFloat>() , 8usize , concat ! ( - "Size of: " , stringify ! ( TestFloat ) )); - assert_eq! (::std::mem::align_of::<TestFloat>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( TestFloat ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const TestFloat ) ) . mMember as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( TestFloat ) , "::" , - stringify ! ( mMember ) )); + assert_eq!( + ::std::mem::size_of::<TestFloat>(), + 8usize, + concat!("Size of: ", stringify!(TestFloat)) + ); + assert_eq!( + ::std::mem::align_of::<TestFloat>(), + 4usize, + concat!("Alignment of ", stringify!(TestFloat)) + ); + assert_eq!( + unsafe { &(*(0 as *const TestFloat)).mMember as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(TestFloat), + "::", + stringify!(mMember) + ) + ); } impl Clone for TestFloat { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] @@ -80,19 +121,34 @@ pub struct TestFloatPtr { } #[test] fn bindgen_test_layout_TestFloatPtr() { - assert_eq!(::std::mem::size_of::<TestFloatPtr>() , 8usize , concat ! ( - "Size of: " , stringify ! ( TestFloatPtr ) )); - assert_eq! (::std::mem::align_of::<TestFloatPtr>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( TestFloatPtr ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const TestFloatPtr ) ) . mMember as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( TestFloatPtr ) , "::" , - stringify ! ( mMember ) )); + assert_eq!( + ::std::mem::size_of::<TestFloatPtr>(), + 8usize, + concat!("Size of: ", stringify!(TestFloatPtr)) + ); + assert_eq!( + ::std::mem::align_of::<TestFloatPtr>(), + 8usize, + concat!("Alignment of ", stringify!(TestFloatPtr)) + ); + assert_eq!( + unsafe { &(*(0 as *const TestFloatPtr)).mMember as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(TestFloatPtr), + "::", + stringify!(mMember) + ) + ); } impl Clone for TestFloatPtr { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for TestFloatPtr { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/const_enum_unnamed.rs b/tests/expectations/tests/const_enum_unnamed.rs index 98c6240f..2749321f 100644 --- a/tests/expectations/tests/const_enum_unnamed.rs +++ b/tests/expectations/tests/const_enum_unnamed.rs @@ -8,7 +8,10 @@ pub const FOO_BAR: _bindgen_ty_1 = _bindgen_ty_1::FOO_BAR; pub const FOO_BAZ: _bindgen_ty_1 = _bindgen_ty_1::FOO_BAZ; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum _bindgen_ty_1 { FOO_BAR = 0, FOO_BAZ = 1, } +pub enum _bindgen_ty_1 { + FOO_BAR = 0, + FOO_BAZ = 1, +} #[repr(C)] #[derive(Debug, Default, Copy)] pub struct Foo { @@ -17,14 +20,24 @@ pub struct Foo { pub const Foo_FOO_BAR: Foo__bindgen_ty_1 = Foo__bindgen_ty_1::FOO_BAR; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Foo__bindgen_ty_1 { FOO_BAR = 10, } +pub enum Foo__bindgen_ty_1 { + FOO_BAR = 10, +} #[test] fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::<Foo>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::<Foo>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::<Foo>(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::<Foo>(), + 1usize, + concat!("Alignment of ", stringify!(Foo)) + ); } impl Clone for Foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/const_tparam.rs b/tests/expectations/tests/const_tparam.rs index 9c101ec6..218abbdb 100644 --- a/tests/expectations/tests/const_tparam.rs +++ b/tests/expectations/tests/const_tparam.rs @@ -11,6 +11,8 @@ pub struct C<T> { pub bar: *mut T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } -impl <T> Default for C<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for C<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/constify-enum.rs b/tests/expectations/tests/constify-enum.rs index 1d04210b..78644ae4 100644 --- a/tests/expectations/tests/constify-enum.rs +++ b/tests/expectations/tests/constify-enum.rs @@ -4,8 +4,7 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -pub const nsCSSPropertyID_eCSSProperty_COUNT_unexistingVariantValue: - nsCSSPropertyID = +pub const nsCSSPropertyID_eCSSProperty_COUNT_unexistingVariantValue: nsCSSPropertyID = nsCSSPropertyID::eCSSProperty_COUNT_unexistingVariantValue; pub const nsCSSPropertyID_eCSSProperty_COUNT: nsCSSPropertyID = nsCSSPropertyID::eCSSPropertyAlias_aa; diff --git a/tests/expectations/tests/constify-module-enums-namespace.rs b/tests/expectations/tests/constify-module-enums-namespace.rs index 4db009be..0a44963f 100644 --- a/tests/expectations/tests/constify-module-enums-namespace.rs +++ b/tests/expectations/tests/constify-module-enums-namespace.rs @@ -31,21 +31,36 @@ pub mod root { } #[test] fn bindgen_test_layout_bar() { - assert_eq!(::std::mem::size_of::<bar>() , 4usize , concat ! ( - "Size of: " , stringify ! ( bar ) )); - assert_eq! (::std::mem::align_of::<bar>() , 4usize , concat ! - ( "Alignment of " , stringify ! ( bar ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const bar ) ) . this_should_work as - * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( bar ) , - "::" , stringify ! ( this_should_work ) )); + assert_eq!( + ::std::mem::size_of::<bar>(), + 4usize, + concat!("Size of: ", stringify!(bar)) + ); + assert_eq!( + ::std::mem::align_of::<bar>(), + 4usize, + concat!("Alignment of ", stringify!(bar)) + ); + assert_eq!( + unsafe { &(*(0 as *const bar)).this_should_work as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(bar), + "::", + stringify!(this_should_work) + ) + ); } impl Clone for bar { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for bar { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } } } diff --git a/tests/expectations/tests/constify-module-enums-shadow-name.rs b/tests/expectations/tests/constify-module-enums-shadow-name.rs index 9b5fd7b8..58debcc6 100644 --- a/tests/expectations/tests/constify-module-enums-shadow-name.rs +++ b/tests/expectations/tests/constify-module-enums-shadow-name.rs @@ -18,19 +18,34 @@ pub struct bar { } #[test] fn bindgen_test_layout_bar() { - assert_eq!(::std::mem::size_of::<bar>() , 4usize , concat ! ( - "Size of: " , stringify ! ( bar ) )); - assert_eq! (::std::mem::align_of::<bar>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( bar ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const bar ) ) . member as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( bar ) , "::" , - stringify ! ( member ) )); + assert_eq!( + ::std::mem::size_of::<bar>(), + 4usize, + concat!("Size of: ", stringify!(bar)) + ); + assert_eq!( + ::std::mem::align_of::<bar>(), + 4usize, + concat!("Alignment of ", stringify!(bar)) + ); + assert_eq!( + unsafe { &(*(0 as *const bar)).member as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(bar), + "::", + stringify!(member) + ) + ); } impl Clone for bar { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for bar { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/constify-module-enums-simple-nonamespace.rs b/tests/expectations/tests/constify-module-enums-simple-nonamespace.rs index 4f8d46c5..32c173ef 100644 --- a/tests/expectations/tests/constify-module-enums-simple-nonamespace.rs +++ b/tests/expectations/tests/constify-module-enums-simple-nonamespace.rs @@ -17,24 +17,44 @@ pub struct Bar { } #[test] fn bindgen_test_layout_Bar() { - assert_eq!(::std::mem::size_of::<Bar>() , 16usize , 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 ) ) . baz1 as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Bar ) , "::" , - stringify ! ( baz1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Bar ) ) . baz2 as * const _ as usize } , - 8usize , concat ! ( - "Alignment of field: " , stringify ! ( Bar ) , "::" , - stringify ! ( baz2 ) )); + assert_eq!( + ::std::mem::size_of::<Bar>(), + 16usize, + 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)).baz1 as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Bar), + "::", + stringify!(baz1) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Bar)).baz2 as *const _ as usize }, + 8usize, + concat!( + "Alignment of field: ", + stringify!(Bar), + "::", + stringify!(baz2) + ) + ); } impl Clone for Bar { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for Bar { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/constify-module-enums-types.rs b/tests/expectations/tests/constify-module-enums-types.rs index 0c25780b..2d516fe4 100644 --- a/tests/expectations/tests/constify-module-enums-types.rs +++ b/tests/expectations/tests/constify-module-enums-types.rs @@ -52,66 +52,126 @@ pub struct bar { } #[test] fn bindgen_test_layout_bar() { - assert_eq!(::std::mem::size_of::<bar>() , 48usize , 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 ) ) . member1 as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( bar ) , "::" , - stringify ! ( member1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const bar ) ) . member2 as * const _ as usize } - , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( bar ) , "::" , - stringify ! ( member2 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const bar ) ) . member3 as * const _ as usize } - , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( bar ) , "::" , - stringify ! ( member3 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const bar ) ) . member4 as * const _ as usize } - , 12usize , concat ! ( - "Alignment of field: " , stringify ! ( bar ) , "::" , - stringify ! ( member4 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const bar ) ) . member5 as * const _ as usize } - , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( bar ) , "::" , - stringify ! ( member5 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const bar ) ) . member6 as * const _ as usize } - , 24usize , concat ! ( - "Alignment of field: " , stringify ! ( bar ) , "::" , - stringify ! ( member6 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const bar ) ) . member7 as * const _ as usize } - , 32usize , concat ! ( - "Alignment of field: " , stringify ! ( bar ) , "::" , - stringify ! ( member7 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const bar ) ) . member8 as * const _ as usize } - , 36usize , concat ! ( - "Alignment of field: " , stringify ! ( bar ) , "::" , - stringify ! ( member8 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const bar ) ) . member9 as * const _ as usize } - , 40usize , concat ! ( - "Alignment of field: " , stringify ! ( bar ) , "::" , - stringify ! ( member9 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const bar ) ) . member10 as * const _ as usize - } , 44usize , concat ! ( - "Alignment of field: " , stringify ! ( bar ) , "::" , - stringify ! ( member10 ) )); + assert_eq!( + ::std::mem::size_of::<bar>(), + 48usize, + 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)).member1 as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(bar), + "::", + stringify!(member1) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const bar)).member2 as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(bar), + "::", + stringify!(member2) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const bar)).member3 as *const _ as usize }, + 8usize, + concat!( + "Alignment of field: ", + stringify!(bar), + "::", + stringify!(member3) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const bar)).member4 as *const _ as usize }, + 12usize, + concat!( + "Alignment of field: ", + stringify!(bar), + "::", + stringify!(member4) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const bar)).member5 as *const _ as usize }, + 16usize, + concat!( + "Alignment of field: ", + stringify!(bar), + "::", + stringify!(member5) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const bar)).member6 as *const _ as usize }, + 24usize, + concat!( + "Alignment of field: ", + stringify!(bar), + "::", + stringify!(member6) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const bar)).member7 as *const _ as usize }, + 32usize, + concat!( + "Alignment of field: ", + stringify!(bar), + "::", + stringify!(member7) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const bar)).member8 as *const _ as usize }, + 36usize, + concat!( + "Alignment of field: ", + stringify!(bar), + "::", + stringify!(member8) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const bar)).member9 as *const _ as usize }, + 40usize, + concat!( + "Alignment of field: ", + stringify!(bar), + "::", + stringify!(member9) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const bar)).member10 as *const _ as usize }, + 44usize, + concat!( + "Alignment of field: ", + stringify!(bar), + "::", + stringify!(member10) + ) + ); } impl Clone for bar { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for bar { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Copy)] @@ -120,21 +180,36 @@ pub struct Baz { } #[test] fn bindgen_test_layout_Baz() { - assert_eq!(::std::mem::size_of::<Baz>() , 4usize , concat ! ( - "Size of: " , stringify ! ( Baz ) )); - assert_eq! (::std::mem::align_of::<Baz>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Baz ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Baz ) ) . member1 as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Baz ) , "::" , - stringify ! ( member1 ) )); + assert_eq!( + ::std::mem::size_of::<Baz>(), + 4usize, + concat!("Size of: ", stringify!(Baz)) + ); + assert_eq!( + ::std::mem::align_of::<Baz>(), + 4usize, + concat!("Alignment of ", stringify!(Baz)) + ); + assert_eq!( + unsafe { &(*(0 as *const Baz)).member1 as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Baz), + "::", + stringify!(member1) + ) + ); } impl Clone for Baz { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for Baz { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } pub mod one_Foo { pub type Type = ::std::os::raw::c_int; @@ -148,31 +223,52 @@ pub struct Bar { } #[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 ) ) . baz as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Bar ) , "::" , - stringify ! ( baz ) )); + 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)).baz as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Bar), + "::", + stringify!(baz) + ) + ); } impl Clone for Bar { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for Bar { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } extern "C" { #[link_name = "\u{1}_Z5func13fooPS_PS0_"] - pub fn func1(arg1: foo::Type, arg2: *mut foo::Type, - arg3: *mut *mut foo::Type) -> *mut foo::Type; + pub fn func1( + arg1: foo::Type, + arg2: *mut foo::Type, + arg3: *mut *mut foo::Type, + ) -> *mut foo::Type; } extern "C" { #[link_name = "\u{1}_Z5func23fooPS_PS0_"] - pub fn func2(arg1: foo_alias1, arg2: *mut foo_alias1, - arg3: *mut *mut foo_alias1) -> *mut foo_alias1; + pub fn func2( + arg1: foo_alias1, + arg2: *mut foo_alias1, + arg3: *mut *mut foo_alias1, + ) -> *mut foo_alias1; } #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -180,8 +276,10 @@ pub struct Thing<T> { pub thing: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } -impl <T> Default for Thing<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for Thing<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } extern "C" { #[link_name = "\u{1}_Z5func35ThingI3fooE"] diff --git a/tests/expectations/tests/constructor-tp.rs b/tests/expectations/tests/constructor-tp.rs index 534f70e3..081abf89 100644 --- a/tests/expectations/tests/constructor-tp.rs +++ b/tests/expectations/tests/constructor-tp.rs @@ -16,17 +16,25 @@ pub struct Bar { } #[test] fn bindgen_test_layout_Bar() { - assert_eq!(::std::mem::size_of::<Bar>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::<Bar>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Bar ) )); + assert_eq!( + ::std::mem::size_of::<Bar>(), + 1usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::<Bar>(), + 1usize, + concat!("Alignment of ", stringify!(Bar)) + ); } extern "C" { #[link_name = "\u{1}_ZN3BarC1Ev"] pub fn Bar_Bar(this: *mut Bar); } impl Clone for Bar { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Bar { #[inline] diff --git a/tests/expectations/tests/constructors.rs b/tests/expectations/tests/constructors.rs index bb0d294a..8d0c8c2d 100644 --- a/tests/expectations/tests/constructors.rs +++ b/tests/expectations/tests/constructors.rs @@ -11,22 +11,29 @@ pub struct TestOverload { } #[test] fn bindgen_test_layout_TestOverload() { - assert_eq!(::std::mem::size_of::<TestOverload>() , 1usize , concat ! ( - "Size of: " , stringify ! ( TestOverload ) )); - assert_eq! (::std::mem::align_of::<TestOverload>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( TestOverload ) )); + assert_eq!( + ::std::mem::size_of::<TestOverload>(), + 1usize, + concat!("Size of: ", stringify!(TestOverload)) + ); + assert_eq!( + ::std::mem::align_of::<TestOverload>(), + 1usize, + concat!("Alignment of ", stringify!(TestOverload)) + ); } extern "C" { #[link_name = "\u{1}_ZN12TestOverloadC1Ei"] - pub fn TestOverload_TestOverload(this: *mut TestOverload, - arg1: ::std::os::raw::c_int); + pub fn TestOverload_TestOverload(this: *mut TestOverload, arg1: ::std::os::raw::c_int); } extern "C" { #[link_name = "\u{1}_ZN12TestOverloadC1Ed"] pub fn TestOverload_TestOverload1(this: *mut TestOverload, arg1: f64); } impl Clone for TestOverload { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl TestOverload { #[inline] @@ -49,17 +56,25 @@ pub struct TestPublicNoArgs { } #[test] fn bindgen_test_layout_TestPublicNoArgs() { - assert_eq!(::std::mem::size_of::<TestPublicNoArgs>() , 1usize , concat ! ( - "Size of: " , stringify ! ( TestPublicNoArgs ) )); - assert_eq! (::std::mem::align_of::<TestPublicNoArgs>() , 1usize , concat ! - ( "Alignment of " , stringify ! ( TestPublicNoArgs ) )); + assert_eq!( + ::std::mem::size_of::<TestPublicNoArgs>(), + 1usize, + concat!("Size of: ", stringify!(TestPublicNoArgs)) + ); + assert_eq!( + ::std::mem::align_of::<TestPublicNoArgs>(), + 1usize, + concat!("Alignment of ", stringify!(TestPublicNoArgs)) + ); } extern "C" { #[link_name = "\u{1}_ZN16TestPublicNoArgsC1Ev"] pub fn TestPublicNoArgs_TestPublicNoArgs(this: *mut TestPublicNoArgs); } impl Clone for TestPublicNoArgs { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl TestPublicNoArgs { #[inline] diff --git a/tests/expectations/tests/convert-cpp-comment-to-rust.rs b/tests/expectations/tests/convert-cpp-comment-to-rust.rs index 08570f16..325682d1 100644 --- a/tests/expectations/tests/convert-cpp-comment-to-rust.rs +++ b/tests/expectations/tests/convert-cpp-comment-to-rust.rs @@ -18,29 +18,54 @@ pub struct mbedtls_mpi { } #[test] fn bindgen_test_layout_mbedtls_mpi() { - assert_eq!(::std::mem::size_of::<mbedtls_mpi>() , 24usize , concat ! ( - "Size of: " , stringify ! ( mbedtls_mpi ) )); - assert_eq! (::std::mem::align_of::<mbedtls_mpi>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( mbedtls_mpi ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const mbedtls_mpi ) ) . s as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( mbedtls_mpi ) , "::" , - stringify ! ( s ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const mbedtls_mpi ) ) . n as * const _ as usize - } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( mbedtls_mpi ) , "::" , - stringify ! ( n ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const mbedtls_mpi ) ) . p as * const _ as usize - } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( mbedtls_mpi ) , "::" , - stringify ! ( p ) )); + assert_eq!( + ::std::mem::size_of::<mbedtls_mpi>(), + 24usize, + concat!("Size of: ", stringify!(mbedtls_mpi)) + ); + assert_eq!( + ::std::mem::align_of::<mbedtls_mpi>(), + 8usize, + concat!("Alignment of ", stringify!(mbedtls_mpi)) + ); + assert_eq!( + unsafe { &(*(0 as *const mbedtls_mpi)).s as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(mbedtls_mpi), + "::", + stringify!(s) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const mbedtls_mpi)).n as *const _ as usize }, + 8usize, + concat!( + "Alignment of field: ", + stringify!(mbedtls_mpi), + "::", + stringify!(n) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const mbedtls_mpi)).p as *const _ as usize }, + 16usize, + concat!( + "Alignment of field: ", + stringify!(mbedtls_mpi), + "::", + stringify!(p) + ) + ); } impl Clone for mbedtls_mpi { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for mbedtls_mpi { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/convert-floats.rs b/tests/expectations/tests/convert-floats.rs index 906da262..8d6f3b92 100644 --- a/tests/expectations/tests/convert-floats.rs +++ b/tests/expectations/tests/convert-floats.rs @@ -22,44 +22,84 @@ pub struct foo { } #[test] fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::<foo>() , 48usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::<foo>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bar ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . baz as * const _ as usize } , - 4usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( baz ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bazz as * const _ as usize } , - 8usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bazz ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bazzz as * const _ as usize } , - 16usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bazzz ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . complexFloat as * const _ as - usize } , 24usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( complexFloat ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . complexDouble as * const _ as - usize } , 32usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( complexDouble ) )); + assert_eq!( + ::std::mem::size_of::<foo>(), + 48usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::<foo>(), + 8usize, + concat!("Alignment of ", stringify!(foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).bar as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo), + "::", + stringify!(bar) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).baz as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(foo), + "::", + stringify!(baz) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).bazz as *const _ as usize }, + 8usize, + concat!( + "Alignment of field: ", + stringify!(foo), + "::", + stringify!(bazz) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).bazzz as *const _ as usize }, + 16usize, + concat!( + "Alignment of field: ", + stringify!(foo), + "::", + stringify!(bazzz) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).complexFloat as *const _ as usize }, + 24usize, + concat!( + "Alignment of field: ", + stringify!(foo), + "::", + stringify!(complexFloat) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).complexDouble as *const _ as usize }, + 32usize, + concat!( + "Alignment of field: ", + stringify!(foo), + "::", + stringify!(complexDouble) + ) + ); } impl Clone for foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for foo { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/cpp-empty-layout.rs b/tests/expectations/tests/cpp-empty-layout.rs index c894b95c..f84a7005 100644 --- a/tests/expectations/tests/cpp-empty-layout.rs +++ b/tests/expectations/tests/cpp-empty-layout.rs @@ -11,11 +11,19 @@ pub struct Foo { } #[test] fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::<Foo>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::<Foo>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::<Foo>(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::<Foo>(), + 1usize, + concat!("Alignment of ", stringify!(Foo)) + ); } impl Clone for Foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/crtp.rs b/tests/expectations/tests/crtp.rs index f2b1dbd8..eb560b3b 100644 --- a/tests/expectations/tests/crtp.rs +++ b/tests/expectations/tests/crtp.rs @@ -16,13 +16,21 @@ pub struct Derived { } #[test] fn bindgen_test_layout_Derived() { - assert_eq!(::std::mem::size_of::<Derived>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Derived ) )); - assert_eq! (::std::mem::align_of::<Derived>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Derived ) )); + assert_eq!( + ::std::mem::size_of::<Derived>(), + 1usize, + concat!("Size of: ", stringify!(Derived)) + ); + assert_eq!( + ::std::mem::align_of::<Derived>(), + 1usize, + concat!("Alignment of ", stringify!(Derived)) + ); } impl Clone for Derived { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default)] @@ -36,30 +44,47 @@ pub struct DerivedFromBaseWithDestructor { } #[test] fn bindgen_test_layout_DerivedFromBaseWithDestructor() { - assert_eq!(::std::mem::size_of::<DerivedFromBaseWithDestructor>() , 1usize - , concat ! ( - "Size of: " , stringify ! ( DerivedFromBaseWithDestructor ) )); - assert_eq! (::std::mem::align_of::<DerivedFromBaseWithDestructor>() , - 1usize , concat ! ( - "Alignment of " , stringify ! ( DerivedFromBaseWithDestructor - ) )); + assert_eq!( + ::std::mem::size_of::<DerivedFromBaseWithDestructor>(), + 1usize, + concat!("Size of: ", stringify!(DerivedFromBaseWithDestructor)) + ); + assert_eq!( + ::std::mem::align_of::<DerivedFromBaseWithDestructor>(), + 1usize, + concat!("Alignment of ", stringify!(DerivedFromBaseWithDestructor)) + ); } #[test] fn __bindgen_test_layout_Base_open0_Derived_close0_instantiation() { - assert_eq!(::std::mem::size_of::<Base>() , 1usize , concat ! ( - "Size of template specialization: " , stringify ! ( Base ) )); - assert_eq!(::std::mem::align_of::<Base>() , 1usize , concat ! ( - "Alignment of template specialization: " , stringify ! ( Base ) - )); + assert_eq!( + ::std::mem::size_of::<Base>(), + 1usize, + concat!("Size of template specialization: ", stringify!(Base)) + ); + assert_eq!( + ::std::mem::align_of::<Base>(), + 1usize, + concat!("Alignment of template specialization: ", stringify!(Base)) + ); } #[test] -fn __bindgen_test_layout_BaseWithDestructor_open0_DerivedFromBaseWithDestructor_close0_instantiation() { - assert_eq!(::std::mem::size_of::<BaseWithDestructor>() , 1usize , concat ! - ( - "Size of template specialization: " , stringify ! ( - BaseWithDestructor ) )); - assert_eq!(::std::mem::align_of::<BaseWithDestructor>() , 1usize , concat - ! ( - "Alignment of template specialization: " , stringify ! ( - BaseWithDestructor ) )); +fn __bindgen_test_layout_BaseWithDestructor_open0_DerivedFromBaseWithDestructor_close0_instantiation( +) { + assert_eq!( + ::std::mem::size_of::<BaseWithDestructor>(), + 1usize, + concat!( + "Size of template specialization: ", + stringify!(BaseWithDestructor) + ) + ); + assert_eq!( + ::std::mem::align_of::<BaseWithDestructor>(), + 1usize, + concat!( + "Alignment of template specialization: ", + stringify!(BaseWithDestructor) + ) + ); } diff --git a/tests/expectations/tests/derive-debug-function-pointer.rs b/tests/expectations/tests/derive-debug-function-pointer.rs index 03cafe97..5c929909 100644 --- a/tests/expectations/tests/derive-debug-function-pointer.rs +++ b/tests/expectations/tests/derive-debug-function-pointer.rs @@ -10,38 +10,61 @@ pub struct Nice { pub pointer: Nice_Function, pub large_array: [::std::os::raw::c_int; 34usize], } -pub type Nice_Function = - ::std::option::Option<unsafe extern "C" fn(data: ::std::os::raw::c_int)>; +pub type Nice_Function = ::std::option::Option<unsafe extern "C" fn(data: ::std::os::raw::c_int)>; #[test] fn bindgen_test_layout_Nice() { - assert_eq!(::std::mem::size_of::<Nice>() , 144usize , concat ! ( - "Size of: " , stringify ! ( Nice ) )); - assert_eq! (::std::mem::align_of::<Nice>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( Nice ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Nice ) ) . pointer as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Nice ) , "::" , - stringify ! ( pointer ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Nice ) ) . large_array as * const _ as - usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( Nice ) , "::" , - stringify ! ( large_array ) )); + assert_eq!( + ::std::mem::size_of::<Nice>(), + 144usize, + concat!("Size of: ", stringify!(Nice)) + ); + assert_eq!( + ::std::mem::align_of::<Nice>(), + 8usize, + concat!("Alignment of ", stringify!(Nice)) + ); + assert_eq!( + unsafe { &(*(0 as *const Nice)).pointer as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Nice), + "::", + stringify!(pointer) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Nice)).large_array as *const _ as usize }, + 8usize, + concat!( + "Alignment of field: ", + stringify!(Nice), + "::", + stringify!(large_array) + ) + ); } impl Clone for Nice { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for Nice { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } impl ::std::fmt::Debug for Nice { fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - write!(f , "Nice {{ pointer: {:?}, large_array: [{}] }}" , self . - pointer , self . large_array . iter ( ) . enumerate ( ) . map - ( - | ( i , v ) | format ! ( - "{}{:?}" , if i > 0 { ", " } else { "" } , v ) ) . collect :: < - String > ( )) + write!( + f, + "Nice {{ pointer: {:?}, large_array: [{}] }}", + self.pointer, + self.large_array + .iter() + .enumerate() + .map(|(i, v)| format!("{}{:?}", if i > 0 { ", " } else { "" }, v)) + .collect::<String>() + ) } } diff --git a/tests/expectations/tests/derive-debug-opaque-template-instantiation.rs b/tests/expectations/tests/derive-debug-opaque-template-instantiation.rs index e5529255..5bc6e20d 100644 --- a/tests/expectations/tests/derive-debug-opaque-template-instantiation.rs +++ b/tests/expectations/tests/derive-debug-opaque-template-instantiation.rs @@ -10,21 +10,34 @@ pub struct Instance { } #[test] fn bindgen_test_layout_Instance() { - assert_eq!(::std::mem::size_of::<Instance>() , 200usize , concat ! ( - "Size of: " , stringify ! ( Instance ) )); - assert_eq! (::std::mem::align_of::<Instance>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Instance ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Instance ) ) . val as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Instance ) , "::" , - stringify ! ( val ) )); + assert_eq!( + ::std::mem::size_of::<Instance>(), + 200usize, + concat!("Size of: ", stringify!(Instance)) + ); + assert_eq!( + ::std::mem::align_of::<Instance>(), + 4usize, + concat!("Alignment of ", stringify!(Instance)) + ); + assert_eq!( + unsafe { &(*(0 as *const Instance)).val as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Instance), + "::", + stringify!(val) + ) + ); } impl Default for Instance { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } impl ::std::fmt::Debug for Instance { fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - write!(f , "Instance {{ val: opaque }}") + write!(f, "Instance {{ val: opaque }}") } } diff --git a/tests/expectations/tests/derive-debug-opaque.rs b/tests/expectations/tests/derive-debug-opaque.rs index 267aca11..29c1d791 100644 --- a/tests/expectations/tests/derive-debug-opaque.rs +++ b/tests/expectations/tests/derive-debug-opaque.rs @@ -10,17 +10,25 @@ pub struct Opaque { } #[test] fn bindgen_test_layout_Opaque() { - assert_eq!(::std::mem::size_of::<Opaque>() , 164usize , concat ! ( - "Size of: " , stringify ! ( Opaque ) )); - assert_eq! (::std::mem::align_of::<Opaque>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Opaque ) )); + assert_eq!( + ::std::mem::size_of::<Opaque>(), + 164usize, + concat!("Size of: ", stringify!(Opaque)) + ); + assert_eq!( + ::std::mem::align_of::<Opaque>(), + 4usize, + concat!("Alignment of ", stringify!(Opaque)) + ); } impl Default for Opaque { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } impl ::std::fmt::Debug for Opaque { fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - write!(f , "Opaque {{ opaque }}") + write!(f, "Opaque {{ opaque }}") } } #[repr(C)] @@ -29,21 +37,34 @@ pub struct OpaqueUser { } #[test] fn bindgen_test_layout_OpaqueUser() { - assert_eq!(::std::mem::size_of::<OpaqueUser>() , 164usize , concat ! ( - "Size of: " , stringify ! ( OpaqueUser ) )); - assert_eq! (::std::mem::align_of::<OpaqueUser>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( OpaqueUser ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const OpaqueUser ) ) . opaque as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( OpaqueUser ) , "::" , - stringify ! ( opaque ) )); + assert_eq!( + ::std::mem::size_of::<OpaqueUser>(), + 164usize, + concat!("Size of: ", stringify!(OpaqueUser)) + ); + assert_eq!( + ::std::mem::align_of::<OpaqueUser>(), + 4usize, + concat!("Alignment of ", stringify!(OpaqueUser)) + ); + assert_eq!( + unsafe { &(*(0 as *const OpaqueUser)).opaque as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(OpaqueUser), + "::", + stringify!(opaque) + ) + ); } impl Default for OpaqueUser { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } impl ::std::fmt::Debug for OpaqueUser { fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - write!(f , "OpaqueUser {{ opaque: {:?} }}" , self . opaque) + write!(f, "OpaqueUser {{ opaque: {:?} }}", self.opaque) } } diff --git a/tests/expectations/tests/derive-fn-ptr.rs b/tests/expectations/tests/derive-fn-ptr.rs index ac479296..096a67d5 100644 --- a/tests/expectations/tests/derive-fn-ptr.rs +++ b/tests/expectations/tests/derive-fn-ptr.rs @@ -4,23 +4,26 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -pub type my_fun_t = - ::std::option::Option<unsafe extern "C" fn(arg1: ::std::os::raw::c_int, - arg2: ::std::os::raw::c_int, - arg3: ::std::os::raw::c_int, - arg4: ::std::os::raw::c_int, - arg5: ::std::os::raw::c_int, - arg6: ::std::os::raw::c_int, - arg7: ::std::os::raw::c_int, - arg8: ::std::os::raw::c_int, - arg9: ::std::os::raw::c_int, - arg10: ::std::os::raw::c_int, - arg11: ::std::os::raw::c_int, - arg12: ::std::os::raw::c_int, - arg13: ::std::os::raw::c_int, - arg14: ::std::os::raw::c_int, - arg15: ::std::os::raw::c_int, - arg16: ::std::os::raw::c_int)>; +pub type my_fun_t = ::std::option::Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: ::std::os::raw::c_int, + arg6: ::std::os::raw::c_int, + arg7: ::std::os::raw::c_int, + arg8: ::std::os::raw::c_int, + arg9: ::std::os::raw::c_int, + arg10: ::std::os::raw::c_int, + arg11: ::std::os::raw::c_int, + arg12: ::std::os::raw::c_int, + arg13: ::std::os::raw::c_int, + arg14: ::std::os::raw::c_int, + arg15: ::std::os::raw::c_int, + arg16: ::std::os::raw::c_int, + ), +>; #[repr(C)] #[derive(Copy)] pub struct Foo { @@ -28,35 +31,53 @@ pub struct Foo { } #[test] fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::<Foo>() , 8usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::<Foo>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Foo ) ) . callback as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Foo ) , "::" , - stringify ! ( callback ) )); + assert_eq!( + ::std::mem::size_of::<Foo>(), + 8usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::<Foo>(), + 8usize, + concat!("Alignment of ", stringify!(Foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const Foo)).callback as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Foo), + "::", + stringify!(callback) + ) + ); } impl Clone for Foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for Foo { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } -pub type my_fun2_t = - ::std::option::Option<unsafe extern "C" fn(arg1: ::std::os::raw::c_int, - arg2: ::std::os::raw::c_int, - arg3: ::std::os::raw::c_int, - arg4: ::std::os::raw::c_int, - arg5: ::std::os::raw::c_int, - arg6: ::std::os::raw::c_int, - arg7: ::std::os::raw::c_int, - arg8: ::std::os::raw::c_int, - arg9: ::std::os::raw::c_int, - arg10: ::std::os::raw::c_int, - arg11: ::std::os::raw::c_int, - arg12: ::std::os::raw::c_int)>; +pub type my_fun2_t = ::std::option::Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: ::std::os::raw::c_int, + arg6: ::std::os::raw::c_int, + arg7: ::std::os::raw::c_int, + arg8: ::std::os::raw::c_int, + arg9: ::std::os::raw::c_int, + arg10: ::std::os::raw::c_int, + arg11: ::std::os::raw::c_int, + arg12: ::std::os::raw::c_int, + ), +>; #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct Bar { @@ -64,19 +85,34 @@ pub struct Bar { } #[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 ) ) . callback as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Bar ) , "::" , - stringify ! ( callback ) )); + 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)).callback as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Bar), + "::", + stringify!(callback) + ) + ); } impl Clone for Bar { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for Bar { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/do-not-derive-copy.rs b/tests/expectations/tests/do-not-derive-copy.rs index 114b73e3..98307774 100644 --- a/tests/expectations/tests/do-not-derive-copy.rs +++ b/tests/expectations/tests/do-not-derive-copy.rs @@ -11,18 +11,27 @@ pub struct WouldBeCopyButWeAreNotDerivingCopy { } #[test] fn bindgen_test_layout_WouldBeCopyButWeAreNotDerivingCopy() { - assert_eq!(::std::mem::size_of::<WouldBeCopyButWeAreNotDerivingCopy>() , - 4usize , concat ! ( - "Size of: " , stringify ! ( WouldBeCopyButWeAreNotDerivingCopy - ) )); - assert_eq! (::std::mem::align_of::<WouldBeCopyButWeAreNotDerivingCopy>() , - 4usize , concat ! ( - "Alignment of " , stringify ! ( - WouldBeCopyButWeAreNotDerivingCopy ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WouldBeCopyButWeAreNotDerivingCopy ) ) . - x as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - WouldBeCopyButWeAreNotDerivingCopy ) , "::" , stringify ! ( x - ) )); + assert_eq!( + ::std::mem::size_of::<WouldBeCopyButWeAreNotDerivingCopy>(), + 4usize, + concat!("Size of: ", stringify!(WouldBeCopyButWeAreNotDerivingCopy)) + ); + assert_eq!( + ::std::mem::align_of::<WouldBeCopyButWeAreNotDerivingCopy>(), + 4usize, + concat!( + "Alignment of ", + stringify!(WouldBeCopyButWeAreNotDerivingCopy) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const WouldBeCopyButWeAreNotDerivingCopy)).x as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(WouldBeCopyButWeAreNotDerivingCopy), + "::", + stringify!(x) + ) + ); } diff --git a/tests/expectations/tests/doggo-or-null.rs b/tests/expectations/tests/doggo-or-null.rs index 292533d9..002e4475 100644 --- a/tests/expectations/tests/doggo-or-null.rs +++ b/tests/expectations/tests/doggo-or-null.rs @@ -11,18 +11,31 @@ pub struct Doggo { } #[test] fn bindgen_test_layout_Doggo() { - assert_eq!(::std::mem::size_of::<Doggo>() , 4usize , concat ! ( - "Size of: " , stringify ! ( Doggo ) )); - assert_eq! (::std::mem::align_of::<Doggo>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Doggo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Doggo ) ) . x as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Doggo ) , "::" , - stringify ! ( x ) )); + assert_eq!( + ::std::mem::size_of::<Doggo>(), + 4usize, + concat!("Size of: ", stringify!(Doggo)) + ); + assert_eq!( + ::std::mem::align_of::<Doggo>(), + 4usize, + concat!("Alignment of ", stringify!(Doggo)) + ); + assert_eq!( + unsafe { &(*(0 as *const Doggo)).x as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Doggo), + "::", + stringify!(x) + ) + ); } impl Clone for Doggo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq)] @@ -31,13 +44,21 @@ pub struct Null { } #[test] fn bindgen_test_layout_Null() { - assert_eq!(::std::mem::size_of::<Null>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Null ) )); - assert_eq! (::std::mem::align_of::<Null>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Null ) )); + assert_eq!( + ::std::mem::size_of::<Null>(), + 1usize, + concat!("Size of: ", stringify!(Null)) + ); + assert_eq!( + ::std::mem::align_of::<Null>(), + 1usize, + concat!("Alignment of ", stringify!(Null)) + ); } impl Clone for Null { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } /// This type is an opaque union. Unions can't derive anything interesting like /// Debug or Default, even if their layout can, because it would require knowing @@ -52,14 +73,24 @@ pub union DoggoOrNull { } #[test] fn bindgen_test_layout_DoggoOrNull() { - assert_eq!(::std::mem::size_of::<DoggoOrNull>() , 4usize , concat ! ( - "Size of: " , stringify ! ( DoggoOrNull ) )); - assert_eq! (::std::mem::align_of::<DoggoOrNull>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( DoggoOrNull ) )); + assert_eq!( + ::std::mem::size_of::<DoggoOrNull>(), + 4usize, + concat!("Size of: ", stringify!(DoggoOrNull)) + ); + assert_eq!( + ::std::mem::align_of::<DoggoOrNull>(), + 4usize, + concat!("Alignment of ", stringify!(DoggoOrNull)) + ); } impl Clone for DoggoOrNull { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for DoggoOrNull { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/duplicated-namespaces-definitions.rs b/tests/expectations/tests/duplicated-namespaces-definitions.rs index 67ca77d6..d907a19c 100644 --- a/tests/expectations/tests/duplicated-namespaces-definitions.rs +++ b/tests/expectations/tests/duplicated-namespaces-definitions.rs @@ -19,23 +19,41 @@ pub mod root { } #[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>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Bar ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Bar ) ) . foo as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Bar ) , "::" , - stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Bar ) ) . baz as * const _ as - usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( Bar ) , "::" , - stringify ! ( baz ) )); + assert_eq!( + ::std::mem::size_of::<Bar>(), + 8usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::<Bar>(), + 4usize, + concat!("Alignment of ", stringify!(Bar)) + ); + assert_eq!( + unsafe { &(*(0 as *const Bar)).foo as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Bar), + "::", + stringify!(foo) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Bar)).baz as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(Bar), + "::", + stringify!(baz) + ) + ); } impl Clone for Bar { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } } pub mod bar { @@ -48,21 +66,36 @@ pub mod root { } #[test] fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::<Foo>() , 8usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::<Foo>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Foo ) ) . ptr as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Foo ) , "::" , - stringify ! ( ptr ) )); + assert_eq!( + ::std::mem::size_of::<Foo>(), + 8usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::<Foo>(), + 8usize, + concat!("Alignment of ", stringify!(Foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const Foo)).ptr as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Foo), + "::", + stringify!(ptr) + ) + ); } impl Clone for Foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for Foo { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } } } diff --git a/tests/expectations/tests/enum.rs b/tests/expectations/tests/enum.rs index 9eafbbd2..70c30830 100644 --- a/tests/expectations/tests/enum.rs +++ b/tests/expectations/tests/enum.rs @@ -6,7 +6,13 @@ #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Foo { Bar = 0, Qux = 1, } +pub enum Foo { + Bar = 0, + Qux = 1, +} #[repr(i32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Neg { MinusOne = -1, One = 1, } +pub enum Neg { + MinusOne = -1, + One = 1, +} diff --git a/tests/expectations/tests/enum_alias.rs b/tests/expectations/tests/enum_alias.rs index c77bf11d..f12c08d3 100644 --- a/tests/expectations/tests/enum_alias.rs +++ b/tests/expectations/tests/enum_alias.rs @@ -6,4 +6,6 @@ #[repr(u8)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Bar { VAL = 0, } +pub enum Bar { + VAL = 0, +} diff --git a/tests/expectations/tests/enum_and_vtable_mangling.rs b/tests/expectations/tests/enum_and_vtable_mangling.rs index b3e49f4f..d6b41610 100644 --- a/tests/expectations/tests/enum_and_vtable_mangling.rs +++ b/tests/expectations/tests/enum_and_vtable_mangling.rs @@ -8,7 +8,10 @@ pub const match_: _bindgen_ty_1 = _bindgen_ty_1::match_; pub const whatever_else: _bindgen_ty_1 = _bindgen_ty_1::whatever_else; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum _bindgen_ty_1 { match_ = 0, whatever_else = 1, } +pub enum _bindgen_ty_1 { + match_ = 0, + whatever_else = 1, +} #[repr(C)] pub struct C__bindgen_vtable(::std::os::raw::c_void); #[repr(C)] @@ -19,20 +22,31 @@ pub struct C { } #[test] fn bindgen_test_layout_C() { - assert_eq!(::std::mem::size_of::<C>() , 16usize , concat ! ( - "Size of: " , stringify ! ( C ) )); - assert_eq! (::std::mem::align_of::<C>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( C ) )); - assert_eq! (unsafe { & ( * ( 0 as * const C ) ) . i as * const _ as usize - } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( i ) )); + assert_eq!( + ::std::mem::size_of::<C>(), + 16usize, + concat!("Size of: ", stringify!(C)) + ); + assert_eq!( + ::std::mem::align_of::<C>(), + 8usize, + concat!("Alignment of ", stringify!(C)) + ); + assert_eq!( + unsafe { &(*(0 as *const C)).i as *const _ as usize }, + 8usize, + concat!("Alignment of field: ", stringify!(C), "::", stringify!(i)) + ); } 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() } + } } extern "C" { #[link_name = "\u{1}_ZN1C5matchEv"] diff --git a/tests/expectations/tests/enum_dupe.rs b/tests/expectations/tests/enum_dupe.rs index 5b6102c9..a91999ed 100644 --- a/tests/expectations/tests/enum_dupe.rs +++ b/tests/expectations/tests/enum_dupe.rs @@ -7,4 +7,6 @@ pub const Foo_Dupe: Foo = Foo::Bar; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Foo { Bar = 1, } +pub enum Foo { + Bar = 1, +} diff --git a/tests/expectations/tests/enum_explicit_type.rs b/tests/expectations/tests/enum_explicit_type.rs index 73fc23f5..7ff0ef51 100644 --- a/tests/expectations/tests/enum_explicit_type.rs +++ b/tests/expectations/tests/enum_explicit_type.rs @@ -6,19 +6,34 @@ #[repr(u8)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Foo { Bar = 0, Qux = 1, } +pub enum Foo { + Bar = 0, + Qux = 1, +} #[repr(i8)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Neg { MinusOne = -1, One = 1, } +pub enum Neg { + MinusOne = -1, + One = 1, +} #[repr(u16)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Bigger { Much = 255, Larger = 256, } +pub enum Bigger { + Much = 255, + Larger = 256, +} #[repr(i64)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum MuchLong { MuchLow = -4294967296, } +pub enum MuchLong { + MuchLow = -4294967296, +} #[repr(i64)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum MuchLongLong { I64_MIN = -9223372036854775808, } +pub enum MuchLongLong { + I64_MIN = -9223372036854775808, +} #[repr(u64)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum MuchULongLong { MuchHigh = 4294967296, } +pub enum MuchULongLong { + MuchHigh = 4294967296, +} diff --git a/tests/expectations/tests/enum_in_template_with_typedef.rs b/tests/expectations/tests/enum_in_template_with_typedef.rs index 8c819535..06dea126 100644 --- a/tests/expectations/tests/enum_in_template_with_typedef.rs +++ b/tests/expectations/tests/enum_in_template_with_typedef.rs @@ -14,4 +14,6 @@ pub const std_fbstring_core_Category_Bar: std_fbstring_core_Category = std_fbstring_core_Category::Foo; #[repr(u8)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum std_fbstring_core_Category { Foo = 0, } +pub enum std_fbstring_core_Category { + Foo = 0, +} diff --git a/tests/expectations/tests/enum_negative.rs b/tests/expectations/tests/enum_negative.rs index b47fdf09..100f27db 100644 --- a/tests/expectations/tests/enum_negative.rs +++ b/tests/expectations/tests/enum_negative.rs @@ -6,4 +6,7 @@ #[repr(i32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Foo { Bar = -2, Qux = 1, } +pub enum Foo { + Bar = -2, + Qux = 1, +} diff --git a/tests/expectations/tests/enum_packed.rs b/tests/expectations/tests/enum_packed.rs index 75b68ee1..cc85b553 100644 --- a/tests/expectations/tests/enum_packed.rs +++ b/tests/expectations/tests/enum_packed.rs @@ -6,10 +6,19 @@ #[repr(u8)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Foo { Bar = 0, Qux = 1, } +pub enum Foo { + Bar = 0, + Qux = 1, +} #[repr(i8)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Neg { MinusOne = -1, One = 1, } +pub enum Neg { + MinusOne = -1, + One = 1, +} #[repr(u16)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Bigger { Much = 255, Larger = 256, } +pub enum Bigger { + Much = 255, + Larger = 256, +} diff --git a/tests/expectations/tests/extern.rs b/tests/expectations/tests/extern.rs index 789ed438..e257b7bc 100644 --- a/tests/expectations/tests/extern.rs +++ b/tests/expectations/tests/extern.rs @@ -4,6 +4,7 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -pub type foo = - ::std::option::Option<unsafe extern "C" fn(bar: ::std::os::raw::c_int) - -> ::std::os::raw::c_int>; +pub type foo = ::std::option::Option< + unsafe extern "C" fn(bar: ::std::os::raw::c_int) + -> ::std::os::raw::c_int, +>; diff --git a/tests/expectations/tests/float128.rs b/tests/expectations/tests/float128.rs index 2ca90d40..5dcc6c40 100644 --- a/tests/expectations/tests/float128.rs +++ b/tests/expectations/tests/float128.rs @@ -2,6 +2,3 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - - diff --git a/tests/expectations/tests/forward-declaration-autoptr.rs b/tests/expectations/tests/forward-declaration-autoptr.rs index 6b078418..c5eeb88e 100644 --- a/tests/expectations/tests/forward-declaration-autoptr.rs +++ b/tests/expectations/tests/forward-declaration-autoptr.rs @@ -63,10 +63,14 @@ fn __bindgen_test_layout_RefPtr_open0_Foo_close0_instantiation() { assert_eq!( ::std::mem::size_of::<RefPtr<Foo>>(), 8usize, + concat!("Size of template specialization: ", stringify!(RefPtr<Foo>)) + ); + assert_eq!( + ::std::mem::align_of::<RefPtr<Foo>>(), + 8usize, concat!( - "Size of template specialization: ", - stringify ! ( RefPtr < Foo > ) + "Alignment of template specialization: ", + stringify!(RefPtr<Foo>) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < RefPtr < Foo > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( RefPtr < Foo > ) ) ); } diff --git a/tests/expectations/tests/forward-enum-decl.rs b/tests/expectations/tests/forward-enum-decl.rs index 8b705f2a..5502c4c4 100644 --- a/tests/expectations/tests/forward-enum-decl.rs +++ b/tests/expectations/tests/forward-enum-decl.rs @@ -6,4 +6,7 @@ #[repr(i32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum CSSPseudoClassType { empty = 0, link = 1, } +pub enum CSSPseudoClassType { + empty = 0, + link = 1, +} diff --git a/tests/expectations/tests/forward-inherit-struct-with-fields.rs b/tests/expectations/tests/forward-inherit-struct-with-fields.rs index 05c6d3ee..19772dbe 100644 --- a/tests/expectations/tests/forward-inherit-struct-with-fields.rs +++ b/tests/expectations/tests/forward-inherit-struct-with-fields.rs @@ -11,8 +11,10 @@ pub struct js_RootedBase<T> { pub next: *mut Rooted<T>, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } -impl <T> Default for js_RootedBase<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for js_RootedBase<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -20,6 +22,8 @@ pub struct Rooted<T> { pub _base: js_RootedBase<T>, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } -impl <T> Default for Rooted<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for Rooted<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/forward-inherit-struct.rs b/tests/expectations/tests/forward-inherit-struct.rs index e3f2b225..a2399bcb 100644 --- a/tests/expectations/tests/forward-inherit-struct.rs +++ b/tests/expectations/tests/forward-inherit-struct.rs @@ -15,5 +15,7 @@ pub struct Rooted { pub _address: u8, } impl Default for Rooted { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/forward_declared_complex_types.rs b/tests/expectations/tests/forward_declared_complex_types.rs index e02ba76c..a4eaa17c 100644 --- a/tests/expectations/tests/forward_declared_complex_types.rs +++ b/tests/expectations/tests/forward_declared_complex_types.rs @@ -11,13 +11,21 @@ pub struct Foo_empty { } #[test] fn bindgen_test_layout_Foo_empty() { - assert_eq!(::std::mem::size_of::<Foo_empty>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo_empty ) )); - assert_eq! (::std::mem::align_of::<Foo_empty>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo_empty ) )); + assert_eq!( + ::std::mem::size_of::<Foo_empty>(), + 1usize, + concat!("Size of: ", stringify!(Foo_empty)) + ); + assert_eq!( + ::std::mem::align_of::<Foo_empty>(), + 1usize, + concat!("Alignment of ", stringify!(Foo_empty)) + ); } impl Clone for Foo_empty { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -31,21 +39,31 @@ pub struct Bar { } #[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 ) ) . f as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Bar ) , "::" , - stringify ! ( f ) )); + 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)).f as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(Bar), "::", stringify!(f)) + ); } impl Clone for Bar { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for Bar { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } extern "C" { #[link_name = "\u{1}_Z10baz_structP3Foo"] diff --git a/tests/expectations/tests/forward_declared_complex_types_1_0.rs b/tests/expectations/tests/forward_declared_complex_types_1_0.rs index e02ba76c..a4eaa17c 100644 --- a/tests/expectations/tests/forward_declared_complex_types_1_0.rs +++ b/tests/expectations/tests/forward_declared_complex_types_1_0.rs @@ -11,13 +11,21 @@ pub struct Foo_empty { } #[test] fn bindgen_test_layout_Foo_empty() { - assert_eq!(::std::mem::size_of::<Foo_empty>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo_empty ) )); - assert_eq! (::std::mem::align_of::<Foo_empty>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo_empty ) )); + assert_eq!( + ::std::mem::size_of::<Foo_empty>(), + 1usize, + concat!("Size of: ", stringify!(Foo_empty)) + ); + assert_eq!( + ::std::mem::align_of::<Foo_empty>(), + 1usize, + concat!("Alignment of ", stringify!(Foo_empty)) + ); } impl Clone for Foo_empty { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -31,21 +39,31 @@ pub struct Bar { } #[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 ) ) . f as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Bar ) , "::" , - stringify ! ( f ) )); + 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)).f as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(Bar), "::", stringify!(f)) + ); } impl Clone for Bar { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for Bar { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } extern "C" { #[link_name = "\u{1}_Z10baz_structP3Foo"] diff --git a/tests/expectations/tests/forward_declared_struct.rs b/tests/expectations/tests/forward_declared_struct.rs index a0f0c137..4450e65d 100644 --- a/tests/expectations/tests/forward_declared_struct.rs +++ b/tests/expectations/tests/forward_declared_struct.rs @@ -11,17 +11,26 @@ pub struct a { } #[test] fn bindgen_test_layout_a() { - assert_eq!(::std::mem::size_of::<a>() , 4usize , concat ! ( - "Size of: " , stringify ! ( a ) )); - assert_eq! (::std::mem::align_of::<a>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( a ) )); - assert_eq! (unsafe { & ( * ( 0 as * const a ) ) . b as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( a ) , "::" , stringify - ! ( b ) )); + assert_eq!( + ::std::mem::size_of::<a>(), + 4usize, + concat!("Size of: ", stringify!(a)) + ); + assert_eq!( + ::std::mem::align_of::<a>(), + 4usize, + concat!("Alignment of ", stringify!(a)) + ); + assert_eq!( + unsafe { &(*(0 as *const a)).b as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(a), "::", stringify!(b)) + ); } impl Clone for a { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy)] @@ -30,15 +39,24 @@ pub struct c { } #[test] fn bindgen_test_layout_c() { - assert_eq!(::std::mem::size_of::<c>() , 4usize , 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 ) ) . d as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( c ) , "::" , stringify - ! ( d ) )); + assert_eq!( + ::std::mem::size_of::<c>(), + 4usize, + 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)).d as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(c), "::", stringify!(d)) + ); } impl Clone for c { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/func_proto.rs b/tests/expectations/tests/func_proto.rs index 789ed438..e257b7bc 100644 --- a/tests/expectations/tests/func_proto.rs +++ b/tests/expectations/tests/func_proto.rs @@ -4,6 +4,7 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -pub type foo = - ::std::option::Option<unsafe extern "C" fn(bar: ::std::os::raw::c_int) - -> ::std::os::raw::c_int>; +pub type foo = ::std::option::Option< + unsafe extern "C" fn(bar: ::std::os::raw::c_int) + -> ::std::os::raw::c_int, +>; diff --git a/tests/expectations/tests/func_ptr.rs b/tests/expectations/tests/func_ptr.rs index 79f27df2..730849c0 100644 --- a/tests/expectations/tests/func_ptr.rs +++ b/tests/expectations/tests/func_ptr.rs @@ -7,9 +7,8 @@ extern "C" { #[link_name = "\u{1}foo"] pub static mut foo: - ::std::option::Option<unsafe extern "C" fn(x: - ::std::os::raw::c_int, - y: - ::std::os::raw::c_int) - -> ::std::os::raw::c_int>; + ::std::option::Option< + unsafe extern "C" fn(x: ::std::os::raw::c_int, y: ::std::os::raw::c_int) + -> ::std::os::raw::c_int, + >; } diff --git a/tests/expectations/tests/func_ptr_in_struct.rs b/tests/expectations/tests/func_ptr_in_struct.rs index e3d1abff..55c75ff1 100644 --- a/tests/expectations/tests/func_ptr_in_struct.rs +++ b/tests/expectations/tests/func_ptr_in_struct.rs @@ -5,31 +5,44 @@ #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum baz { } +pub enum baz {} #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct Foo { - pub bar: ::std::option::Option<unsafe extern "C" fn(x: - ::std::os::raw::c_int, - y: - ::std::os::raw::c_int) - -> baz>, + pub bar: ::std::option::Option< + unsafe extern "C" fn(x: ::std::os::raw::c_int, y: ::std::os::raw::c_int) -> baz, + >, } #[test] fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::<Foo>() , 8usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::<Foo>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Foo ) , "::" , - stringify ! ( bar ) )); + assert_eq!( + ::std::mem::size_of::<Foo>(), + 8usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::<Foo>(), + 8usize, + concat!("Alignment of ", stringify!(Foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const Foo)).bar as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Foo), + "::", + stringify!(bar) + ) + ); } impl Clone for Foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for Foo { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/gen-constructors-neg.rs b/tests/expectations/tests/gen-constructors-neg.rs index c894b95c..f84a7005 100644 --- a/tests/expectations/tests/gen-constructors-neg.rs +++ b/tests/expectations/tests/gen-constructors-neg.rs @@ -11,11 +11,19 @@ pub struct Foo { } #[test] fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::<Foo>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::<Foo>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::<Foo>(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::<Foo>(), + 1usize, + concat!("Alignment of ", stringify!(Foo)) + ); } impl Clone for Foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/gen-destructors-neg.rs b/tests/expectations/tests/gen-destructors-neg.rs index 64373d75..0f75ce0b 100644 --- a/tests/expectations/tests/gen-destructors-neg.rs +++ b/tests/expectations/tests/gen-destructors-neg.rs @@ -11,13 +11,24 @@ pub struct Foo { } #[test] fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::<Foo>() , 4usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::<Foo>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Foo ) , "::" , - stringify ! ( bar ) )); + assert_eq!( + ::std::mem::size_of::<Foo>(), + 4usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::<Foo>(), + 4usize, + concat!("Alignment of ", stringify!(Foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const Foo)).bar as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Foo), + "::", + stringify!(bar) + ) + ); } diff --git a/tests/expectations/tests/gen-destructors.rs b/tests/expectations/tests/gen-destructors.rs index c13abf83..a7bf4028 100644 --- a/tests/expectations/tests/gen-destructors.rs +++ b/tests/expectations/tests/gen-destructors.rs @@ -11,15 +11,26 @@ pub struct Foo { } #[test] fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::<Foo>() , 4usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::<Foo>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Foo ) , "::" , - stringify ! ( bar ) )); + assert_eq!( + ::std::mem::size_of::<Foo>(), + 4usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::<Foo>(), + 4usize, + concat!("Alignment of ", stringify!(Foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const Foo)).bar as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Foo), + "::", + stringify!(bar) + ) + ); } extern "C" { #[link_name = "\u{1}_ZN3FooD1Ev"] @@ -27,5 +38,7 @@ extern "C" { } impl Foo { #[inline] - pub unsafe fn destruct(&mut self) { Foo_Foo_destructor(self) } + pub unsafe fn destruct(&mut self) { + Foo_Foo_destructor(self) + } } diff --git a/tests/expectations/tests/generate-inline.rs b/tests/expectations/tests/generate-inline.rs index f123acef..f4dafb45 100644 --- a/tests/expectations/tests/generate-inline.rs +++ b/tests/expectations/tests/generate-inline.rs @@ -11,21 +11,31 @@ pub struct Foo { } #[test] fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::<Foo>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::<Foo>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::<Foo>(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::<Foo>(), + 1usize, + concat!("Alignment of ", stringify!(Foo)) + ); } extern "C" { #[link_name = "\u{1}_ZN3Foo3barEv"] pub fn Foo_bar() -> ::std::os::raw::c_int; } impl Clone for Foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Foo { #[inline] - pub unsafe fn bar() -> ::std::os::raw::c_int { Foo_bar() } + pub unsafe fn bar() -> ::std::os::raw::c_int { + Foo_bar() + } } extern "C" { #[link_name = "\u{1}_Z3foov"] diff --git a/tests/expectations/tests/inherit-namespaced.rs b/tests/expectations/tests/inherit-namespaced.rs index e3f2b225..a2399bcb 100644 --- a/tests/expectations/tests/inherit-namespaced.rs +++ b/tests/expectations/tests/inherit-namespaced.rs @@ -15,5 +15,7 @@ pub struct Rooted { pub _address: u8, } impl Default for Rooted { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/inherit_named.rs b/tests/expectations/tests/inherit_named.rs index 0503804a..fadf270e 100644 --- a/tests/expectations/tests/inherit_named.rs +++ b/tests/expectations/tests/inherit_named.rs @@ -15,6 +15,8 @@ pub struct Weeee<T> { pub _base: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } -impl <T> Default for Weeee<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for Weeee<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/inherit_typedef.rs b/tests/expectations/tests/inherit_typedef.rs index 85af3e03..1c07e1df 100644 --- a/tests/expectations/tests/inherit_typedef.rs +++ b/tests/expectations/tests/inherit_typedef.rs @@ -11,13 +11,21 @@ pub struct Foo { } #[test] fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::<Foo>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::<Foo>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::<Foo>(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::<Foo>(), + 1usize, + concat!("Alignment of ", stringify!(Foo)) + ); } impl Clone for Foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } pub type TypedefedFoo = Foo; #[repr(C)] @@ -27,11 +35,19 @@ pub struct Bar { } #[test] fn bindgen_test_layout_Bar() { - assert_eq!(::std::mem::size_of::<Bar>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::<Bar>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Bar ) )); + assert_eq!( + ::std::mem::size_of::<Bar>(), + 1usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::<Bar>(), + 1usize, + concat!("Alignment of ", stringify!(Bar)) + ); } impl Clone for Bar { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/inline-function.rs b/tests/expectations/tests/inline-function.rs index 2ca90d40..5dcc6c40 100644 --- a/tests/expectations/tests/inline-function.rs +++ b/tests/expectations/tests/inline-function.rs @@ -2,6 +2,3 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - - diff --git a/tests/expectations/tests/inline_namespace.rs b/tests/expectations/tests/inline_namespace.rs index 13f3b8ee..b31bbe04 100644 --- a/tests/expectations/tests/inline_namespace.rs +++ b/tests/expectations/tests/inline_namespace.rs @@ -20,17 +20,30 @@ pub mod root { } #[test] fn bindgen_test_layout_Bar() { - assert_eq!(::std::mem::size_of::<Bar>() , 4usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::<Bar>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Bar ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Bar ) ) . baz as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Bar ) , "::" , - stringify ! ( baz ) )); + assert_eq!( + ::std::mem::size_of::<Bar>(), + 4usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::<Bar>(), + 4usize, + concat!("Alignment of ", stringify!(Bar)) + ); + assert_eq!( + unsafe { &(*(0 as *const Bar)).baz as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Bar), + "::", + stringify!(baz) + ) + ); } impl Clone for Bar { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } } diff --git a/tests/expectations/tests/inline_namespace_conservative.rs b/tests/expectations/tests/inline_namespace_conservative.rs index 406d9f5e..39e15611 100644 --- a/tests/expectations/tests/inline_namespace_conservative.rs +++ b/tests/expectations/tests/inline_namespace_conservative.rs @@ -25,17 +25,30 @@ pub mod root { } #[test] fn bindgen_test_layout_Bar() { - assert_eq!(::std::mem::size_of::<Bar>() , 4usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::<Bar>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Bar ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Bar ) ) . baz as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Bar ) , "::" , - stringify ! ( baz ) )); + assert_eq!( + ::std::mem::size_of::<Bar>(), + 4usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::<Bar>(), + 4usize, + concat!("Alignment of ", stringify!(Bar)) + ); + assert_eq!( + unsafe { &(*(0 as *const Bar)).baz as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Bar), + "::", + stringify!(baz) + ) + ); } impl Clone for Bar { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } } diff --git a/tests/expectations/tests/inline_namespace_no_ns_enabled.rs b/tests/expectations/tests/inline_namespace_no_ns_enabled.rs index c2592e57..e208f0dc 100644 --- a/tests/expectations/tests/inline_namespace_no_ns_enabled.rs +++ b/tests/expectations/tests/inline_namespace_no_ns_enabled.rs @@ -18,7 +18,9 @@ pub struct std_basic_string_Alloc_hider { pub storage: *mut ::std::os::raw::c_void, } impl Default for std_basic_string_Alloc_hider { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug)] @@ -26,9 +28,13 @@ pub struct std_basic_string__bindgen_ty_1<CharT> { pub inline_storage: [CharT; 4usize], pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<CharT>>, } -impl <CharT> Default for std_basic_string__bindgen_ty_1<CharT> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<CharT> Default for std_basic_string__bindgen_ty_1<CharT> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } -impl <CharT> Default for std_basic_string<CharT> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<CharT> Default for std_basic_string<CharT> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/inner_const.rs b/tests/expectations/tests/inner_const.rs index 1315bb6a..0a49c3f2 100644 --- a/tests/expectations/tests/inner_const.rs +++ b/tests/expectations/tests/inner_const.rs @@ -19,16 +19,29 @@ extern "C" { } #[test] fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::<Foo>() , 4usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::<Foo>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Foo ) , "::" , - stringify ! ( bar ) )); + assert_eq!( + ::std::mem::size_of::<Foo>(), + 4usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::<Foo>(), + 4usize, + concat!("Alignment of ", stringify!(Foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const Foo)).bar as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Foo), + "::", + stringify!(bar) + ) + ); } impl Clone for Foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/inner_template_self.rs b/tests/expectations/tests/inner_template_self.rs index b94ba60f..e5822659 100644 --- a/tests/expectations/tests/inner_template_self.rs +++ b/tests/expectations/tests/inner_template_self.rs @@ -11,7 +11,9 @@ pub struct LinkedList { pub prev: *mut LinkedList, } impl Default for LinkedList { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Copy)] @@ -20,28 +22,50 @@ pub struct InstantiateIt { } #[test] fn bindgen_test_layout_InstantiateIt() { - assert_eq!(::std::mem::size_of::<InstantiateIt>() , 16usize , concat ! ( - "Size of: " , stringify ! ( InstantiateIt ) )); - assert_eq! (::std::mem::align_of::<InstantiateIt>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( InstantiateIt ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const InstantiateIt ) ) . m_list as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( InstantiateIt ) , "::" - , stringify ! ( m_list ) )); + assert_eq!( + ::std::mem::size_of::<InstantiateIt>(), + 16usize, + concat!("Size of: ", stringify!(InstantiateIt)) + ); + assert_eq!( + ::std::mem::align_of::<InstantiateIt>(), + 8usize, + concat!("Alignment of ", stringify!(InstantiateIt)) + ); + assert_eq!( + unsafe { &(*(0 as *const InstantiateIt)).m_list as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(InstantiateIt), + "::", + stringify!(m_list) + ) + ); } impl Clone for InstantiateIt { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for InstantiateIt { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[test] fn __bindgen_test_layout_LinkedList_open0_int_close0_instantiation() { - assert_eq!(::std::mem::size_of::<LinkedList>() , 16usize , concat ! ( - "Size of template specialization: " , stringify ! ( LinkedList - ) )); - assert_eq!(::std::mem::align_of::<LinkedList>() , 8usize , concat ! ( - "Alignment of template specialization: " , stringify ! ( - LinkedList ) )); + assert_eq!( + ::std::mem::size_of::<LinkedList>(), + 16usize, + concat!("Size of template specialization: ", stringify!(LinkedList)) + ); + assert_eq!( + ::std::mem::align_of::<LinkedList>(), + 8usize, + concat!( + "Alignment of template specialization: ", + stringify!(LinkedList) + ) + ); } diff --git a/tests/expectations/tests/int128_t.rs b/tests/expectations/tests/int128_t.rs index 2ca90d40..5dcc6c40 100644 --- a/tests/expectations/tests/int128_t.rs +++ b/tests/expectations/tests/int128_t.rs @@ -2,6 +2,3 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - - diff --git a/tests/expectations/tests/issue-358.rs b/tests/expectations/tests/issue-358.rs index c094b333..892148aa 100644 --- a/tests/expectations/tests/issue-358.rs +++ b/tests/expectations/tests/issue-358.rs @@ -10,7 +10,9 @@ pub struct JS_PersistentRooted { pub _base: a, } impl Default for JS_PersistentRooted { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -18,5 +20,7 @@ pub struct a { pub b: *mut a, } impl Default for a { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/issue-372.rs b/tests/expectations/tests/issue-372.rs index 6924d0a9..c2516bda 100644 --- a/tests/expectations/tests/issue-372.rs +++ b/tests/expectations/tests/issue-372.rs @@ -17,31 +17,41 @@ pub mod root { } #[test] fn bindgen_test_layout_i() { - assert_eq!(::std::mem::size_of::<i>() , 24usize , concat ! ( - "Size of: " , stringify ! ( i ) )); - assert_eq! (::std::mem::align_of::<i>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( i ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const i ) ) . j as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( i ) , "::" , - stringify ! ( j ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const i ) ) . k as * const _ as usize } , - 8usize , concat ! ( - "Alignment of field: " , stringify ! ( i ) , "::" , - stringify ! ( k ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const i ) ) . l as * const _ as usize } , - 16usize , concat ! ( - "Alignment of field: " , stringify ! ( i ) , "::" , - stringify ! ( l ) )); + assert_eq!( + ::std::mem::size_of::<i>(), + 24usize, + concat!("Size of: ", stringify!(i)) + ); + assert_eq!( + ::std::mem::align_of::<i>(), + 8usize, + concat!("Alignment of ", stringify!(i)) + ); + assert_eq!( + unsafe { &(*(0 as *const i)).j as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(i), "::", stringify!(j)) + ); + assert_eq!( + unsafe { &(*(0 as *const i)).k as *const _ as usize }, + 8usize, + concat!("Alignment of field: ", stringify!(i), "::", stringify!(k)) + ); + assert_eq!( + unsafe { &(*(0 as *const i)).l as *const _ as usize }, + 16usize, + concat!("Alignment of field: ", stringify!(i), "::", stringify!(l)) + ); } impl Clone for i { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for i { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Copy)] @@ -50,21 +60,31 @@ pub mod root { } #[test] fn bindgen_test_layout_d() { - assert_eq!(::std::mem::size_of::<d>() , 24usize , concat ! ( - "Size of: " , stringify ! ( d ) )); - assert_eq! (::std::mem::align_of::<d>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( d ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const d ) ) . m as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( d ) , "::" , - stringify ! ( m ) )); + assert_eq!( + ::std::mem::size_of::<d>(), + 24usize, + concat!("Size of: ", stringify!(d)) + ); + assert_eq!( + ::std::mem::align_of::<d>(), + 8usize, + concat!("Alignment of ", stringify!(d)) + ); + assert_eq!( + unsafe { &(*(0 as *const d)).m as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(d), "::", stringify!(m)) + ); } impl Clone for d { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for d { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] @@ -88,17 +108,25 @@ pub mod root { } #[test] fn bindgen_test_layout_F() { - assert_eq!(::std::mem::size_of::<F>() , 264usize , concat ! ( - "Size of: " , stringify ! ( F ) )); - assert_eq! (::std::mem::align_of::<F>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( F ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const F ) ) . w as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( F ) , "::" , - stringify ! ( w ) )); + assert_eq!( + ::std::mem::size_of::<F>(), + 264usize, + concat!("Size of: ", stringify!(F)) + ); + assert_eq!( + ::std::mem::align_of::<F>(), + 8usize, + concat!("Alignment of ", stringify!(F)) + ); + assert_eq!( + unsafe { &(*(0 as *const F)).w as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(F), "::", stringify!(w)) + ); } impl Default for F { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } } diff --git a/tests/expectations/tests/issue-410.rs b/tests/expectations/tests/issue-410.rs index 2fcefa12..938cd597 100644 --- a/tests/expectations/tests/issue-410.rs +++ b/tests/expectations/tests/issue-410.rs @@ -30,7 +30,7 @@ pub mod root { ); } extern "C" { - #[link_name = "\u{1}_ZN2JS5Value1aE10JSWhyMagic"] + #[link_name = "\u{1}_ZN2JS5Value1aE10JSWhyMagic"] pub fn Value_a(this: *mut root::JS::Value, arg1: root::JSWhyMagic); } impl Clone for Value { @@ -46,5 +46,5 @@ pub mod root { } } #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] - pub enum JSWhyMagic { } + pub enum JSWhyMagic {} } diff --git a/tests/expectations/tests/issue-446.rs b/tests/expectations/tests/issue-446.rs index d416548d..d5634d53 100644 --- a/tests/expectations/tests/issue-446.rs +++ b/tests/expectations/tests/issue-446.rs @@ -10,7 +10,9 @@ pub struct List { pub next: *mut List, } impl Default for List { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -18,5 +20,7 @@ pub struct PersistentRooted { pub root_list: List, } impl Default for PersistentRooted { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/issue-447.rs b/tests/expectations/tests/issue-447.rs index 66e1c043..323da81e 100644 --- a/tests/expectations/tests/issue-447.rs +++ b/tests/expectations/tests/issue-447.rs @@ -58,7 +58,7 @@ pub mod root { ); } extern "C" { - #[link_name = "\u{1}_ZN17JSAutoCompartmentC1EN7mozilla6detail19GuardObjectNotifierE"] + #[link_name = "\u{1}_ZN17JSAutoCompartmentC1EN7mozilla6detail19GuardObjectNotifierE"] pub fn JSAutoCompartment_JSAutoCompartment( this: *mut root::JSAutoCompartment, arg1: root::mozilla::detail::GuardObjectNotifier, diff --git a/tests/expectations/tests/issue-493.rs b/tests/expectations/tests/issue-493.rs index 7a947366..8975938d 100644 --- a/tests/expectations/tests/issue-493.rs +++ b/tests/expectations/tests/issue-493.rs @@ -6,35 +6,47 @@ #[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(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct basic_string { @@ -51,13 +63,17 @@ pub struct basic_string___long { pub __data_: basic_string_pointer, } impl Default for basic_string___long { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } pub const basic_string___min_cap: basic_string__bindgen_ty_1 = basic_string__bindgen_ty_1::__min_cap; #[repr(i32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum basic_string__bindgen_ty_1 { __min_cap = 0, } +pub enum basic_string__bindgen_ty_1 { + __min_cap = 0, +} #[repr(C)] pub struct basic_string___short { pub __bindgen_anon_1: basic_string___short__bindgen_ty_1, @@ -70,10 +86,14 @@ pub union basic_string___short__bindgen_ty_1 { _bindgen_union_align: u8, } impl Default for basic_string___short__bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } impl Default for basic_string___short { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] pub struct basic_string___ulx { @@ -82,20 +102,26 @@ pub struct basic_string___ulx { pub bindgen_union_field: [u8; 0usize], } impl Default for basic_string___ulx { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } pub const basic_string___n_words: basic_string__bindgen_ty_2 = basic_string__bindgen_ty_2::__n_words; #[repr(i32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum basic_string__bindgen_ty_2 { __n_words = 0, } +pub enum basic_string__bindgen_ty_2 { + __n_words = 0, +} #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct basic_string___raw { pub __words: *mut basic_string_size_type, } impl Default for basic_string___raw { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] pub struct basic_string___rep { @@ -109,8 +135,12 @@ pub struct basic_string___rep__bindgen_ty_1 { pub bindgen_union_field: [u8; 0usize], } impl Default for basic_string___rep__bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } impl Default for basic_string___rep { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/issue-493_1_0.rs b/tests/expectations/tests/issue-493_1_0.rs index 710cd41e..da6dac77 100644 --- a/tests/expectations/tests/issue-493_1_0.rs +++ b/tests/expectations/tests/issue-493_1_0.rs @@ -6,35 +6,47 @@ #[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(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct basic_string { @@ -51,13 +63,17 @@ pub struct basic_string___long { pub __data_: basic_string_pointer, } impl Default for basic_string___long { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } pub const basic_string___min_cap: basic_string__bindgen_ty_1 = basic_string__bindgen_ty_1::__min_cap; #[repr(i32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum basic_string__bindgen_ty_1 { __min_cap = 0, } +pub enum basic_string__bindgen_ty_1 { + __min_cap = 0, +} #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct basic_string___short { @@ -72,7 +88,9 @@ pub struct basic_string___short__bindgen_ty_1 { pub bindgen_union_field: u8, } impl Default for basic_string___short { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Copy, Clone)] @@ -82,20 +100,26 @@ pub struct basic_string___ulx { pub bindgen_union_field: [u8; 0usize], } impl Default for basic_string___ulx { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } pub const basic_string___n_words: basic_string__bindgen_ty_2 = basic_string__bindgen_ty_2::__n_words; #[repr(i32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum basic_string__bindgen_ty_2 { __n_words = 0, } +pub enum basic_string__bindgen_ty_2 { + __n_words = 0, +} #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct basic_string___raw { pub __words: *mut basic_string_size_type, } impl Default for basic_string___raw { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Copy, Clone)] @@ -111,8 +135,12 @@ pub struct basic_string___rep__bindgen_ty_1 { pub bindgen_union_field: [u8; 0usize], } impl Default for basic_string___rep__bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } impl Default for basic_string___rep { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/issue-544-stylo-creduce-2.rs b/tests/expectations/tests/issue-544-stylo-creduce-2.rs index e217fe24..071111a4 100644 --- a/tests/expectations/tests/issue-544-stylo-creduce-2.rs +++ b/tests/expectations/tests/issue-544-stylo-creduce-2.rs @@ -11,5 +11,7 @@ pub struct Foo { pub type Foo_FirstAlias = [u8; 0usize]; pub type Foo_SecondAlias = [u8; 0usize]; impl Default for Foo { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/issue-569-non-type-template-params-causing-layout-test-failures.rs b/tests/expectations/tests/issue-569-non-type-template-params-causing-layout-test-failures.rs index 3eae9488..d3814fba 100644 --- a/tests/expectations/tests/issue-569-non-type-template-params-causing-layout-test-failures.rs +++ b/tests/expectations/tests/issue-569-non-type-template-params-causing-layout-test-failures.rs @@ -8,7 +8,10 @@ pub const ENUM_VARIANT_1: _bindgen_ty_1 = _bindgen_ty_1::ENUM_VARIANT_1; pub const ENUM_VARIANT_2: _bindgen_ty_1 = _bindgen_ty_1::ENUM_VARIANT_2; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum _bindgen_ty_1 { ENUM_VARIANT_1 = 0, ENUM_VARIANT_2 = 1, } +pub enum _bindgen_ty_1 { + ENUM_VARIANT_1 = 0, + ENUM_VARIANT_2 = 1, +} pub type JS_Alias = u8; #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -16,7 +19,9 @@ pub struct JS_Base { pub f: JS_Alias, } impl Default for JS_Base { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Copy)] @@ -25,23 +30,40 @@ pub struct JS_AutoIdVector { } #[test] fn bindgen_test_layout_JS_AutoIdVector() { - assert_eq!(::std::mem::size_of::<JS_AutoIdVector>() , 1usize , concat ! ( - "Size of: " , stringify ! ( JS_AutoIdVector ) )); - assert_eq! (::std::mem::align_of::<JS_AutoIdVector>() , 1usize , concat ! - ( "Alignment of " , stringify ! ( JS_AutoIdVector ) )); + assert_eq!( + ::std::mem::size_of::<JS_AutoIdVector>(), + 1usize, + concat!("Size of: ", stringify!(JS_AutoIdVector)) + ); + assert_eq!( + ::std::mem::align_of::<JS_AutoIdVector>(), + 1usize, + concat!("Alignment of ", stringify!(JS_AutoIdVector)) + ); } impl Clone for JS_AutoIdVector { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for JS_AutoIdVector { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[test] fn __bindgen_test_layout_JS_Base_open0_int_close0_instantiation() { - assert_eq!(::std::mem::size_of::<JS_Base>() , 1usize , concat ! ( - "Size of template specialization: " , stringify ! ( JS_Base ) - )); - assert_eq!(::std::mem::align_of::<JS_Base>() , 1usize , concat ! ( - "Alignment of template specialization: " , stringify ! ( - JS_Base ) )); + assert_eq!( + ::std::mem::size_of::<JS_Base>(), + 1usize, + concat!("Size of template specialization: ", stringify!(JS_Base)) + ); + assert_eq!( + ::std::mem::align_of::<JS_Base>(), + 1usize, + concat!( + "Alignment of template specialization: ", + stringify!(JS_Base) + ) + ); } diff --git a/tests/expectations/tests/issue-573-layout-test-failures.rs b/tests/expectations/tests/issue-573-layout-test-failures.rs index 50ea61e0..fba41d1a 100644 --- a/tests/expectations/tests/issue-573-layout-test-failures.rs +++ b/tests/expectations/tests/issue-573-layout-test-failures.rs @@ -16,24 +16,42 @@ pub struct AutoIdVector { } #[test] fn bindgen_test_layout_AutoIdVector() { - assert_eq!(::std::mem::size_of::<AutoIdVector>() , 1usize , concat ! ( - "Size of: " , stringify ! ( AutoIdVector ) )); - assert_eq! (::std::mem::align_of::<AutoIdVector>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( AutoIdVector ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const AutoIdVector ) ) . ar as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( AutoIdVector ) , "::" , - stringify ! ( ar ) )); + assert_eq!( + ::std::mem::size_of::<AutoIdVector>(), + 1usize, + concat!("Size of: ", stringify!(AutoIdVector)) + ); + assert_eq!( + ::std::mem::align_of::<AutoIdVector>(), + 1usize, + concat!("Alignment of ", stringify!(AutoIdVector)) + ); + assert_eq!( + unsafe { &(*(0 as *const AutoIdVector)).ar as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(AutoIdVector), + "::", + stringify!(ar) + ) + ); } impl Clone for AutoIdVector { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn __bindgen_test_layout_Outer_open0_int_close0_instantiation() { - assert_eq!(::std::mem::size_of::<Outer>() , 1usize , concat ! ( - "Size of template specialization: " , stringify ! ( Outer ) )); - assert_eq!(::std::mem::align_of::<Outer>() , 1usize , concat ! ( - "Alignment of template specialization: " , stringify ! ( Outer - ) )); + assert_eq!( + ::std::mem::size_of::<Outer>(), + 1usize, + concat!("Size of template specialization: ", stringify!(Outer)) + ); + assert_eq!( + ::std::mem::align_of::<Outer>(), + 1usize, + concat!("Alignment of template specialization: ", stringify!(Outer)) + ); } diff --git a/tests/expectations/tests/issue-574-assertion-failure-in-codegen.rs b/tests/expectations/tests/issue-574-assertion-failure-in-codegen.rs index 0d13c10d..e0554090 100644 --- a/tests/expectations/tests/issue-574-assertion-failure-in-codegen.rs +++ b/tests/expectations/tests/issue-574-assertion-failure-in-codegen.rs @@ -16,18 +16,31 @@ pub struct _bindgen_ty_1 { } #[test] fn bindgen_test_layout__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<_bindgen_ty_1>() , 1usize , concat ! ( - "Size of: " , stringify ! ( _bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<_bindgen_ty_1>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( _bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const _bindgen_ty_1 ) ) . ar as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( _bindgen_ty_1 ) , "::" - , stringify ! ( ar ) )); + assert_eq!( + ::std::mem::size_of::<_bindgen_ty_1>(), + 1usize, + concat!("Size of: ", stringify!(_bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<_bindgen_ty_1>(), + 1usize, + concat!("Alignment of ", stringify!(_bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const _bindgen_ty_1)).ar as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(_bindgen_ty_1), + "::", + stringify!(ar) + ) + ); } impl Clone for _bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } extern "C" { #[link_name = "\u{1}AutoIdVector"] @@ -35,9 +48,14 @@ extern "C" { } #[test] fn __bindgen_test_layout_a_open0_int_close0_instantiation() { - assert_eq!(::std::mem::size_of::<a>() , 1usize , concat ! ( - "Size of template specialization: " , stringify ! ( a ) )); - assert_eq!(::std::mem::align_of::<a>() , 1usize , concat ! ( - "Alignment of template specialization: " , stringify ! ( a ) - )); + assert_eq!( + ::std::mem::size_of::<a>(), + 1usize, + concat!("Size of template specialization: ", stringify!(a)) + ); + assert_eq!( + ::std::mem::align_of::<a>(), + 1usize, + concat!("Alignment of template specialization: ", stringify!(a)) + ); } diff --git a/tests/expectations/tests/issue-584-stylo-template-analysis-panic.rs b/tests/expectations/tests/issue-584-stylo-template-analysis-panic.rs index 87b38f28..433c0bad 100644 --- a/tests/expectations/tests/issue-584-stylo-template-analysis-panic.rs +++ b/tests/expectations/tests/issue-584-stylo-template-analysis-panic.rs @@ -13,21 +13,31 @@ pub struct A { pub type A_a = b; #[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!( + ::std::mem::size_of::<A>(), + 1usize, + concat!("Size of: ", stringify!(A)) + ); + assert_eq!( + ::std::mem::align_of::<A>(), + 1usize, + concat!("Alignment of ", stringify!(A)) + ); } impl Clone for A { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] pub struct e<c> { pub d: RefPtr<c>, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<c>>, } -impl <c> Default for e<c> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<c> Default for e<c> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] @@ -40,17 +50,26 @@ pub struct g { } #[test] fn bindgen_test_layout_g() { - assert_eq!(::std::mem::size_of::<g>() , 1usize , concat ! ( - "Size of: " , stringify ! ( g ) )); - assert_eq! (::std::mem::align_of::<g>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( g ) )); - assert_eq! (unsafe { & ( * ( 0 as * const g ) ) . h as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( g ) , "::" , stringify - ! ( h ) )); + assert_eq!( + ::std::mem::size_of::<g>(), + 1usize, + concat!("Size of: ", stringify!(g)) + ); + assert_eq!( + ::std::mem::align_of::<g>(), + 1usize, + concat!("Alignment of ", stringify!(g)) + ); + assert_eq!( + unsafe { &(*(0 as *const g)).h as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(g), "::", stringify!(h)) + ); } impl Default for g { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] pub struct b { @@ -58,13 +77,21 @@ pub struct b { } #[test] fn bindgen_test_layout_b() { - assert_eq!(::std::mem::size_of::<b>() , 1usize , concat ! ( - "Size of: " , stringify ! ( b ) )); - assert_eq! (::std::mem::align_of::<b>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( b ) )); + assert_eq!( + ::std::mem::size_of::<b>(), + 1usize, + concat!("Size of: ", stringify!(b)) + ); + assert_eq!( + ::std::mem::align_of::<b>(), + 1usize, + concat!("Alignment of ", stringify!(b)) + ); } impl Default for b { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } extern "C" { #[link_name = "\u{1}_Z25Servo_Element_GetSnapshotv"] @@ -72,9 +99,14 @@ extern "C" { } #[test] fn __bindgen_test_layout_f_open0_e_open1_int_close1_close0_instantiation() { - assert_eq!(::std::mem::size_of::<f>() , 1usize , concat ! ( - "Size of template specialization: " , stringify ! ( f ) )); - assert_eq!(::std::mem::align_of::<f>() , 1usize , concat ! ( - "Alignment of template specialization: " , stringify ! ( f ) - )); + assert_eq!( + ::std::mem::size_of::<f>(), + 1usize, + concat!("Size of template specialization: ", stringify!(f)) + ); + assert_eq!( + ::std::mem::align_of::<f>(), + 1usize, + concat!("Alignment of template specialization: ", stringify!(f)) + ); } diff --git a/tests/expectations/tests/issue-638-stylo-cannot-find-T-in-this-scope.rs b/tests/expectations/tests/issue-638-stylo-cannot-find-T-in-this-scope.rs index 4bda0927..11571a2d 100644 --- a/tests/expectations/tests/issue-638-stylo-cannot-find-T-in-this-scope.rs +++ b/tests/expectations/tests/issue-638-stylo-cannot-find-T-in-this-scope.rs @@ -10,8 +10,10 @@ pub struct RefPtr<T> { pub use_of_t: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } -impl <T> Default for RefPtr<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for RefPtr<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -20,6 +22,8 @@ pub struct UsesRefPtrWithAliasedTypeParam<U> { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<U>>, } pub type UsesRefPtrWithAliasedTypeParam_V<U> = U; -impl <U> Default for UsesRefPtrWithAliasedTypeParam<U> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<U> Default for UsesRefPtrWithAliasedTypeParam<U> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/issue-639-typedef-anon-field.rs b/tests/expectations/tests/issue-639-typedef-anon-field.rs index e67400cc..2a48641f 100644 --- a/tests/expectations/tests/issue-639-typedef-anon-field.rs +++ b/tests/expectations/tests/issue-639-typedef-anon-field.rs @@ -16,33 +16,59 @@ pub struct Foo_Bar { } #[test] fn bindgen_test_layout_Foo_Bar() { - assert_eq!(::std::mem::size_of::<Foo_Bar>() , 4usize , concat ! ( - "Size of: " , stringify ! ( Foo_Bar ) )); - assert_eq! (::std::mem::align_of::<Foo_Bar>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Foo_Bar ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Foo_Bar ) ) . abc as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Foo_Bar ) , "::" , - stringify ! ( abc ) )); + assert_eq!( + ::std::mem::size_of::<Foo_Bar>(), + 4usize, + concat!("Size of: ", stringify!(Foo_Bar)) + ); + assert_eq!( + ::std::mem::align_of::<Foo_Bar>(), + 4usize, + concat!("Alignment of ", stringify!(Foo_Bar)) + ); + assert_eq!( + unsafe { &(*(0 as *const Foo_Bar)).abc as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Foo_Bar), + "::", + stringify!(abc) + ) + ); } impl Clone for Foo_Bar { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::<Foo>() , 4usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::<Foo>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Foo ) , "::" , - stringify ! ( bar ) )); + assert_eq!( + ::std::mem::size_of::<Foo>(), + 4usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::<Foo>(), + 4usize, + concat!("Alignment of ", stringify!(Foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const Foo)).bar as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Foo), + "::", + stringify!(bar) + ) + ); } impl Clone for Foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy)] @@ -56,26 +82,47 @@ pub struct Baz_Bar { } #[test] fn bindgen_test_layout_Baz_Bar() { - assert_eq!(::std::mem::size_of::<Baz_Bar>() , 4usize , concat ! ( - "Size of: " , stringify ! ( Baz_Bar ) )); - assert_eq! (::std::mem::align_of::<Baz_Bar>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Baz_Bar ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Baz_Bar ) ) . abc as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Baz_Bar ) , "::" , - stringify ! ( abc ) )); + assert_eq!( + ::std::mem::size_of::<Baz_Bar>(), + 4usize, + concat!("Size of: ", stringify!(Baz_Bar)) + ); + assert_eq!( + ::std::mem::align_of::<Baz_Bar>(), + 4usize, + concat!("Alignment of ", stringify!(Baz_Bar)) + ); + assert_eq!( + unsafe { &(*(0 as *const Baz_Bar)).abc as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Baz_Bar), + "::", + stringify!(abc) + ) + ); } impl Clone for Baz_Bar { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_Baz() { - assert_eq!(::std::mem::size_of::<Baz>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Baz ) )); - assert_eq! (::std::mem::align_of::<Baz>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Baz ) )); + assert_eq!( + ::std::mem::size_of::<Baz>(), + 1usize, + concat!("Size of: ", stringify!(Baz)) + ); + assert_eq!( + ::std::mem::align_of::<Baz>(), + 1usize, + concat!("Alignment of ", stringify!(Baz)) + ); } impl Clone for Baz { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/issue-643-inner-struct.rs b/tests/expectations/tests/issue-643-inner-struct.rs index 82be5c92..f0375cc8 100644 --- a/tests/expectations/tests/issue-643-inner-struct.rs +++ b/tests/expectations/tests/issue-643-inner-struct.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,16 +29,18 @@ 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)] #[derive(Debug)] pub struct rte_ring { @@ -52,18 +56,31 @@ pub struct rte_ring_prod { } #[test] fn bindgen_test_layout_rte_ring_prod() { - assert_eq!(::std::mem::size_of::<rte_ring_prod>() , 4usize , concat ! ( - "Size of: " , stringify ! ( rte_ring_prod ) )); - assert_eq! (::std::mem::align_of::<rte_ring_prod>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( rte_ring_prod ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ring_prod ) ) . watermark as * const - _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ring_prod ) , "::" - , stringify ! ( watermark ) )); + assert_eq!( + ::std::mem::size_of::<rte_ring_prod>(), + 4usize, + concat!("Size of: ", stringify!(rte_ring_prod)) + ); + assert_eq!( + ::std::mem::align_of::<rte_ring_prod>(), + 4usize, + concat!("Alignment of ", stringify!(rte_ring_prod)) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_ring_prod)).watermark as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(rte_ring_prod), + "::", + stringify!(watermark) + ) + ); } impl Clone for rte_ring_prod { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy)] @@ -72,28 +89,49 @@ pub struct rte_ring_cons { } #[test] fn bindgen_test_layout_rte_ring_cons() { - assert_eq!(::std::mem::size_of::<rte_ring_cons>() , 4usize , concat ! ( - "Size of: " , stringify ! ( rte_ring_cons ) )); - assert_eq! (::std::mem::align_of::<rte_ring_cons>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( rte_ring_cons ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ring_cons ) ) . sc_dequeue as * const - _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ring_cons ) , "::" - , stringify ! ( sc_dequeue ) )); + assert_eq!( + ::std::mem::size_of::<rte_ring_cons>(), + 4usize, + concat!("Size of: ", stringify!(rte_ring_cons)) + ); + assert_eq!( + ::std::mem::align_of::<rte_ring_cons>(), + 4usize, + concat!("Alignment of ", stringify!(rte_ring_cons)) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_ring_cons)).sc_dequeue as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(rte_ring_cons), + "::", + stringify!(sc_dequeue) + ) + ); } impl Clone for rte_ring_cons { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_rte_ring() { - assert_eq!(::std::mem::size_of::<rte_ring>() , 16usize , concat ! ( - "Size of: " , stringify ! ( rte_ring ) )); - assert_eq! (::std::mem::align_of::<rte_ring>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( rte_ring ) )); + assert_eq!( + ::std::mem::size_of::<rte_ring>(), + 16usize, + concat!("Size of: ", stringify!(rte_ring)) + ); + assert_eq!( + ::std::mem::align_of::<rte_ring>(), + 8usize, + concat!("Alignment of ", stringify!(rte_ring)) + ); } impl Default for rte_ring { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Default, Copy)] @@ -101,5 +139,7 @@ pub struct rte_memzone { pub _address: u8, } impl Clone for rte_memzone { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/issue-645-cannot-find-type-T-in-this-scope.rs b/tests/expectations/tests/issue-645-cannot-find-type-T-in-this-scope.rs index 87228ec6..4d65c0ae 100644 --- a/tests/expectations/tests/issue-645-cannot-find-type-T-in-this-scope.rs +++ b/tests/expectations/tests/issue-645-cannot-find-type-T-in-this-scope.rs @@ -3,7 +3,8 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[derive(Clone, Copy, Debug)] pub struct RefPtr<T>(T); +#[derive(Clone, Copy, Debug)] +pub struct RefPtr<T>(T); #[repr(C)] pub struct HasRefPtr<T> { @@ -11,6 +12,8 @@ pub struct HasRefPtr<T> { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } pub type HasRefPtr_TypedefOfT<T> = T; -impl <T> Default for HasRefPtr<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for HasRefPtr<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/issue-662-cannot-find-T-in-this-scope.rs b/tests/expectations/tests/issue-662-cannot-find-T-in-this-scope.rs index 3e7c4195..f5ecbd5e 100644 --- a/tests/expectations/tests/issue-662-cannot-find-T-in-this-scope.rs +++ b/tests/expectations/tests/issue-662-cannot-find-T-in-this-scope.rs @@ -10,8 +10,10 @@ pub struct RefPtr<T> { pub a: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } -impl <T> Default for RefPtr<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for RefPtr<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -19,8 +21,10 @@ pub struct nsMainThreadPtrHolder<T> { pub a: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } -impl <T> Default for nsMainThreadPtrHolder<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for nsMainThreadPtrHolder<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -28,6 +32,8 @@ pub struct nsMainThreadPtrHandle<T> { pub mPtr: RefPtr<nsMainThreadPtrHolder<T>>, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } -impl <T> Default for nsMainThreadPtrHandle<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for nsMainThreadPtrHandle<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/issue-662-part-2.rs b/tests/expectations/tests/issue-662-part-2.rs index a1b97ca6..9e685b3a 100644 --- a/tests/expectations/tests/issue-662-part-2.rs +++ b/tests/expectations/tests/issue-662-part-2.rs @@ -3,7 +3,8 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[derive(Clone, Copy, Debug)] pub struct RefPtr<T>(T); +#[derive(Clone, Copy, Debug)] +pub struct RefPtr<T>(T); #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -11,14 +12,18 @@ pub struct nsMainThreadPtrHolder<T> { pub a: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } -impl <T> Default for nsMainThreadPtrHolder<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for nsMainThreadPtrHolder<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] pub struct nsMainThreadPtrHandle<U> { pub mPtr: RefPtr<nsMainThreadPtrHolder<U>>, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<U>>, } -impl <U> Default for nsMainThreadPtrHandle<U> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<U> Default for nsMainThreadPtrHandle<U> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/issue-674-1.rs b/tests/expectations/tests/issue-674-1.rs index 31fe3c53..ee71cc55 100644 --- a/tests/expectations/tests/issue-674-1.rs +++ b/tests/expectations/tests/issue-674-1.rs @@ -25,19 +25,30 @@ pub mod root { } #[test] fn bindgen_test_layout_CapturingContentInfo() { - assert_eq!(::std::mem::size_of::<CapturingContentInfo>() , 1usize , - concat ! ( - "Size of: " , stringify ! ( CapturingContentInfo ) )); - assert_eq! (::std::mem::align_of::<CapturingContentInfo>() , 1usize , - concat ! ( - "Alignment of " , stringify ! ( CapturingContentInfo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const CapturingContentInfo ) ) . a as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - CapturingContentInfo ) , "::" , stringify ! ( a ) )); + assert_eq!( + ::std::mem::size_of::<CapturingContentInfo>(), + 1usize, + concat!("Size of: ", stringify!(CapturingContentInfo)) + ); + assert_eq!( + ::std::mem::align_of::<CapturingContentInfo>(), + 1usize, + concat!("Alignment of ", stringify!(CapturingContentInfo)) + ); + assert_eq!( + unsafe { &(*(0 as *const CapturingContentInfo)).a as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(CapturingContentInfo), + "::", + stringify!(a) + ) + ); } impl Clone for CapturingContentInfo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } } diff --git a/tests/expectations/tests/issue-674-2.rs b/tests/expectations/tests/issue-674-2.rs index cfbef269..29990978 100644 --- a/tests/expectations/tests/issue-674-2.rs +++ b/tests/expectations/tests/issue-674-2.rs @@ -25,18 +25,26 @@ pub mod root { } #[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 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const c ) ) . b as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( c ) , "::" , - stringify ! ( b ) )); + 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)) + ); + assert_eq!( + unsafe { &(*(0 as *const c)).b as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(c), "::", stringify!(b)) + ); } impl Clone for c { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy)] @@ -45,18 +53,26 @@ pub mod root { } #[test] fn bindgen_test_layout_B() { - assert_eq!(::std::mem::size_of::<B>() , 1usize , concat ! ( - "Size of: " , stringify ! ( B ) )); - assert_eq! (::std::mem::align_of::<B>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( B ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const B ) ) . a as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( B ) , "::" , - stringify ! ( a ) )); + assert_eq!( + ::std::mem::size_of::<B>(), + 1usize, + concat!("Size of: ", stringify!(B)) + ); + assert_eq!( + ::std::mem::align_of::<B>(), + 1usize, + concat!("Alignment of ", stringify!(B)) + ); + assert_eq!( + unsafe { &(*(0 as *const B)).a as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(B), "::", stringify!(a)) + ); } impl Clone for B { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] @@ -65,13 +81,21 @@ pub mod root { } #[test] fn __bindgen_test_layout_StaticRefPtr_open0_B_close0_instantiation() { - assert_eq!(::std::mem::size_of::<root::StaticRefPtr>() , 1usize , - concat ! ( - "Size of template specialization: " , stringify ! ( - root::StaticRefPtr ) )); - assert_eq!(::std::mem::align_of::<root::StaticRefPtr>() , 1usize , - concat ! ( - "Alignment of template specialization: " , stringify ! ( - root::StaticRefPtr ) )); + assert_eq!( + ::std::mem::size_of::<root::StaticRefPtr>(), + 1usize, + concat!( + "Size of template specialization: ", + stringify!(root::StaticRefPtr) + ) + ); + assert_eq!( + ::std::mem::align_of::<root::StaticRefPtr>(), + 1usize, + concat!( + "Alignment of template specialization: ", + stringify!(root::StaticRefPtr) + ) + ); } } diff --git a/tests/expectations/tests/issue-674-3.rs b/tests/expectations/tests/issue-674-3.rs index 71f794c3..f98720aa 100644 --- a/tests/expectations/tests/issue-674-3.rs +++ b/tests/expectations/tests/issue-674-3.rs @@ -21,18 +21,26 @@ pub mod root { } #[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 ) ) . b as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( a ) , "::" , - stringify ! ( b ) )); + 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)).b as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(a), "::", stringify!(b)) + ); } impl Clone for a { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy)] @@ -41,17 +49,30 @@ pub mod root { } #[test] fn bindgen_test_layout_nsCSSValue() { - assert_eq!(::std::mem::size_of::<nsCSSValue>() , 1usize , concat ! ( - "Size of: " , stringify ! ( nsCSSValue ) )); - assert_eq! (::std::mem::align_of::<nsCSSValue>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( nsCSSValue ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const nsCSSValue ) ) . c as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( nsCSSValue ) , "::" - , stringify ! ( c ) )); + assert_eq!( + ::std::mem::size_of::<nsCSSValue>(), + 1usize, + concat!("Size of: ", stringify!(nsCSSValue)) + ); + assert_eq!( + ::std::mem::align_of::<nsCSSValue>(), + 1usize, + concat!("Alignment of ", stringify!(nsCSSValue)) + ); + assert_eq!( + unsafe { &(*(0 as *const nsCSSValue)).c as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(nsCSSValue), + "::", + stringify!(c) + ) + ); } impl Clone for nsCSSValue { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } } diff --git a/tests/expectations/tests/issue-691-template-parameter-virtual.rs b/tests/expectations/tests/issue-691-template-parameter-virtual.rs index 09f5ee20..aef7ed4a 100644 --- a/tests/expectations/tests/issue-691-template-parameter-virtual.rs +++ b/tests/expectations/tests/issue-691-template-parameter-virtual.rs @@ -13,16 +13,26 @@ pub struct VirtualMethods { } #[test] fn bindgen_test_layout_VirtualMethods() { - assert_eq!(::std::mem::size_of::<VirtualMethods>() , 8usize , concat ! ( - "Size of: " , stringify ! ( VirtualMethods ) )); - assert_eq! (::std::mem::align_of::<VirtualMethods>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( VirtualMethods ) )); + assert_eq!( + ::std::mem::size_of::<VirtualMethods>(), + 8usize, + concat!("Size of: ", stringify!(VirtualMethods)) + ); + assert_eq!( + ::std::mem::align_of::<VirtualMethods>(), + 8usize, + concat!("Alignment of ", stringify!(VirtualMethods)) + ); } impl Clone for VirtualMethods { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for VirtualMethods { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] @@ -36,25 +46,37 @@ pub struct ServoElementSnapshotTable { } #[test] fn bindgen_test_layout_ServoElementSnapshotTable() { - assert_eq!(::std::mem::size_of::<ServoElementSnapshotTable>() , 4usize , - concat ! ( - "Size of: " , stringify ! ( ServoElementSnapshotTable ) )); - assert_eq! (::std::mem::align_of::<ServoElementSnapshotTable>() , 4usize , - concat ! ( - "Alignment of " , stringify ! ( ServoElementSnapshotTable ) - )); + assert_eq!( + ::std::mem::size_of::<ServoElementSnapshotTable>(), + 4usize, + concat!("Size of: ", stringify!(ServoElementSnapshotTable)) + ); + assert_eq!( + ::std::mem::align_of::<ServoElementSnapshotTable>(), + 4usize, + concat!("Alignment of ", stringify!(ServoElementSnapshotTable)) + ); } impl Clone for ServoElementSnapshotTable { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for ServoElementSnapshotTable { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[test] fn __bindgen_test_layout_Set_open0_VirtualMethods_close0_instantiation() { - assert_eq!(::std::mem::size_of::<Set>() , 4usize , concat ! ( - "Size of template specialization: " , stringify ! ( Set ) )); - assert_eq!(::std::mem::align_of::<Set>() , 4usize , concat ! ( - "Alignment of template specialization: " , stringify ! ( Set ) - )); + assert_eq!( + ::std::mem::size_of::<Set>(), + 4usize, + concat!("Size of template specialization: ", stringify!(Set)) + ); + assert_eq!( + ::std::mem::align_of::<Set>(), + 4usize, + concat!("Alignment of template specialization: ", stringify!(Set)) + ); } diff --git a/tests/expectations/tests/issue-739-pointer-wide-bitfield.rs b/tests/expectations/tests/issue-739-pointer-wide-bitfield.rs index 17e63981..30d59ab7 100644 --- a/tests/expectations/tests/issue-739-pointer-wide-bitfield.rs +++ b/tests/expectations/tests/issue-739-pointer-wide-bitfield.rs @@ -12,11 +12,19 @@ pub struct Foo { } #[test] fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::<Foo>() , 32usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::<Foo>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::<Foo>(), + 32usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::<Foo>(), + 8usize, + concat!("Alignment of ", stringify!(Foo)) + ); } impl Clone for Foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/issue-801-opaque-sloppiness.rs b/tests/expectations/tests/issue-801-opaque-sloppiness.rs index b07e17c4..896a9a6c 100644 --- a/tests/expectations/tests/issue-801-opaque-sloppiness.rs +++ b/tests/expectations/tests/issue-801-opaque-sloppiness.rs @@ -16,13 +16,21 @@ pub struct B { } #[test] fn bindgen_test_layout_B() { - assert_eq!(::std::mem::size_of::<B>() , 1usize , concat ! ( - "Size of: " , stringify ! ( B ) )); - assert_eq! (::std::mem::align_of::<B>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( B ) )); + assert_eq!( + ::std::mem::size_of::<B>(), + 1usize, + concat!("Size of: ", stringify!(B)) + ); + assert_eq!( + ::std::mem::align_of::<B>(), + 1usize, + concat!("Alignment of ", stringify!(B)) + ); } impl Clone for B { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } extern "C" { #[link_name = "\u{1}_ZN1B1aE"] @@ -35,15 +43,24 @@ pub struct C { } #[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 ) )); - assert_eq! (unsafe { & ( * ( 0 as * const C ) ) . b as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( b ) )); + 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)) + ); + assert_eq!( + unsafe { &(*(0 as *const C)).b as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(C), "::", stringify!(b)) + ); } impl Clone for C { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs b/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs index 1e153606..63ec6982 100644 --- a/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs +++ b/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs @@ -11,13 +11,21 @@ pub struct Pupper { } #[test] fn bindgen_test_layout_Pupper() { - assert_eq!(::std::mem::size_of::<Pupper>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Pupper ) )); - assert_eq! (::std::mem::align_of::<Pupper>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Pupper ) )); + assert_eq!( + ::std::mem::size_of::<Pupper>(), + 1usize, + concat!("Size of: ", stringify!(Pupper)) + ); + assert_eq!( + ::std::mem::align_of::<Pupper>(), + 1usize, + concat!("Alignment of ", stringify!(Pupper)) + ); } impl Clone for Pupper { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] @@ -26,13 +34,21 @@ pub struct Doggo { } #[test] fn bindgen_test_layout_Doggo() { - assert_eq!(::std::mem::size_of::<Doggo>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Doggo ) )); - assert_eq! (::std::mem::align_of::<Doggo>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Doggo ) )); + assert_eq!( + ::std::mem::size_of::<Doggo>(), + 1usize, + concat!("Size of: ", stringify!(Doggo)) + ); + assert_eq!( + ::std::mem::align_of::<Doggo>(), + 1usize, + concat!("Alignment of ", stringify!(Doggo)) + ); } impl Clone for Doggo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] @@ -41,13 +57,21 @@ pub struct SuchWow { } #[test] fn bindgen_test_layout_SuchWow() { - assert_eq!(::std::mem::size_of::<SuchWow>() , 1usize , concat ! ( - "Size of: " , stringify ! ( SuchWow ) )); - assert_eq! (::std::mem::align_of::<SuchWow>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( SuchWow ) )); + assert_eq!( + ::std::mem::size_of::<SuchWow>(), + 1usize, + concat!("Size of: ", stringify!(SuchWow)) + ); + assert_eq!( + ::std::mem::align_of::<SuchWow>(), + 1usize, + concat!("Alignment of ", stringify!(SuchWow)) + ); } impl Clone for SuchWow { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] @@ -56,10 +80,16 @@ pub struct Opaque { } #[test] fn bindgen_test_layout_Opaque() { - assert_eq!(::std::mem::size_of::<Opaque>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Opaque ) )); - assert_eq! (::std::mem::align_of::<Opaque>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Opaque ) )); + assert_eq!( + ::std::mem::size_of::<Opaque>(), + 1usize, + concat!("Size of: ", stringify!(Opaque)) + ); + assert_eq!( + ::std::mem::align_of::<Opaque>(), + 1usize, + concat!("Alignment of ", stringify!(Opaque)) + ); } extern "C" { #[link_name = "\u{1}_ZN6Opaque17eleven_out_of_tenEv"] @@ -70,7 +100,9 @@ extern "C" { pub fn Opaque_Opaque(this: *mut Opaque, pup: Pupper); } impl Clone for Opaque { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Opaque { #[inline] @@ -95,16 +127,29 @@ pub struct Whitelisted { } #[test] fn bindgen_test_layout_Whitelisted() { - assert_eq!(::std::mem::size_of::<Whitelisted>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Whitelisted ) )); - assert_eq! (::std::mem::align_of::<Whitelisted>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Whitelisted ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Whitelisted ) ) . some_member as * const - _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Whitelisted ) , "::" , - stringify ! ( some_member ) )); + assert_eq!( + ::std::mem::size_of::<Whitelisted>(), + 1usize, + concat!("Size of: ", stringify!(Whitelisted)) + ); + assert_eq!( + ::std::mem::align_of::<Whitelisted>(), + 1usize, + concat!("Alignment of ", stringify!(Whitelisted)) + ); + assert_eq!( + unsafe { &(*(0 as *const Whitelisted)).some_member as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Whitelisted), + "::", + stringify!(some_member) + ) + ); } impl Clone for Whitelisted { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/issue-826-generating-methods-when-asked-not-to.rs b/tests/expectations/tests/issue-826-generating-methods-when-asked-not-to.rs index c894b95c..f84a7005 100644 --- a/tests/expectations/tests/issue-826-generating-methods-when-asked-not-to.rs +++ b/tests/expectations/tests/issue-826-generating-methods-when-asked-not-to.rs @@ -11,11 +11,19 @@ pub struct Foo { } #[test] fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::<Foo>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::<Foo>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::<Foo>(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::<Foo>(), + 1usize, + concat!("Alignment of ", stringify!(Foo)) + ); } impl Clone for Foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/issue-833-1.rs b/tests/expectations/tests/issue-833-1.rs index 4900bf2d..aa19dd1b 100644 --- a/tests/expectations/tests/issue-833-1.rs +++ b/tests/expectations/tests/issue-833-1.rs @@ -3,7 +3,10 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] pub struct nsTArray { pub hdr: *const () } +#[repr(C)] +pub struct nsTArray { + pub hdr: *const (), +} extern "C" { pub fn func() -> *mut nsTArray; diff --git a/tests/expectations/tests/issue-833.rs b/tests/expectations/tests/issue-833.rs index 9de7c64f..4ee4602a 100644 --- a/tests/expectations/tests/issue-833.rs +++ b/tests/expectations/tests/issue-833.rs @@ -3,7 +3,10 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] pub struct nsTArray<T> { pub hdr: *const T } +#[repr(C)] +pub struct nsTArray<T> { + pub hdr: *const T, +} extern "C" { pub fn func() -> *mut nsTArray<::std::os::raw::c_int>; diff --git a/tests/expectations/tests/issue-834.rs b/tests/expectations/tests/issue-834.rs index 1e507ad2..35f0c13f 100644 --- a/tests/expectations/tests/issue-834.rs +++ b/tests/expectations/tests/issue-834.rs @@ -11,11 +11,19 @@ pub struct U { } #[test] fn bindgen_test_layout_U() { - assert_eq!(::std::mem::size_of::<U>() , 1usize , concat ! ( - "Size of: " , stringify ! ( U ) )); - assert_eq! (::std::mem::align_of::<U>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( U ) )); + assert_eq!( + ::std::mem::size_of::<U>(), + 1usize, + concat!("Size of: ", stringify!(U)) + ); + assert_eq!( + ::std::mem::align_of::<U>(), + 1usize, + concat!("Alignment of ", stringify!(U)) + ); } impl Clone for U { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/issue-888-enum-var-decl-jump.rs b/tests/expectations/tests/issue-888-enum-var-decl-jump.rs index 9f446d70..6d2b0c5e 100644 --- a/tests/expectations/tests/issue-888-enum-var-decl-jump.rs +++ b/tests/expectations/tests/issue-888-enum-var-decl-jump.rs @@ -22,15 +22,23 @@ pub mod root { } #[test] fn bindgen_test_layout_Type() { - assert_eq!(::std::mem::size_of::<Type>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Type ) )); - assert_eq! (::std::mem::align_of::<Type>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Type ) )); + assert_eq!( + ::std::mem::size_of::<Type>(), + 1usize, + concat!("Size of: ", stringify!(Type)) + ); + assert_eq!( + ::std::mem::align_of::<Type>(), + 1usize, + concat!("Alignment of ", stringify!(Type)) + ); } impl Clone for Type { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } } #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] - pub enum a { } + pub enum a {} } diff --git a/tests/expectations/tests/issue_311.rs b/tests/expectations/tests/issue_311.rs index c5ecb966..a464442e 100644 --- a/tests/expectations/tests/issue_311.rs +++ b/tests/expectations/tests/issue_311.rs @@ -20,26 +20,38 @@ pub mod root { } #[test] fn bindgen_test_layout_jsval_layout__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<jsval_layout__bindgen_ty_1>() , - 1usize , concat ! ( - "Size of: " , stringify ! ( jsval_layout__bindgen_ty_1 ) - )); - assert_eq! (::std::mem::align_of::<jsval_layout__bindgen_ty_1>() , - 1usize , concat ! ( - "Alignment of " , stringify ! ( jsval_layout__bindgen_ty_1 - ) )); + assert_eq!( + ::std::mem::size_of::<jsval_layout__bindgen_ty_1>(), + 1usize, + concat!("Size of: ", stringify!(jsval_layout__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<jsval_layout__bindgen_ty_1>(), + 1usize, + concat!("Alignment of ", stringify!(jsval_layout__bindgen_ty_1)) + ); } impl Clone for jsval_layout__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_jsval_layout() { - assert_eq!(::std::mem::size_of::<jsval_layout>() , 1usize , concat ! ( - "Size of: " , stringify ! ( jsval_layout ) )); - assert_eq! (::std::mem::align_of::<jsval_layout>() , 1usize , concat ! - ( "Alignment of " , stringify ! ( jsval_layout ) )); + assert_eq!( + ::std::mem::size_of::<jsval_layout>(), + 1usize, + concat!("Size of: ", stringify!(jsval_layout)) + ); + assert_eq!( + ::std::mem::align_of::<jsval_layout>(), + 1usize, + concat!("Alignment of ", stringify!(jsval_layout)) + ); } impl Clone for jsval_layout { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } } diff --git a/tests/expectations/tests/layout.rs b/tests/expectations/tests/layout.rs index 28ebdc76..eedf1e2b 100644 --- a/tests/expectations/tests/layout.rs +++ b/tests/expectations/tests/layout.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,16 +29,18 @@ 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, packed)] #[derive(Debug, Default)] pub struct header { @@ -47,6 +51,9 @@ pub struct header { } #[test] fn bindgen_test_layout_header() { - assert_eq!(::std::mem::size_of::<header>() , 16usize , concat ! ( - "Size of: " , stringify ! ( header ) )); + assert_eq!( + ::std::mem::size_of::<header>(), + 16usize, + concat!("Size of: ", stringify!(header)) + ); } diff --git a/tests/expectations/tests/layout_arp.rs b/tests/expectations/tests/layout_arp.rs index 8f853068..4f9145b6 100644 --- a/tests/expectations/tests/layout_arp.rs +++ b/tests/expectations/tests/layout_arp.rs @@ -29,18 +29,31 @@ pub struct ether_addr { } #[test] fn bindgen_test_layout_ether_addr() { - assert_eq!(::std::mem::size_of::<ether_addr>() , 6usize , concat ! ( - "Size of: " , stringify ! ( ether_addr ) )); - assert_eq! (::std::mem::align_of::<ether_addr>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( ether_addr ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ether_addr ) ) . addr_bytes as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( ether_addr ) , "::" , - stringify ! ( addr_bytes ) )); + assert_eq!( + ::std::mem::size_of::<ether_addr>(), + 6usize, + concat!("Size of: ", stringify!(ether_addr)) + ); + assert_eq!( + ::std::mem::align_of::<ether_addr>(), + 1usize, + concat!("Alignment of ", stringify!(ether_addr)) + ); + assert_eq!( + unsafe { &(*(0 as *const ether_addr)).addr_bytes as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(ether_addr), + "::", + stringify!(addr_bytes) + ) + ); } impl Clone for ether_addr { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } /// ARP header IPv4 payload. #[repr(C, packed)] @@ -57,33 +70,61 @@ pub struct arp_ipv4 { } #[test] fn bindgen_test_layout_arp_ipv4() { - assert_eq!(::std::mem::size_of::<arp_ipv4>() , 20usize , concat ! ( - "Size of: " , stringify ! ( arp_ipv4 ) )); - assert_eq! (::std::mem::align_of::<arp_ipv4>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( arp_ipv4 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const arp_ipv4 ) ) . arp_sha as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( arp_ipv4 ) , "::" , - stringify ! ( arp_sha ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const arp_ipv4 ) ) . arp_sip as * const _ as - usize } , 6usize , concat ! ( - "Alignment of field: " , stringify ! ( arp_ipv4 ) , "::" , - stringify ! ( arp_sip ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const arp_ipv4 ) ) . arp_tha as * const _ as - usize } , 10usize , concat ! ( - "Alignment of field: " , stringify ! ( arp_ipv4 ) , "::" , - stringify ! ( arp_tha ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const arp_ipv4 ) ) . arp_tip as * const _ as - usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( arp_ipv4 ) , "::" , - stringify ! ( arp_tip ) )); + assert_eq!( + ::std::mem::size_of::<arp_ipv4>(), + 20usize, + concat!("Size of: ", stringify!(arp_ipv4)) + ); + assert_eq!( + ::std::mem::align_of::<arp_ipv4>(), + 1usize, + concat!("Alignment of ", stringify!(arp_ipv4)) + ); + assert_eq!( + unsafe { &(*(0 as *const arp_ipv4)).arp_sha as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(arp_ipv4), + "::", + stringify!(arp_sha) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const arp_ipv4)).arp_sip as *const _ as usize }, + 6usize, + concat!( + "Alignment of field: ", + stringify!(arp_ipv4), + "::", + stringify!(arp_sip) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const arp_ipv4)).arp_tha as *const _ as usize }, + 10usize, + concat!( + "Alignment of field: ", + stringify!(arp_ipv4), + "::", + stringify!(arp_tha) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const arp_ipv4)).arp_tip as *const _ as usize }, + 16usize, + concat!( + "Alignment of field: ", + stringify!(arp_ipv4), + "::", + stringify!(arp_tip) + ) + ); } impl Clone for arp_ipv4 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } /// ARP header. #[repr(C, packed)] @@ -98,41 +139,79 @@ pub struct arp_hdr { } #[test] fn bindgen_test_layout_arp_hdr() { - assert_eq!(::std::mem::size_of::<arp_hdr>() , 28usize , concat ! ( - "Size of: " , stringify ! ( arp_hdr ) )); - assert_eq! (::std::mem::align_of::<arp_hdr>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( arp_hdr ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const arp_hdr ) ) . arp_hrd as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( arp_hdr ) , "::" , - stringify ! ( arp_hrd ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const arp_hdr ) ) . arp_pro as * const _ as - usize } , 2usize , concat ! ( - "Alignment of field: " , stringify ! ( arp_hdr ) , "::" , - stringify ! ( arp_pro ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const arp_hdr ) ) . arp_hln as * const _ as - usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( arp_hdr ) , "::" , - stringify ! ( arp_hln ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const arp_hdr ) ) . arp_pln as * const _ as - usize } , 5usize , concat ! ( - "Alignment of field: " , stringify ! ( arp_hdr ) , "::" , - stringify ! ( arp_pln ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const arp_hdr ) ) . arp_op as * const _ as - usize } , 6usize , concat ! ( - "Alignment of field: " , stringify ! ( arp_hdr ) , "::" , - stringify ! ( arp_op ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const arp_hdr ) ) . arp_data as * const _ as - usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( arp_hdr ) , "::" , - stringify ! ( arp_data ) )); + assert_eq!( + ::std::mem::size_of::<arp_hdr>(), + 28usize, + concat!("Size of: ", stringify!(arp_hdr)) + ); + assert_eq!( + ::std::mem::align_of::<arp_hdr>(), + 1usize, + concat!("Alignment of ", stringify!(arp_hdr)) + ); + assert_eq!( + unsafe { &(*(0 as *const arp_hdr)).arp_hrd as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(arp_hdr), + "::", + stringify!(arp_hrd) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const arp_hdr)).arp_pro as *const _ as usize }, + 2usize, + concat!( + "Alignment of field: ", + stringify!(arp_hdr), + "::", + stringify!(arp_pro) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const arp_hdr)).arp_hln as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(arp_hdr), + "::", + stringify!(arp_hln) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const arp_hdr)).arp_pln as *const _ as usize }, + 5usize, + concat!( + "Alignment of field: ", + stringify!(arp_hdr), + "::", + stringify!(arp_pln) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const arp_hdr)).arp_op as *const _ as usize }, + 6usize, + concat!( + "Alignment of field: ", + stringify!(arp_hdr), + "::", + stringify!(arp_op) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const arp_hdr)).arp_data as *const _ as usize }, + 8usize, + concat!( + "Alignment of field: ", + stringify!(arp_hdr), + "::", + stringify!(arp_data) + ) + ); } impl Clone for arp_hdr { - 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 6cfd85a4..53c6d8c3 100644 --- a/tests/expectations/tests/layout_array_too_long.rs +++ b/tests/expectations/tests/layout_array_too_long.rs @@ -301,9 +301,9 @@ impl Default for ip_frag_pkt { } 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 + 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 diff --git a/tests/expectations/tests/layout_kni_mbuf.rs b/tests/expectations/tests/layout_kni_mbuf.rs index 72552bea..facc85b2 100644 --- a/tests/expectations/tests/layout_kni_mbuf.rs +++ b/tests/expectations/tests/layout_kni_mbuf.rs @@ -33,82 +33,159 @@ pub struct rte_kni_mbuf { } #[test] fn bindgen_test_layout_rte_kni_mbuf() { - assert_eq!(::std::mem::size_of::<rte_kni_mbuf>() , 128usize , concat ! ( - "Size of: " , stringify ! ( rte_kni_mbuf ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . buf_addr as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( buf_addr ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . buf_physaddr as * - const _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( buf_physaddr ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . pad0 as * const _ as - usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( pad0 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . data_off as * const _ - as usize } , 18usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( data_off ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . pad1 as * const _ as - usize } , 20usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( pad1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . nb_segs as * const _ - as usize } , 22usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( nb_segs ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . pad4 as * const _ as - usize } , 23usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( pad4 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . ol_flags as * const _ - as usize } , 24usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( ol_flags ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . pad2 as * const _ as - usize } , 32usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( pad2 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . pkt_len as * const _ - as usize } , 36usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( pkt_len ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . data_len as * const _ - as usize } , 40usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( data_len ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . pad3 as * const _ as - usize } , 64usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( pad3 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . pool as * const _ as - usize } , 72usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( pool ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . next as * const _ as - usize } , 80usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( next ) )); + assert_eq!( + ::std::mem::size_of::<rte_kni_mbuf>(), + 128usize, + concat!("Size of: ", stringify!(rte_kni_mbuf)) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_kni_mbuf)).buf_addr as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(buf_addr) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_kni_mbuf)).buf_physaddr as *const _ as usize }, + 8usize, + concat!( + "Alignment of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(buf_physaddr) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_kni_mbuf)).pad0 as *const _ as usize }, + 16usize, + concat!( + "Alignment of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(pad0) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_kni_mbuf)).data_off as *const _ as usize }, + 18usize, + concat!( + "Alignment of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(data_off) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_kni_mbuf)).pad1 as *const _ as usize }, + 20usize, + concat!( + "Alignment of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(pad1) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_kni_mbuf)).nb_segs as *const _ as usize }, + 22usize, + concat!( + "Alignment of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(nb_segs) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_kni_mbuf)).pad4 as *const _ as usize }, + 23usize, + concat!( + "Alignment of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(pad4) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_kni_mbuf)).ol_flags as *const _ as usize }, + 24usize, + concat!( + "Alignment of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(ol_flags) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_kni_mbuf)).pad2 as *const _ as usize }, + 32usize, + concat!( + "Alignment of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(pad2) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_kni_mbuf)).pkt_len as *const _ as usize }, + 36usize, + concat!( + "Alignment of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(pkt_len) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_kni_mbuf)).data_len as *const _ as usize }, + 40usize, + concat!( + "Alignment of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(data_len) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_kni_mbuf)).pad3 as *const _ as usize }, + 64usize, + concat!( + "Alignment of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(pad3) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_kni_mbuf)).pool as *const _ as usize }, + 72usize, + concat!( + "Alignment of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(pool) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_kni_mbuf)).next as *const _ as usize }, + 80usize, + concat!( + "Alignment of field: ", + stringify!(rte_kni_mbuf), + "::", + stringify!(next) + ) + ); } impl Clone for rte_kni_mbuf { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for rte_kni_mbuf { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/layout_large_align_field.rs b/tests/expectations/tests/layout_large_align_field.rs index 0d86acda..7c8ab865 100644 --- a/tests/expectations/tests/layout_large_align_field.rs +++ b/tests/expectations/tests/layout_large_align_field.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,16 +29,18 @@ 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> {} pub const RTE_CACHE_LINE_SIZE: ::std::os::raw::c_uint = 64; pub const RTE_LIBRTE_IP_FRAG_MAX_FRAG: ::std::os::raw::c_uint = 4; pub const IP_LAST_FRAG_IDX: _bindgen_ty_1 = _bindgen_ty_1::IP_LAST_FRAG_IDX; @@ -64,31 +68,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)] @@ -103,28 +132,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. @@ -155,77 +207,134 @@ 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() } + } } #[repr(C)] #[derive(Debug, Copy)] @@ -235,26 +344,46 @@ pub struct ip_pkt_list { } #[test] fn bindgen_test_layout_ip_pkt_list() { - assert_eq!(::std::mem::size_of::<ip_pkt_list>() , 16usize , concat ! ( - "Size of: " , stringify ! ( ip_pkt_list ) )); - assert_eq! (::std::mem::align_of::<ip_pkt_list>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( ip_pkt_list ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_pkt_list ) ) . tqh_first as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_pkt_list ) , "::" , - stringify ! ( tqh_first ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_pkt_list ) ) . tqh_last as * const _ - as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_pkt_list ) , "::" , - stringify ! ( tqh_last ) )); + assert_eq!( + ::std::mem::size_of::<ip_pkt_list>(), + 16usize, + concat!("Size of: ", stringify!(ip_pkt_list)) + ); + assert_eq!( + ::std::mem::align_of::<ip_pkt_list>(), + 8usize, + concat!("Alignment of ", stringify!(ip_pkt_list)) + ); + assert_eq!( + unsafe { &(*(0 as *const ip_pkt_list)).tqh_first as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(ip_pkt_list), + "::", + stringify!(tqh_first) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const ip_pkt_list)).tqh_last as *const _ as usize }, + 8usize, + concat!( + "Alignment of field: ", + stringify!(ip_pkt_list), + "::", + stringify!(tqh_last) + ) + ); } impl Clone for ip_pkt_list { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for ip_pkt_list { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } /// fragmentation table statistics #[repr(C)] @@ -276,44 +405,81 @@ pub struct ip_frag_tbl_stat { } #[test] fn bindgen_test_layout_ip_frag_tbl_stat() { - assert_eq!(::std::mem::size_of::<ip_frag_tbl_stat>() , 64usize , concat ! - ( "Size of: " , stringify ! ( ip_frag_tbl_stat ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_tbl_stat ) ) . find_num as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_tbl_stat ) , - "::" , stringify ! ( find_num ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_tbl_stat ) ) . add_num as * const - _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_tbl_stat ) , - "::" , stringify ! ( add_num ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_tbl_stat ) ) . del_num as * const - _ as usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_tbl_stat ) , - "::" , stringify ! ( del_num ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_tbl_stat ) ) . reuse_num as * - const _ as usize } , 24usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_tbl_stat ) , - "::" , stringify ! ( reuse_num ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_tbl_stat ) ) . fail_total as * - const _ as usize } , 32usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_tbl_stat ) , - "::" , stringify ! ( fail_total ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_tbl_stat ) ) . fail_nospace as * - const _ as usize } , 40usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_tbl_stat ) , - "::" , stringify ! ( fail_nospace ) )); + assert_eq!( + ::std::mem::size_of::<ip_frag_tbl_stat>(), + 64usize, + concat!("Size of: ", stringify!(ip_frag_tbl_stat)) + ); + assert_eq!( + unsafe { &(*(0 as *const ip_frag_tbl_stat)).find_num as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(ip_frag_tbl_stat), + "::", + stringify!(find_num) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const ip_frag_tbl_stat)).add_num as *const _ as usize }, + 8usize, + concat!( + "Alignment of field: ", + stringify!(ip_frag_tbl_stat), + "::", + stringify!(add_num) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const ip_frag_tbl_stat)).del_num as *const _ as usize }, + 16usize, + concat!( + "Alignment of field: ", + stringify!(ip_frag_tbl_stat), + "::", + stringify!(del_num) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const ip_frag_tbl_stat)).reuse_num as *const _ as usize }, + 24usize, + concat!( + "Alignment of field: ", + stringify!(ip_frag_tbl_stat), + "::", + stringify!(reuse_num) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const ip_frag_tbl_stat)).fail_total as *const _ as usize }, + 32usize, + concat!( + "Alignment of field: ", + stringify!(ip_frag_tbl_stat), + "::", + stringify!(fail_total) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const ip_frag_tbl_stat)).fail_nospace as *const _ as usize }, + 40usize, + concat!( + "Alignment of field: ", + stringify!(ip_frag_tbl_stat), + "::", + stringify!(fail_nospace) + ) + ); } impl Clone for ip_frag_tbl_stat { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for ip_frag_tbl_stat { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } /// fragmentation table #[repr(C)] @@ -344,66 +510,126 @@ pub struct rte_ip_frag_tbl { } #[test] fn bindgen_test_layout_rte_ip_frag_tbl() { - assert_eq!(::std::mem::size_of::<rte_ip_frag_tbl>() , 128usize , concat ! - ( "Size of: " , stringify ! ( rte_ip_frag_tbl ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ip_frag_tbl ) ) . max_cycles as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , - "::" , stringify ! ( max_cycles ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ip_frag_tbl ) ) . entry_mask as * - const _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , - "::" , stringify ! ( entry_mask ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ip_frag_tbl ) ) . max_entries as * - const _ as usize } , 12usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , - "::" , stringify ! ( max_entries ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ip_frag_tbl ) ) . use_entries as * - const _ as usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , - "::" , stringify ! ( use_entries ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ip_frag_tbl ) ) . bucket_entries as * - const _ as usize } , 20usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , - "::" , stringify ! ( bucket_entries ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ip_frag_tbl ) ) . nb_entries as * - const _ as usize } , 24usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , - "::" , stringify ! ( nb_entries ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ip_frag_tbl ) ) . nb_buckets as * - const _ as usize } , 28usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , - "::" , stringify ! ( nb_buckets ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ip_frag_tbl ) ) . last as * const _ - as usize } , 32usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , - "::" , stringify ! ( last ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ip_frag_tbl ) ) . lru as * const _ as - usize } , 40usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , - "::" , stringify ! ( lru ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ip_frag_tbl ) ) . stat as * const _ - as usize } , 64usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , - "::" , stringify ! ( stat ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ip_frag_tbl ) ) . pkt as * const _ as - usize } , 128usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , - "::" , stringify ! ( pkt ) )); + assert_eq!( + ::std::mem::size_of::<rte_ip_frag_tbl>(), + 128usize, + concat!("Size of: ", stringify!(rte_ip_frag_tbl)) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_ip_frag_tbl)).max_cycles as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(rte_ip_frag_tbl), + "::", + stringify!(max_cycles) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_ip_frag_tbl)).entry_mask as *const _ as usize }, + 8usize, + concat!( + "Alignment of field: ", + stringify!(rte_ip_frag_tbl), + "::", + stringify!(entry_mask) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_ip_frag_tbl)).max_entries as *const _ as usize }, + 12usize, + concat!( + "Alignment of field: ", + stringify!(rte_ip_frag_tbl), + "::", + stringify!(max_entries) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_ip_frag_tbl)).use_entries as *const _ as usize }, + 16usize, + concat!( + "Alignment of field: ", + stringify!(rte_ip_frag_tbl), + "::", + stringify!(use_entries) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_ip_frag_tbl)).bucket_entries as *const _ as usize }, + 20usize, + concat!( + "Alignment of field: ", + stringify!(rte_ip_frag_tbl), + "::", + stringify!(bucket_entries) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_ip_frag_tbl)).nb_entries as *const _ as usize }, + 24usize, + concat!( + "Alignment of field: ", + stringify!(rte_ip_frag_tbl), + "::", + stringify!(nb_entries) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_ip_frag_tbl)).nb_buckets as *const _ as usize }, + 28usize, + concat!( + "Alignment of field: ", + stringify!(rte_ip_frag_tbl), + "::", + stringify!(nb_buckets) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_ip_frag_tbl)).last as *const _ as usize }, + 32usize, + concat!( + "Alignment of field: ", + stringify!(rte_ip_frag_tbl), + "::", + stringify!(last) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_ip_frag_tbl)).lru as *const _ as usize }, + 40usize, + concat!( + "Alignment of field: ", + stringify!(rte_ip_frag_tbl), + "::", + stringify!(lru) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_ip_frag_tbl)).stat as *const _ as usize }, + 64usize, + concat!( + "Alignment of field: ", + stringify!(rte_ip_frag_tbl), + "::", + stringify!(stat) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const rte_ip_frag_tbl)).pkt as *const _ as usize }, + 128usize, + concat!( + "Alignment of field: ", + stringify!(rte_ip_frag_tbl), + "::", + stringify!(pkt) + ) + ); } impl Default for rte_ip_frag_tbl { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } /// < fragment mbuf #[repr(C)] @@ -412,5 +638,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/mangling-linux32.rs b/tests/expectations/tests/mangling-linux32.rs index 96186774..e237eeef 100644 --- a/tests/expectations/tests/mangling-linux32.rs +++ b/tests/expectations/tests/mangling-linux32.rs @@ -18,11 +18,19 @@ extern "C" { } #[test] fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::<Foo>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::<Foo>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::<Foo>(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::<Foo>(), + 1usize, + concat!("Alignment of ", stringify!(Foo)) + ); } impl Clone for Foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/mangling-linux64.rs b/tests/expectations/tests/mangling-linux64.rs index 96186774..e237eeef 100644 --- a/tests/expectations/tests/mangling-linux64.rs +++ b/tests/expectations/tests/mangling-linux64.rs @@ -18,11 +18,19 @@ extern "C" { } #[test] fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::<Foo>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::<Foo>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::<Foo>(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::<Foo>(), + 1usize, + concat!("Alignment of ", stringify!(Foo)) + ); } impl Clone for Foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/mangling-macos.rs b/tests/expectations/tests/mangling-macos.rs index 6f758141..39a020ad 100644 --- a/tests/expectations/tests/mangling-macos.rs +++ b/tests/expectations/tests/mangling-macos.rs @@ -19,11 +19,19 @@ extern "C" { } #[test] fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::<Foo>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::<Foo>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::<Foo>(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::<Foo>(), + 1usize, + concat!("Alignment of ", stringify!(Foo)) + ); } impl Clone for Foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/mangling-win64.rs b/tests/expectations/tests/mangling-win64.rs index ffaf52cf..747ccbf5 100644 --- a/tests/expectations/tests/mangling-win64.rs +++ b/tests/expectations/tests/mangling-win64.rs @@ -18,11 +18,19 @@ extern "C" { } #[test] fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::<Foo>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::<Foo>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::<Foo>(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::<Foo>(), + 1usize, + concat!("Alignment of ", stringify!(Foo)) + ); } impl Clone for Foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/method-mangling.rs b/tests/expectations/tests/method-mangling.rs index e44b6e7d..eada760b 100644 --- a/tests/expectations/tests/method-mangling.rs +++ b/tests/expectations/tests/method-mangling.rs @@ -11,19 +11,29 @@ pub struct Foo { } #[test] fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::<Foo>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::<Foo>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::<Foo>(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::<Foo>(), + 1usize, + concat!("Alignment of ", stringify!(Foo)) + ); } extern "C" { #[link_name = "\u{1}_ZN3Foo4typeEv"] pub fn Foo_type(this: *mut Foo) -> ::std::os::raw::c_int; } impl Clone for Foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Foo { #[inline] - pub unsafe fn type_(&mut self) -> ::std::os::raw::c_int { Foo_type(self) } + pub unsafe fn type_(&mut self) -> ::std::os::raw::c_int { + Foo_type(self) + } } diff --git a/tests/expectations/tests/module-whitelisted.rs b/tests/expectations/tests/module-whitelisted.rs index ad2c92fc..0e1d5641 100644 --- a/tests/expectations/tests/module-whitelisted.rs +++ b/tests/expectations/tests/module-whitelisted.rs @@ -15,12 +15,20 @@ pub mod root { } #[test] fn bindgen_test_layout_Test() { - assert_eq!(::std::mem::size_of::<Test>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Test ) )); - assert_eq! (::std::mem::align_of::<Test>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Test ) )); + assert_eq!( + ::std::mem::size_of::<Test>(), + 1usize, + concat!("Size of: ", stringify!(Test)) + ); + assert_eq!( + ::std::mem::align_of::<Test>(), + 1usize, + concat!("Alignment of ", stringify!(Test)) + ); } impl Clone for Test { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } } diff --git a/tests/expectations/tests/msvc-no-usr.rs b/tests/expectations/tests/msvc-no-usr.rs index 589f8995..848c656f 100644 --- a/tests/expectations/tests/msvc-no-usr.rs +++ b/tests/expectations/tests/msvc-no-usr.rs @@ -11,16 +11,24 @@ pub struct A { } #[test] fn bindgen_test_layout_A() { - assert_eq!(::std::mem::size_of::<A>() , 8usize , concat ! ( - "Size of: " , stringify ! ( A ) )); - assert_eq! (::std::mem::align_of::<A>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( A ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const A ) ) . foo as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( A ) , "::" , stringify - ! ( foo ) )); + assert_eq!( + ::std::mem::size_of::<A>(), + 8usize, + concat!("Size of: ", stringify!(A)) + ); + assert_eq!( + ::std::mem::align_of::<A>(), + 8usize, + concat!("Alignment of ", stringify!(A)) + ); + assert_eq!( + unsafe { &(*(0 as *const A)).foo as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(A), "::", stringify!(foo)) + ); } impl Clone for A { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/multiple-inherit-empty-correct-layout.rs b/tests/expectations/tests/multiple-inherit-empty-correct-layout.rs index 06f1df50..2af91b4c 100644 --- a/tests/expectations/tests/multiple-inherit-empty-correct-layout.rs +++ b/tests/expectations/tests/multiple-inherit-empty-correct-layout.rs @@ -11,13 +11,21 @@ pub struct Foo { } #[test] fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::<Foo>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::<Foo>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::<Foo>(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::<Foo>(), + 1usize, + concat!("Alignment of ", stringify!(Foo)) + ); } impl Clone for Foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy)] @@ -26,13 +34,21 @@ pub struct Bar { } #[test] fn bindgen_test_layout_Bar() { - assert_eq!(::std::mem::size_of::<Bar>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::<Bar>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Bar ) )); + assert_eq!( + ::std::mem::size_of::<Bar>(), + 1usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::<Bar>(), + 1usize, + concat!("Alignment of ", stringify!(Bar)) + ); } impl Clone for Bar { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy)] @@ -41,11 +57,19 @@ pub struct Baz { } #[test] fn bindgen_test_layout_Baz() { - assert_eq!(::std::mem::size_of::<Baz>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Baz ) )); - assert_eq! (::std::mem::align_of::<Baz>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Baz ) )); + assert_eq!( + ::std::mem::size_of::<Baz>(), + 1usize, + concat!("Size of: ", stringify!(Baz)) + ); + assert_eq!( + ::std::mem::align_of::<Baz>(), + 1usize, + concat!("Alignment of ", stringify!(Baz)) + ); } impl Clone for Baz { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/mutable.rs b/tests/expectations/tests/mutable.rs index 9c986137..f7f580b2 100644 --- a/tests/expectations/tests/mutable.rs +++ b/tests/expectations/tests/mutable.rs @@ -12,23 +12,41 @@ pub struct C { } #[test] fn bindgen_test_layout_C() { - assert_eq!(::std::mem::size_of::<C>() , 8usize , 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 ) ) . m_member as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( m_member ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C ) ) . m_other as * const _ as usize } , - 4usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( m_other ) )); + assert_eq!( + ::std::mem::size_of::<C>(), + 8usize, + 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)).m_member as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(C), + "::", + stringify!(m_member) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const C)).m_other as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(C), + "::", + stringify!(m_other) + ) + ); } impl Clone for C { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default)] @@ -37,15 +55,26 @@ pub struct NonCopiable { } #[test] fn bindgen_test_layout_NonCopiable() { - assert_eq!(::std::mem::size_of::<NonCopiable>() , 4usize , concat ! ( - "Size of: " , stringify ! ( NonCopiable ) )); - assert_eq! (::std::mem::align_of::<NonCopiable>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( NonCopiable ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const NonCopiable ) ) . m_member as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( NonCopiable ) , "::" , - stringify ! ( m_member ) )); + assert_eq!( + ::std::mem::size_of::<NonCopiable>(), + 4usize, + concat!("Size of: ", stringify!(NonCopiable)) + ); + assert_eq!( + ::std::mem::align_of::<NonCopiable>(), + 4usize, + concat!("Alignment of ", stringify!(NonCopiable)) + ); + assert_eq!( + unsafe { &(*(0 as *const NonCopiable)).m_member as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(NonCopiable), + "::", + stringify!(m_member) + ) + ); } #[repr(C)] #[derive(Debug, Default)] @@ -54,18 +83,32 @@ pub struct NonCopiableWithNonCopiableMutableMember { } #[test] fn bindgen_test_layout_NonCopiableWithNonCopiableMutableMember() { - assert_eq!(::std::mem::size_of::<NonCopiableWithNonCopiableMutableMember>() - , 4usize , concat ! ( - "Size of: " , stringify ! ( - NonCopiableWithNonCopiableMutableMember ) )); - assert_eq! (::std::mem::align_of::<NonCopiableWithNonCopiableMutableMember>() - , 4usize , concat ! ( - "Alignment of " , stringify ! ( - NonCopiableWithNonCopiableMutableMember ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const NonCopiableWithNonCopiableMutableMember ) - ) . m_member as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - NonCopiableWithNonCopiableMutableMember ) , "::" , stringify ! - ( m_member ) )); + assert_eq!( + ::std::mem::size_of::<NonCopiableWithNonCopiableMutableMember>(), + 4usize, + concat!( + "Size of: ", + stringify!(NonCopiableWithNonCopiableMutableMember) + ) + ); + assert_eq!( + ::std::mem::align_of::<NonCopiableWithNonCopiableMutableMember>(), + 4usize, + concat!( + "Alignment of ", + stringify!(NonCopiableWithNonCopiableMutableMember) + ) + ); + assert_eq!( + unsafe { + &(*(0 as *const NonCopiableWithNonCopiableMutableMember)).m_member as *const _ as usize + }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(NonCopiableWithNonCopiableMutableMember), + "::", + stringify!(m_member) + ) + ); } diff --git a/tests/expectations/tests/namespace.rs b/tests/expectations/tests/namespace.rs index 6349748d..e6077152 100644 --- a/tests/expectations/tests/namespace.rs +++ b/tests/expectations/tests/namespace.rs @@ -9,7 +9,7 @@ pub mod root { #[allow(unused_imports)] use self::super::root; extern "C" { - #[link_name = "\u{1}_Z9top_levelv"] + #[link_name = "\u{1}_Z9top_levelv"] pub fn top_level(); } pub mod whatever { @@ -17,7 +17,7 @@ pub mod root { use self::super::super::root; pub type whatever_int_t = ::std::os::raw::c_int; extern "C" { - #[link_name = "\u{1}_ZN8whatever11in_whateverEv"] + #[link_name = "\u{1}_ZN8whatever11in_whateverEv"] pub fn in_whatever(); } } @@ -25,7 +25,7 @@ pub mod root { #[allow(unused_imports)] use self::super::super::root; extern "C" { - #[link_name = "\u{1}_ZN12_GLOBAL__N_13fooEv"] + #[link_name = "\u{1}_ZN12_GLOBAL__N_13fooEv"] pub fn foo(); } #[repr(C)] @@ -52,7 +52,7 @@ pub mod root { ); } extern "C" { - #[link_name = "\u{1}_ZN12_GLOBAL__N_11A20lets_hope_this_worksEv"] + #[link_name = "\u{1}_ZN12_GLOBAL__N_11A20lets_hope_this_worksEv"] pub fn A_lets_hope_this_works( this: *mut root::_bindgen_mod_id_13::A, ) -> ::std::os::raw::c_int; @@ -99,15 +99,15 @@ pub mod root { } } extern "C" { - #[link_name = "\u{1}_ZN1w3hehEv"] + #[link_name = "\u{1}_ZN1w3hehEv"] pub fn heh() -> root::w::whatever_int_t; } extern "C" { - #[link_name = "\u{1}_ZN1w3fooEv"] + #[link_name = "\u{1}_ZN1w3fooEv"] pub fn foo() -> root::C<::std::os::raw::c_int>; } extern "C" { - #[link_name = "\u{1}_ZN1w4barrEv"] + #[link_name = "\u{1}_ZN1w4barrEv"] pub fn barr() -> root::C<f32>; } } diff --git a/tests/expectations/tests/nested.rs b/tests/expectations/tests/nested.rs index 929732f6..a8c7775c 100644 --- a/tests/expectations/tests/nested.rs +++ b/tests/expectations/tests/nested.rs @@ -11,18 +11,31 @@ pub struct Calc { } #[test] fn bindgen_test_layout_Calc() { - assert_eq!(::std::mem::size_of::<Calc>() , 4usize , concat ! ( - "Size of: " , stringify ! ( Calc ) )); - assert_eq! (::std::mem::align_of::<Calc>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Calc ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Calc ) ) . w as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Calc ) , "::" , - stringify ! ( w ) )); + assert_eq!( + ::std::mem::size_of::<Calc>(), + 4usize, + concat!("Size of: ", stringify!(Calc)) + ); + assert_eq!( + ::std::mem::align_of::<Calc>(), + 4usize, + concat!("Alignment of ", stringify!(Calc)) + ); + assert_eq!( + unsafe { &(*(0 as *const Calc)).w as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Calc), + "::", + stringify!(w) + ) + ); } impl Clone for Calc { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy)] @@ -42,42 +55,75 @@ pub struct Test_Size_Dimension { } #[test] fn bindgen_test_layout_Test_Size_Dimension() { - assert_eq!(::std::mem::size_of::<Test_Size_Dimension>() , 4usize , concat - ! ( "Size of: " , stringify ! ( Test_Size_Dimension ) )); - assert_eq! (::std::mem::align_of::<Test_Size_Dimension>() , 4usize , - concat ! ( - "Alignment of " , stringify ! ( Test_Size_Dimension ) )); + assert_eq!( + ::std::mem::size_of::<Test_Size_Dimension>(), + 4usize, + concat!("Size of: ", stringify!(Test_Size_Dimension)) + ); + assert_eq!( + ::std::mem::align_of::<Test_Size_Dimension>(), + 4usize, + concat!("Alignment of ", stringify!(Test_Size_Dimension)) + ); } impl Clone for Test_Size_Dimension { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_Test_Size() { - assert_eq!(::std::mem::size_of::<Test_Size>() , 8usize , concat ! ( - "Size of: " , stringify ! ( Test_Size ) )); - assert_eq! (::std::mem::align_of::<Test_Size>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Test_Size ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test_Size ) ) . mWidth as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Test_Size ) , "::" , - stringify ! ( mWidth ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test_Size ) ) . mHeight as * const _ as - usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( Test_Size ) , "::" , - stringify ! ( mHeight ) )); + assert_eq!( + ::std::mem::size_of::<Test_Size>(), + 8usize, + concat!("Size of: ", stringify!(Test_Size)) + ); + assert_eq!( + ::std::mem::align_of::<Test_Size>(), + 4usize, + concat!("Alignment of ", stringify!(Test_Size)) + ); + assert_eq!( + unsafe { &(*(0 as *const Test_Size)).mWidth as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Test_Size), + "::", + stringify!(mWidth) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Test_Size)).mHeight as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(Test_Size), + "::", + stringify!(mHeight) + ) + ); } impl Clone for Test_Size { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_Test() { - assert_eq!(::std::mem::size_of::<Test>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Test ) )); - assert_eq! (::std::mem::align_of::<Test>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Test ) )); + assert_eq!( + ::std::mem::size_of::<Test>(), + 1usize, + concat!("Size of: ", stringify!(Test)) + ); + assert_eq!( + ::std::mem::align_of::<Test>(), + 1usize, + concat!("Alignment of ", stringify!(Test)) + ); } impl Clone for Test { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/nested_vtable.rs b/tests/expectations/tests/nested_vtable.rs index d6579ec2..0da5289e 100644 --- a/tests/expectations/tests/nested_vtable.rs +++ b/tests/expectations/tests/nested_vtable.rs @@ -13,21 +13,30 @@ pub struct nsISupports { } #[test] fn bindgen_test_layout_nsISupports() { - assert_eq!(::std::mem::size_of::<nsISupports>() , 8usize , concat ! ( - "Size of: " , stringify ! ( nsISupports ) )); - assert_eq! (::std::mem::align_of::<nsISupports>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( nsISupports ) )); + assert_eq!( + ::std::mem::size_of::<nsISupports>(), + 8usize, + concat!("Size of: ", stringify!(nsISupports)) + ); + assert_eq!( + ::std::mem::align_of::<nsISupports>(), + 8usize, + concat!("Alignment of ", stringify!(nsISupports)) + ); } impl Clone for nsISupports { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for nsISupports { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } extern "C" { #[link_name = "\u{1}_ZN11nsISupports14QueryInterfaceEv"] - pub fn nsISupports_QueryInterface(this: *mut ::std::os::raw::c_void) - -> *mut nsISupports; + pub fn nsISupports_QueryInterface(this: *mut ::std::os::raw::c_void) -> *mut nsISupports; } #[repr(C)] #[derive(Debug, Copy)] @@ -36,16 +45,26 @@ pub struct nsIRunnable { } #[test] fn bindgen_test_layout_nsIRunnable() { - assert_eq!(::std::mem::size_of::<nsIRunnable>() , 8usize , concat ! ( - "Size of: " , stringify ! ( nsIRunnable ) )); - assert_eq! (::std::mem::align_of::<nsIRunnable>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( nsIRunnable ) )); + assert_eq!( + ::std::mem::size_of::<nsIRunnable>(), + 8usize, + concat!("Size of: ", stringify!(nsIRunnable)) + ); + assert_eq!( + ::std::mem::align_of::<nsIRunnable>(), + 8usize, + concat!("Alignment of ", stringify!(nsIRunnable)) + ); } impl Clone for nsIRunnable { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for nsIRunnable { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Copy)] @@ -54,14 +73,24 @@ pub struct Runnable { } #[test] fn bindgen_test_layout_Runnable() { - assert_eq!(::std::mem::size_of::<Runnable>() , 8usize , concat ! ( - "Size of: " , stringify ! ( Runnable ) )); - assert_eq! (::std::mem::align_of::<Runnable>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( Runnable ) )); + assert_eq!( + ::std::mem::size_of::<Runnable>(), + 8usize, + concat!("Size of: ", stringify!(Runnable)) + ); + assert_eq!( + ::std::mem::align_of::<Runnable>(), + 8usize, + concat!("Alignment of ", stringify!(Runnable)) + ); } impl Clone for Runnable { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for Runnable { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/nested_within_namespace.rs b/tests/expectations/tests/nested_within_namespace.rs index 8021b831..d291a537 100644 --- a/tests/expectations/tests/nested_within_namespace.rs +++ b/tests/expectations/tests/nested_within_namespace.rs @@ -23,33 +23,59 @@ pub mod root { } #[test] fn bindgen_test_layout_Bar_Baz() { - assert_eq!(::std::mem::size_of::<Bar_Baz>() , 4usize , concat ! ( - "Size of: " , stringify ! ( Bar_Baz ) )); - assert_eq! (::std::mem::align_of::<Bar_Baz>() , 4usize , concat ! - ( "Alignment of " , stringify ! ( Bar_Baz ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Bar_Baz ) ) . foo as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Bar_Baz ) , - "::" , stringify ! ( foo ) )); + assert_eq!( + ::std::mem::size_of::<Bar_Baz>(), + 4usize, + concat!("Size of: ", stringify!(Bar_Baz)) + ); + assert_eq!( + ::std::mem::align_of::<Bar_Baz>(), + 4usize, + concat!("Alignment of ", stringify!(Bar_Baz)) + ); + assert_eq!( + unsafe { &(*(0 as *const Bar_Baz)).foo as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Bar_Baz), + "::", + stringify!(foo) + ) + ); } impl Clone for Bar_Baz { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_Bar() { - assert_eq!(::std::mem::size_of::<Bar>() , 4usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::<Bar>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Bar ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Bar ) ) . foo as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Bar ) , "::" , - stringify ! ( foo ) )); + assert_eq!( + ::std::mem::size_of::<Bar>(), + 4usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::<Bar>(), + 4usize, + concat!("Alignment of ", stringify!(Bar)) + ); + assert_eq!( + unsafe { &(*(0 as *const Bar)).foo as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Bar), + "::", + stringify!(foo) + ) + ); } impl Clone for Bar { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy)] @@ -58,18 +84,31 @@ pub mod root { } #[test] fn bindgen_test_layout_Baz() { - assert_eq!(::std::mem::size_of::<Baz>() , 4usize , concat ! ( - "Size of: " , stringify ! ( Baz ) )); - assert_eq! (::std::mem::align_of::<Baz>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Baz ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Baz ) ) . baz as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Baz ) , "::" , - stringify ! ( baz ) )); + assert_eq!( + ::std::mem::size_of::<Baz>(), + 4usize, + concat!("Size of: ", stringify!(Baz)) + ); + assert_eq!( + ::std::mem::align_of::<Baz>(), + 4usize, + concat!("Alignment of ", stringify!(Baz)) + ); + assert_eq!( + unsafe { &(*(0 as *const Baz)).baz as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Baz), + "::", + stringify!(baz) + ) + ); } impl Clone for Baz { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } } } diff --git a/tests/expectations/tests/no-comments.rs b/tests/expectations/tests/no-comments.rs index e67b156b..b097acd6 100644 --- a/tests/expectations/tests/no-comments.rs +++ b/tests/expectations/tests/no-comments.rs @@ -11,16 +11,24 @@ pub struct Foo { } #[test] fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::<Foo>() , 4usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::<Foo>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Foo ) ) . s as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Foo ) , "::" , - stringify ! ( s ) )); + assert_eq!( + ::std::mem::size_of::<Foo>(), + 4usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::<Foo>(), + 4usize, + concat!("Alignment of ", stringify!(Foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const Foo)).s as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(Foo), "::", stringify!(s)) + ); } impl Clone for Foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/no-recursive-whitelisting.rs b/tests/expectations/tests/no-recursive-whitelisting.rs index 30dc9e69..3901339a 100644 --- a/tests/expectations/tests/no-recursive-whitelisting.rs +++ b/tests/expectations/tests/no-recursive-whitelisting.rs @@ -11,16 +11,29 @@ pub struct Foo { } #[test] fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::<Foo>() , 8usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::<Foo>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Foo ) ) . baz as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Foo ) , "::" , - stringify ! ( baz ) )); + assert_eq!( + ::std::mem::size_of::<Foo>(), + 8usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::<Foo>(), + 8usize, + concat!("Alignment of ", stringify!(Foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const Foo)).baz as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Foo), + "::", + stringify!(baz) + ) + ); } impl Default for Foo { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/no-std.rs b/tests/expectations/tests/no-std.rs index 41b3b184..252b51ff 100644 --- a/tests/expectations/tests/no-std.rs +++ b/tests/expectations/tests/no-std.rs @@ -2,9 +2,11 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - #![no_std] -mod libc { pub type c_int = i32; pub enum c_void {} } +mod libc { + pub type c_int = i32; + pub enum c_void {} +} #[repr(C)] #[derive(Debug, Copy)] @@ -15,29 +17,44 @@ pub struct foo { } #[test] fn bindgen_test_layout_foo() { - assert_eq!(::core::mem::size_of::<foo>() , 16usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::core::mem::align_of::<foo>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . b as * const _ as usize } , - 4usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( b ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , - 8usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bar ) )); + assert_eq!( + ::core::mem::size_of::<foo>(), + 16usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::core::mem::align_of::<foo>(), + 8usize, + concat!("Alignment of ", stringify!(foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).a as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(foo), "::", stringify!(a)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).b as *const _ as usize }, + 4usize, + concat!("Alignment of field: ", stringify!(foo), "::", stringify!(b)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).bar as *const _ as usize }, + 8usize, + concat!( + "Alignment of field: ", + stringify!(foo), + "::", + stringify!(bar) + ) + ); } impl Clone for foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for foo { - fn default() -> Self { unsafe { ::core::mem::zeroed() } } + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } } diff --git a/tests/expectations/tests/non-type-params.rs b/tests/expectations/tests/non-type-params.rs index c367d806..4a6626a0 100644 --- a/tests/expectations/tests/non-type-params.rs +++ b/tests/expectations/tests/non-type-params.rs @@ -15,26 +15,49 @@ pub struct UsesArray { } #[test] fn bindgen_test_layout_UsesArray() { - assert_eq!(::std::mem::size_of::<UsesArray>() , 40usize , concat ! ( - "Size of: " , stringify ! ( UsesArray ) )); - assert_eq! (::std::mem::align_of::<UsesArray>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( UsesArray ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const UsesArray ) ) . array_char_16 as * const - _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( UsesArray ) , "::" , - stringify ! ( array_char_16 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const UsesArray ) ) . array_bool_8 as * const _ - as usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( UsesArray ) , "::" , - stringify ! ( array_bool_8 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const UsesArray ) ) . array_int_4 as * const _ - as usize } , 24usize , concat ! ( - "Alignment of field: " , stringify ! ( UsesArray ) , "::" , - stringify ! ( array_int_4 ) )); + assert_eq!( + ::std::mem::size_of::<UsesArray>(), + 40usize, + concat!("Size of: ", stringify!(UsesArray)) + ); + assert_eq!( + ::std::mem::align_of::<UsesArray>(), + 4usize, + concat!("Alignment of ", stringify!(UsesArray)) + ); + assert_eq!( + unsafe { &(*(0 as *const UsesArray)).array_char_16 as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(UsesArray), + "::", + stringify!(array_char_16) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const UsesArray)).array_bool_8 as *const _ as usize }, + 16usize, + concat!( + "Alignment of field: ", + stringify!(UsesArray), + "::", + stringify!(array_bool_8) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const UsesArray)).array_int_4 as *const _ as usize }, + 24usize, + concat!( + "Alignment of field: ", + stringify!(UsesArray), + "::", + stringify!(array_int_4) + ) + ); } impl Clone for UsesArray { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/nsStyleAutoArray.rs b/tests/expectations/tests/nsStyleAutoArray.rs index d9287e00..0c9f1ec6 100644 --- a/tests/expectations/tests/nsStyleAutoArray.rs +++ b/tests/expectations/tests/nsStyleAutoArray.rs @@ -10,8 +10,10 @@ pub struct nsTArray<T> { pub mBuff: *mut T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } -impl <T> Default for nsTArray<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for nsTArray<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -25,6 +27,8 @@ pub struct nsStyleAutoArray<T> { pub enum nsStyleAutoArray_WithSingleInitialElement { WITH_SINGLE_INITIAL_ELEMENT = 0, } -impl <T> Default for nsStyleAutoArray<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for nsStyleAutoArray<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/objc_category.rs b/tests/expectations/tests/objc_category.rs index 2f29adc9..ba37b819 100644 --- a/tests/expectations/tests/objc_category.rs +++ b/tests/expectations/tests/objc_category.rs @@ -2,8 +2,7 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - -#![cfg(target_os="macos")] +#![cfg(target_os = "macos")] #[macro_use] extern crate objc; @@ -13,11 +12,15 @@ pub trait Foo { unsafe fn method(self); } impl Foo for id { - unsafe fn method(self) { msg_send!(self , method) } + unsafe fn method(self) { + msg_send!(self, method) + } } pub trait Foo_BarCategory { unsafe fn categoryMethod(self); } impl Foo_BarCategory for id { - unsafe fn categoryMethod(self) { msg_send!(self , categoryMethod) } + unsafe fn categoryMethod(self) { + msg_send!(self, categoryMethod) + } } diff --git a/tests/expectations/tests/objc_class.rs b/tests/expectations/tests/objc_class.rs index 2f6f00c7..b5c15a0e 100644 --- a/tests/expectations/tests/objc_class.rs +++ b/tests/expectations/tests/objc_class.rs @@ -2,8 +2,7 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - -#![cfg(target_os="macos")] +#![cfg(target_os = "macos")] #[macro_use] extern crate objc; @@ -17,5 +16,7 @@ pub trait Foo { unsafe fn method(self); } impl Foo for id { - unsafe fn method(self) { msg_send!(self , method) } + unsafe fn method(self) { + msg_send!(self, method) + } } diff --git a/tests/expectations/tests/objc_interface.rs b/tests/expectations/tests/objc_interface.rs index 1108219d..e8c1278a 100644 --- a/tests/expectations/tests/objc_interface.rs +++ b/tests/expectations/tests/objc_interface.rs @@ -2,14 +2,13 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - -#![cfg(target_os="macos")] +#![cfg(target_os = "macos")] #[macro_use] extern crate objc; #[allow(non_camel_case_types)] pub type id = *mut objc::runtime::Object; -pub trait Foo { } -impl Foo for id { } -pub trait protocol_bar { } -impl protocol_bar for id { } +pub trait Foo {} +impl Foo for id {} +pub trait protocol_bar {} +impl protocol_bar for id {} diff --git a/tests/expectations/tests/objc_interface_type.rs b/tests/expectations/tests/objc_interface_type.rs index 0b3721ef..446e6384 100644 --- a/tests/expectations/tests/objc_interface_type.rs +++ b/tests/expectations/tests/objc_interface_type.rs @@ -2,15 +2,14 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - -#![cfg(target_os="macos")] +#![cfg(target_os = "macos")] #[macro_use] extern crate objc; #[allow(non_camel_case_types)] pub type id = *mut objc::runtime::Object; -pub trait Foo { } -impl Foo for id { } +pub trait Foo {} +impl Foo for id {} #[repr(C)] #[derive(Debug, Copy)] pub struct FooStruct { @@ -18,21 +17,36 @@ pub struct FooStruct { } #[test] fn bindgen_test_layout_FooStruct() { - assert_eq!(::std::mem::size_of::<FooStruct>() , 8usize , concat ! ( - "Size of: " , stringify ! ( FooStruct ) )); - assert_eq! (::std::mem::align_of::<FooStruct>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( FooStruct ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const FooStruct ) ) . foo as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( FooStruct ) , "::" , - stringify ! ( foo ) )); + assert_eq!( + ::std::mem::size_of::<FooStruct>(), + 8usize, + concat!("Size of: ", stringify!(FooStruct)) + ); + assert_eq!( + ::std::mem::align_of::<FooStruct>(), + 8usize, + concat!("Alignment of ", stringify!(FooStruct)) + ); + assert_eq!( + unsafe { &(*(0 as *const FooStruct)).foo as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(FooStruct), + "::", + stringify!(foo) + ) + ); } impl Clone for FooStruct { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for FooStruct { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } extern "C" { pub fn fooFunc(foo: id); diff --git a/tests/expectations/tests/objc_protocol.rs b/tests/expectations/tests/objc_protocol.rs index aa7e7291..33a81fa4 100644 --- a/tests/expectations/tests/objc_protocol.rs +++ b/tests/expectations/tests/objc_protocol.rs @@ -2,14 +2,13 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - -#![cfg(target_os="macos")] +#![cfg(target_os = "macos")] #[macro_use] extern crate objc; #[allow(non_camel_case_types)] pub type id = *mut objc::runtime::Object; -pub trait protocol_Foo { } -impl protocol_Foo for id { } -pub trait Foo { } -impl Foo for id { } +pub trait protocol_Foo {} +impl protocol_Foo for id {} +pub trait Foo {} +impl Foo for id {} diff --git a/tests/expectations/tests/objc_sel_and_id.rs b/tests/expectations/tests/objc_sel_and_id.rs index 9c05aca0..8802c206 100644 --- a/tests/expectations/tests/objc_sel_and_id.rs +++ b/tests/expectations/tests/objc_sel_and_id.rs @@ -2,8 +2,7 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - -#![cfg(target_os="macos")] +#![cfg(target_os = "macos")] #[macro_use] extern crate objc; diff --git a/tests/expectations/tests/objc_whitelist.rs b/tests/expectations/tests/objc_whitelist.rs index 4eba7c7f..38881ad0 100644 --- a/tests/expectations/tests/objc_whitelist.rs +++ b/tests/expectations/tests/objc_whitelist.rs @@ -1,8 +1,7 @@ /* 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)] #![cfg(target_os = "macos")] #[macro_use] @@ -19,8 +18,7 @@ impl protocol_SomeProtocol for id { } unsafe fn protocolClassMethod() { msg_send!( - objc::runtime::Class::get("SomeProtocol") - .expect("Couldn't find SomeProtocol"), + objc::runtime::Class::get("SomeProtocol").expect("Couldn't find SomeProtocol"), protocolClassMethod ) } @@ -35,8 +33,7 @@ impl WhitelistMe for id { } unsafe fn classMethod() { msg_send!( - objc::runtime::Class::get("WhitelistMe") - .expect("Couldn't find WhitelistMe"), + objc::runtime::Class::get("WhitelistMe").expect("Couldn't find WhitelistMe"), classMethod ) } diff --git a/tests/expectations/tests/opaque-template-instantiation-namespaced.rs b/tests/expectations/tests/opaque-template-instantiation-namespaced.rs index 09818446..e541e648 100644 --- a/tests/expectations/tests/opaque-template-instantiation-namespaced.rs +++ b/tests/expectations/tests/opaque-template-instantiation-namespaced.rs @@ -159,9 +159,16 @@ pub mod root { 1usize, concat!( "Size of template specialization: ", - stringify ! ( root :: zoidberg :: Template < root :: zoidberg :: Foo > ) + stringify!(root::zoidberg::Template<root::zoidberg::Foo>) + ) + ); + assert_eq!( + ::std::mem::align_of::<root::zoidberg::Template<root::zoidberg::Foo>>(), + 1usize, + concat!( + "Alignment of template specialization: ", + stringify!(root::zoidberg::Template<root::zoidberg::Foo>) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < root :: zoidberg :: Template < root :: zoidberg :: Foo > > ( ) , 1usize , concat ! ( "Alignment of template specialization: " , stringify ! ( root :: zoidberg :: Template < root :: zoidberg :: Foo > ) ) ); } } diff --git a/tests/expectations/tests/opaque-template-instantiation.rs b/tests/expectations/tests/opaque-template-instantiation.rs index 480dba48..779c32a6 100644 --- a/tests/expectations/tests/opaque-template-instantiation.rs +++ b/tests/expectations/tests/opaque-template-instantiation.rs @@ -93,8 +93,15 @@ fn __bindgen_test_layout_Template_open0_char_close0_instantiation() { 1usize, concat!( "Size of template specialization: ", - stringify ! ( Template < :: std :: os :: raw :: c_char > ) + stringify!(Template<::std::os::raw::c_char>) + ) + ); + assert_eq!( + ::std::mem::align_of::<Template<::std::os::raw::c_char>>(), + 1usize, + concat!( + "Alignment of template specialization: ", + stringify!(Template<::std::os::raw::c_char>) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < Template < :: std :: os :: raw :: c_char > > ( ) , 1usize , concat ! ( "Alignment of template specialization: " , stringify ! ( Template < :: std :: os :: raw :: c_char > ) ) ); } diff --git a/tests/expectations/tests/opaque-tracing.rs b/tests/expectations/tests/opaque-tracing.rs index afae3127..62f63c42 100644 --- a/tests/expectations/tests/opaque-tracing.rs +++ b/tests/expectations/tests/opaque-tracing.rs @@ -15,11 +15,19 @@ pub struct Container { } #[test] fn bindgen_test_layout_Container() { - assert_eq!(::std::mem::size_of::<Container>() , 8usize , concat ! ( - "Size of: " , stringify ! ( Container ) )); - assert_eq! (::std::mem::align_of::<Container>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Container ) )); + assert_eq!( + ::std::mem::size_of::<Container>(), + 8usize, + concat!("Size of: ", stringify!(Container)) + ); + assert_eq!( + ::std::mem::align_of::<Container>(), + 4usize, + concat!("Alignment of ", stringify!(Container)) + ); } impl Clone for Container { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/overflowed_enum.rs b/tests/expectations/tests/overflowed_enum.rs index bc4a5347..0e8700dc 100644 --- a/tests/expectations/tests/overflowed_enum.rs +++ b/tests/expectations/tests/overflowed_enum.rs @@ -13,4 +13,7 @@ pub enum Foo { } #[repr(u16)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Bar { One = 1, Big = 2, } +pub enum Bar { + One = 1, + Big = 2, +} diff --git a/tests/expectations/tests/overloading.rs b/tests/expectations/tests/overloading.rs index ab417e8e..28b783c3 100644 --- a/tests/expectations/tests/overloading.rs +++ b/tests/expectations/tests/overloading.rs @@ -10,8 +10,7 @@ extern "C" { } extern "C" { #[link_name = "\u{1}_Z8Evaluateii"] - pub fn Evaluate1(x: ::std::os::raw::c_int, y: ::std::os::raw::c_int) - -> bool; + pub fn Evaluate1(x: ::std::os::raw::c_int, y: ::std::os::raw::c_int) -> bool; } extern "C" { #[link_name = "\u{1}_ZN3foo10MyFunctionEv"] diff --git a/tests/expectations/tests/prepend-enum-constified-variant.rs b/tests/expectations/tests/prepend-enum-constified-variant.rs index d5dca70c..df9ecf3c 100644 --- a/tests/expectations/tests/prepend-enum-constified-variant.rs +++ b/tests/expectations/tests/prepend-enum-constified-variant.rs @@ -7,4 +7,6 @@ pub const AV_CODEC_ID_TTF: AVCodecID = AVCodecID::AV_CODEC_ID_FIRST_UNKNOWN; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum AVCodecID { AV_CODEC_ID_FIRST_UNKNOWN = 98304, } +pub enum AVCodecID { + AV_CODEC_ID_FIRST_UNKNOWN = 98304, +} diff --git a/tests/expectations/tests/private.rs b/tests/expectations/tests/private.rs index e29ad1ba..73f6377d 100644 --- a/tests/expectations/tests/private.rs +++ b/tests/expectations/tests/private.rs @@ -13,23 +13,41 @@ pub struct HasPrivate { } #[test] fn bindgen_test_layout_HasPrivate() { - assert_eq!(::std::mem::size_of::<HasPrivate>() , 8usize , concat ! ( - "Size of: " , stringify ! ( HasPrivate ) )); - assert_eq! (::std::mem::align_of::<HasPrivate>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( HasPrivate ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const HasPrivate ) ) . mNotPrivate as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( HasPrivate ) , "::" , - stringify ! ( mNotPrivate ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const HasPrivate ) ) . mIsPrivate as * const _ - as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( HasPrivate ) , "::" , - stringify ! ( mIsPrivate ) )); + assert_eq!( + ::std::mem::size_of::<HasPrivate>(), + 8usize, + concat!("Size of: ", stringify!(HasPrivate)) + ); + assert_eq!( + ::std::mem::align_of::<HasPrivate>(), + 4usize, + concat!("Alignment of ", stringify!(HasPrivate)) + ); + assert_eq!( + unsafe { &(*(0 as *const HasPrivate)).mNotPrivate as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(HasPrivate), + "::", + stringify!(mNotPrivate) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const HasPrivate)).mIsPrivate as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(HasPrivate), + "::", + stringify!(mIsPrivate) + ) + ); } impl Clone for HasPrivate { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } /// <div rustbindgen private></div> #[repr(C)] @@ -40,23 +58,41 @@ pub struct VeryPrivate { } #[test] fn bindgen_test_layout_VeryPrivate() { - assert_eq!(::std::mem::size_of::<VeryPrivate>() , 8usize , concat ! ( - "Size of: " , stringify ! ( VeryPrivate ) )); - assert_eq! (::std::mem::align_of::<VeryPrivate>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( VeryPrivate ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const VeryPrivate ) ) . mIsPrivate as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( VeryPrivate ) , "::" , - stringify ! ( mIsPrivate ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const VeryPrivate ) ) . mIsAlsoPrivate as * - const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( VeryPrivate ) , "::" , - stringify ! ( mIsAlsoPrivate ) )); + assert_eq!( + ::std::mem::size_of::<VeryPrivate>(), + 8usize, + concat!("Size of: ", stringify!(VeryPrivate)) + ); + assert_eq!( + ::std::mem::align_of::<VeryPrivate>(), + 4usize, + concat!("Alignment of ", stringify!(VeryPrivate)) + ); + assert_eq!( + unsafe { &(*(0 as *const VeryPrivate)).mIsPrivate as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(VeryPrivate), + "::", + stringify!(mIsPrivate) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const VeryPrivate)).mIsAlsoPrivate as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(VeryPrivate), + "::", + stringify!(mIsAlsoPrivate) + ) + ); } impl Clone for VeryPrivate { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } /// <div rustbindgen private></div> #[repr(C)] @@ -68,21 +104,39 @@ pub struct ContradictPrivate { } #[test] fn bindgen_test_layout_ContradictPrivate() { - assert_eq!(::std::mem::size_of::<ContradictPrivate>() , 8usize , concat ! - ( "Size of: " , stringify ! ( ContradictPrivate ) )); - assert_eq! (::std::mem::align_of::<ContradictPrivate>() , 4usize , concat - ! ( "Alignment of " , stringify ! ( ContradictPrivate ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ContradictPrivate ) ) . mNotPrivate as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( ContradictPrivate ) , - "::" , stringify ! ( mNotPrivate ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ContradictPrivate ) ) . mIsPrivate as * - const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( ContradictPrivate ) , - "::" , stringify ! ( mIsPrivate ) )); + assert_eq!( + ::std::mem::size_of::<ContradictPrivate>(), + 8usize, + concat!("Size of: ", stringify!(ContradictPrivate)) + ); + assert_eq!( + ::std::mem::align_of::<ContradictPrivate>(), + 4usize, + concat!("Alignment of ", stringify!(ContradictPrivate)) + ); + assert_eq!( + unsafe { &(*(0 as *const ContradictPrivate)).mNotPrivate as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(ContradictPrivate), + "::", + stringify!(mNotPrivate) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const ContradictPrivate)).mIsPrivate as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(ContradictPrivate), + "::", + stringify!(mIsPrivate) + ) + ); } impl Clone for ContradictPrivate { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/public-dtor.rs b/tests/expectations/tests/public-dtor.rs index dab29762..f551c2cb 100644 --- a/tests/expectations/tests/public-dtor.rs +++ b/tests/expectations/tests/public-dtor.rs @@ -11,10 +11,16 @@ pub struct cv_String { } #[test] fn bindgen_test_layout_cv_String() { - assert_eq!(::std::mem::size_of::<cv_String>() , 1usize , concat ! ( - "Size of: " , stringify ! ( cv_String ) )); - assert_eq! (::std::mem::align_of::<cv_String>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( cv_String ) )); + assert_eq!( + ::std::mem::size_of::<cv_String>(), + 1usize, + concat!("Size of: ", stringify!(cv_String)) + ); + assert_eq!( + ::std::mem::align_of::<cv_String>(), + 1usize, + concat!("Alignment of ", stringify!(cv_String)) + ); } extern "C" { #[link_name = "\u{1}_ZN2cv6StringD1Ev"] @@ -22,5 +28,7 @@ extern "C" { } impl cv_String { #[inline] - pub unsafe fn destruct(&mut self) { cv_String_String_destructor(self) } + pub unsafe fn destruct(&mut self) { + cv_String_String_destructor(self) + } } diff --git a/tests/expectations/tests/ref_argument_array.rs b/tests/expectations/tests/ref_argument_array.rs index ea5d0e18..fd57dd57 100644 --- a/tests/expectations/tests/ref_argument_array.rs +++ b/tests/expectations/tests/ref_argument_array.rs @@ -14,20 +14,31 @@ pub struct nsID { } #[test] fn bindgen_test_layout_nsID() { - assert_eq!(::std::mem::size_of::<nsID>() , 8usize , concat ! ( - "Size of: " , stringify ! ( nsID ) )); - assert_eq! (::std::mem::align_of::<nsID>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( nsID ) )); + assert_eq!( + ::std::mem::size_of::<nsID>(), + 8usize, + concat!("Size of: ", stringify!(nsID)) + ); + assert_eq!( + ::std::mem::align_of::<nsID>(), + 8usize, + concat!("Alignment of ", stringify!(nsID)) + ); } impl Clone for nsID { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for nsID { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } extern "C" { #[link_name = "\u{1}_ZN4nsID16ToProvidedStringERA10_c"] - pub fn nsID_ToProvidedString(this: *mut ::std::os::raw::c_void, - aDest: - *mut [::std::os::raw::c_char; 10usize]); + pub fn nsID_ToProvidedString( + this: *mut ::std::os::raw::c_void, + aDest: *mut [::std::os::raw::c_char; 10usize], + ); } diff --git a/tests/expectations/tests/reparented_replacement.rs b/tests/expectations/tests/reparented_replacement.rs index c9e85911..0402c95c 100644 --- a/tests/expectations/tests/reparented_replacement.rs +++ b/tests/expectations/tests/reparented_replacement.rs @@ -19,18 +19,31 @@ pub mod root { } #[test] fn bindgen_test_layout_Bar() { - assert_eq!(::std::mem::size_of::<Bar>() , 4usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::<Bar>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Bar ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Bar ) ) . bazz as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Bar ) , "::" , - stringify ! ( bazz ) )); + assert_eq!( + ::std::mem::size_of::<Bar>(), + 4usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::<Bar>(), + 4usize, + concat!("Alignment of ", stringify!(Bar)) + ); + assert_eq!( + unsafe { &(*(0 as *const Bar)).bazz as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Bar), + "::", + stringify!(bazz) + ) + ); } impl Clone for Bar { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } } pub type ReferencesBar = root::foo::Bar; diff --git a/tests/expectations/tests/replaces_double.rs b/tests/expectations/tests/replaces_double.rs index 7f8127fd..9d49052e 100644 --- a/tests/expectations/tests/replaces_double.rs +++ b/tests/expectations/tests/replaces_double.rs @@ -10,8 +10,10 @@ pub struct Wrapper_Wrapped<T> { pub t: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } -impl <T> Default for Wrapper_Wrapped<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for Wrapper_Wrapped<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } pub type Wrapper_Type<T> = Wrapper_Wrapped<T>; #[repr(C)] @@ -22,6 +24,8 @@ pub struct Rooted<T> { } /// <div rustbindgen replaces="Rooted_MaybeWrapped"></div> pub type Rooted_MaybeWrapped<T> = T; -impl <T> Default for Rooted<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for Rooted<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/same_struct_name_in_different_namespaces.rs b/tests/expectations/tests/same_struct_name_in_different_namespaces.rs index e406cf33..3575a581 100644 --- a/tests/expectations/tests/same_struct_name_in_different_namespaces.rs +++ b/tests/expectations/tests/same_struct_name_in_different_namespaces.rs @@ -17,21 +17,39 @@ pub struct JS_shadow_Zone { } #[test] fn bindgen_test_layout_JS_shadow_Zone() { - assert_eq!(::std::mem::size_of::<JS_shadow_Zone>() , 8usize , concat ! ( - "Size of: " , stringify ! ( JS_shadow_Zone ) )); - assert_eq! (::std::mem::align_of::<JS_shadow_Zone>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( JS_shadow_Zone ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const JS_shadow_Zone ) ) . x as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( JS_shadow_Zone ) , "::" - , stringify ! ( x ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const JS_shadow_Zone ) ) . y as * const _ as - usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( JS_shadow_Zone ) , "::" - , stringify ! ( y ) )); + assert_eq!( + ::std::mem::size_of::<JS_shadow_Zone>(), + 8usize, + concat!("Size of: ", stringify!(JS_shadow_Zone)) + ); + assert_eq!( + ::std::mem::align_of::<JS_shadow_Zone>(), + 4usize, + concat!("Alignment of ", stringify!(JS_shadow_Zone)) + ); + assert_eq!( + unsafe { &(*(0 as *const JS_shadow_Zone)).x as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(JS_shadow_Zone), + "::", + stringify!(x) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const JS_shadow_Zone)).y as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(JS_shadow_Zone), + "::", + stringify!(y) + ) + ); } impl Clone for JS_shadow_Zone { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/sentry-defined-multiple-times.rs b/tests/expectations/tests/sentry-defined-multiple-times.rs index 7d105c2a..61d35e25 100644 --- a/tests/expectations/tests/sentry-defined-multiple-times.rs +++ b/tests/expectations/tests/sentry-defined-multiple-times.rs @@ -96,8 +96,8 @@ pub mod root { ); assert_eq!( unsafe { - &(*(0 as *const NotTemplateWrapper_sentry)).i_am_not_template_wrapper_sentry as - *const _ as usize + &(*(0 as *const NotTemplateWrapper_sentry)).i_am_not_template_wrapper_sentry + as *const _ as usize }, 0usize, concat!( @@ -138,8 +138,8 @@ pub mod root { assert_eq!( unsafe { &(*(0 as *const InlineNotTemplateWrapper_sentry)) - .i_am_inline_not_template_wrapper_sentry as *const _ as - usize + .i_am_inline_not_template_wrapper_sentry as *const _ + as usize }, 0usize, concat!( diff --git a/tests/expectations/tests/short-enums.rs b/tests/expectations/tests/short-enums.rs index 73eb45d7..c3b26da9 100644 --- a/tests/expectations/tests/short-enums.rs +++ b/tests/expectations/tests/short-enums.rs @@ -6,10 +6,16 @@ #[repr(u8)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum one_byte_t { SOME_VALUE = 1, } +pub enum one_byte_t { + SOME_VALUE = 1, +} #[repr(u16)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum two_byte_t { SOME_OTHER_VALUE = 256, } +pub enum two_byte_t { + SOME_OTHER_VALUE = 256, +} #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum four_byte_t { SOME_BIGGER_VALUE = 16777216, } +pub enum four_byte_t { + SOME_BIGGER_VALUE = 16777216, +} diff --git a/tests/expectations/tests/size_t_template.rs b/tests/expectations/tests/size_t_template.rs index b3adbee6..16a72e25 100644 --- a/tests/expectations/tests/size_t_template.rs +++ b/tests/expectations/tests/size_t_template.rs @@ -11,16 +11,24 @@ pub struct C { } #[test] fn bindgen_test_layout_C() { - assert_eq!(::std::mem::size_of::<C>() , 12usize , 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 ) ) . arr as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( arr ) )); + assert_eq!( + ::std::mem::size_of::<C>(), + 12usize, + 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)).arr as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(C), "::", stringify!(arr)) + ); } impl Clone for C { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/struct_containing_forward_declared_struct.rs b/tests/expectations/tests/struct_containing_forward_declared_struct.rs index db47ce6f..12e13dc8 100644 --- a/tests/expectations/tests/struct_containing_forward_declared_struct.rs +++ b/tests/expectations/tests/struct_containing_forward_declared_struct.rs @@ -11,21 +11,36 @@ pub struct a { } #[test] fn bindgen_test_layout_a() { - assert_eq!(::std::mem::size_of::<a>() , 8usize , concat ! ( - "Size of: " , stringify ! ( a ) )); - assert_eq! (::std::mem::align_of::<a>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const a ) ) . val_a as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( a ) , "::" , stringify - ! ( val_a ) )); + assert_eq!( + ::std::mem::size_of::<a>(), + 8usize, + concat!("Size of: ", stringify!(a)) + ); + assert_eq!( + ::std::mem::align_of::<a>(), + 8usize, + concat!("Alignment of ", stringify!(a)) + ); + assert_eq!( + unsafe { &(*(0 as *const a)).val_a as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(a), + "::", + stringify!(val_a) + ) + ); } impl Clone for a { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for a { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] @@ -34,16 +49,29 @@ pub struct b { } #[test] fn bindgen_test_layout_b() { - assert_eq!(::std::mem::size_of::<b>() , 4usize , concat ! ( - "Size of: " , stringify ! ( b ) )); - assert_eq! (::std::mem::align_of::<b>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( b ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const b ) ) . val_b as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( b ) , "::" , stringify - ! ( val_b ) )); + assert_eq!( + ::std::mem::size_of::<b>(), + 4usize, + concat!("Size of: ", stringify!(b)) + ); + assert_eq!( + ::std::mem::align_of::<b>(), + 4usize, + concat!("Alignment of ", stringify!(b)) + ); + assert_eq!( + unsafe { &(*(0 as *const b)).val_b as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(b), + "::", + stringify!(val_b) + ) + ); } impl Clone for b { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/struct_typedef.rs b/tests/expectations/tests/struct_typedef.rs index fb680b69..f1e195fd 100644 --- a/tests/expectations/tests/struct_typedef.rs +++ b/tests/expectations/tests/struct_typedef.rs @@ -11,19 +11,31 @@ pub struct typedef_named_struct { } #[test] fn bindgen_test_layout_typedef_named_struct() { - assert_eq!(::std::mem::size_of::<typedef_named_struct>() , 1usize , concat - ! ( "Size of: " , stringify ! ( typedef_named_struct ) )); - assert_eq! (::std::mem::align_of::<typedef_named_struct>() , 1usize , - concat ! ( - "Alignment of " , stringify ! ( typedef_named_struct ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const typedef_named_struct ) ) . has_name as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( typedef_named_struct ) - , "::" , stringify ! ( has_name ) )); + assert_eq!( + ::std::mem::size_of::<typedef_named_struct>(), + 1usize, + concat!("Size of: ", stringify!(typedef_named_struct)) + ); + assert_eq!( + ::std::mem::align_of::<typedef_named_struct>(), + 1usize, + concat!("Alignment of ", stringify!(typedef_named_struct)) + ); + assert_eq!( + unsafe { &(*(0 as *const typedef_named_struct)).has_name as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(typedef_named_struct), + "::", + stringify!(has_name) + ) + ); } impl Clone for typedef_named_struct { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] @@ -32,30 +44,49 @@ pub struct _bindgen_ty_1 { } #[test] fn bindgen_test_layout__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<_bindgen_ty_1>() , 8usize , concat ! ( - "Size of: " , stringify ! ( _bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<_bindgen_ty_1>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( _bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const _bindgen_ty_1 ) ) . no_name as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( _bindgen_ty_1 ) , "::" - , stringify ! ( no_name ) )); + assert_eq!( + ::std::mem::size_of::<_bindgen_ty_1>(), + 8usize, + concat!("Size of: ", stringify!(_bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<_bindgen_ty_1>(), + 8usize, + concat!("Alignment of ", stringify!(_bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const _bindgen_ty_1)).no_name as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(_bindgen_ty_1), + "::", + stringify!(no_name) + ) + ); } impl Clone for _bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for _bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } pub type struct_ptr_t = *mut _bindgen_ty_1; pub type struct_ptr_ptr_t = *mut *mut _bindgen_ty_1; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum typedef_named_enum { ENUM_HAS_NAME = 1, } +pub enum typedef_named_enum { + ENUM_HAS_NAME = 1, +} pub const ENUM_IS_ANON: _bindgen_ty_2 = _bindgen_ty_2::ENUM_IS_ANON; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum _bindgen_ty_2 { ENUM_IS_ANON = 0, } +pub enum _bindgen_ty_2 { + ENUM_IS_ANON = 0, +} pub type enum_ptr_t = *mut _bindgen_ty_2; pub type enum_ptr_ptr_t = *mut *mut _bindgen_ty_2; diff --git a/tests/expectations/tests/struct_with_anon_struct.rs b/tests/expectations/tests/struct_with_anon_struct.rs index 024eaac4..d386c79b 100644 --- a/tests/expectations/tests/struct_with_anon_struct.rs +++ b/tests/expectations/tests/struct_with_anon_struct.rs @@ -17,36 +17,67 @@ pub struct foo__bindgen_ty_1 { } #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 8usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as - usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1>(), + 8usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).a as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(a) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).b as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(b) + ) + ); } impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::<foo>() , 8usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::<foo>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bar ) )); + assert_eq!( + ::std::mem::size_of::<foo>(), + 8usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::<foo>(), + 4usize, + concat!("Alignment of ", stringify!(foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).bar as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo), + "::", + stringify!(bar) + ) + ); } impl Clone for foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/struct_with_anon_struct_array.rs b/tests/expectations/tests/struct_with_anon_struct_array.rs index fe3e8b0c..2826c36e 100644 --- a/tests/expectations/tests/struct_with_anon_struct_array.rs +++ b/tests/expectations/tests/struct_with_anon_struct_array.rs @@ -18,23 +18,41 @@ pub struct foo__bindgen_ty_1 { } #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 8usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as - usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1>(), + 8usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).a as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(a) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).b as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(b) + ) + ); } impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] @@ -44,41 +62,77 @@ pub struct foo__bindgen_ty_2 { } #[test] fn bindgen_test_layout_foo__bindgen_ty_2() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_2>() , 8usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_2 ) )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_2>() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_2 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_2 ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_2 ) , - "::" , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_2 ) ) . b as * const _ as - usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_2 ) , - "::" , stringify ! ( b ) )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_2>(), + 8usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_2>(), + 4usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_2)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_2)).a as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_2), + "::", + stringify!(a) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_2)).b as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_2), + "::", + stringify!(b) + ) + ); } impl Clone for foo__bindgen_ty_2 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::<foo>() , 208usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::<foo>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bar ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . baz as * const _ as usize } , - 16usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( baz ) )); + assert_eq!( + ::std::mem::size_of::<foo>(), + 208usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::<foo>(), + 4usize, + concat!("Alignment of ", stringify!(foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).bar as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo), + "::", + stringify!(bar) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).baz as *const _ as usize }, + 16usize, + concat!( + "Alignment of field: ", + stringify!(foo), + "::", + stringify!(baz) + ) + ); } impl Clone for foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/struct_with_anon_struct_pointer.rs b/tests/expectations/tests/struct_with_anon_struct_pointer.rs index 006de1cd..bf3ad049 100644 --- a/tests/expectations/tests/struct_with_anon_struct_pointer.rs +++ b/tests/expectations/tests/struct_with_anon_struct_pointer.rs @@ -17,39 +17,72 @@ pub struct foo__bindgen_ty_1 { } #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 8usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as - usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1>(), + 8usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).a as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(a) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).b as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(b) + ) + ); } impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::<foo>() , 8usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::<foo>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bar ) )); + assert_eq!( + ::std::mem::size_of::<foo>(), + 8usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::<foo>(), + 8usize, + concat!("Alignment of ", stringify!(foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).bar as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo), + "::", + stringify!(bar) + ) + ); } impl Clone for foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for foo { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/struct_with_anon_union.rs b/tests/expectations/tests/struct_with_anon_union.rs index a43ba4ee..665ec308 100644 --- a/tests/expectations/tests/struct_with_anon_union.rs +++ b/tests/expectations/tests/struct_with_anon_union.rs @@ -18,42 +18,77 @@ pub union foo__bindgen_ty_1 { } #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 4usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1>(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).a as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(a) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).b as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(b) + ) + ); } impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for foo__bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[test] fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::<foo>() , 4usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::<foo>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bar ) )); + assert_eq!( + ::std::mem::size_of::<foo>(), + 4usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::<foo>(), + 4usize, + concat!("Alignment of ", stringify!(foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).bar as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo), + "::", + stringify!(bar) + ) + ); } impl Clone for foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for foo { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/struct_with_anon_union_1_0.rs b/tests/expectations/tests/struct_with_anon_union_1_0.rs index 4a25fd6d..e02e78e9 100644 --- a/tests/expectations/tests/struct_with_anon_union_1_0.rs +++ b/tests/expectations/tests/struct_with_anon_union_1_0.rs @@ -6,35 +6,47 @@ #[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(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo { @@ -49,36 +61,67 @@ pub struct foo__bindgen_ty_1 { } #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 4usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1>(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).a as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(a) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).b as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(b) + ) + ); } impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::<foo>() , 4usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::<foo>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bar ) )); + assert_eq!( + ::std::mem::size_of::<foo>(), + 4usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::<foo>(), + 4usize, + concat!("Alignment of ", stringify!(foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).bar as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo), + "::", + stringify!(bar) + ) + ); } impl Clone for foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/struct_with_anon_unnamed_struct.rs b/tests/expectations/tests/struct_with_anon_unnamed_struct.rs index 0349d70c..ba596f33 100644 --- a/tests/expectations/tests/struct_with_anon_unnamed_struct.rs +++ b/tests/expectations/tests/struct_with_anon_unnamed_struct.rs @@ -17,31 +17,57 @@ pub struct foo__bindgen_ty_1 { } #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 8usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as - usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1>(), + 8usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).a as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(a) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).b as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(b) + ) + ); } impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::<foo>() , 8usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::<foo>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); + assert_eq!( + ::std::mem::size_of::<foo>(), + 8usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::<foo>(), + 4usize, + concat!("Alignment of ", stringify!(foo)) + ); } impl Clone for foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/struct_with_anon_unnamed_union.rs b/tests/expectations/tests/struct_with_anon_unnamed_union.rs index af25e4e4..37ba81c3 100644 --- a/tests/expectations/tests/struct_with_anon_unnamed_union.rs +++ b/tests/expectations/tests/struct_with_anon_unnamed_union.rs @@ -18,37 +18,67 @@ pub union foo__bindgen_ty_1 { } #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 4usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1>(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).a as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(a) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).b as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(b) + ) + ); } impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for foo__bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[test] fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::<foo>() , 4usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::<foo>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); + assert_eq!( + ::std::mem::size_of::<foo>(), + 4usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::<foo>(), + 4usize, + concat!("Alignment of ", stringify!(foo)) + ); } impl Clone for foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for foo { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs b/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs index 5ce4064f..0f958b03 100644 --- a/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs +++ b/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs @@ -6,35 +6,47 @@ #[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(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo { @@ -49,31 +61,57 @@ pub struct foo__bindgen_ty_1 { } #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 4usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1>(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).a as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(a) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).b as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(b) + ) + ); } impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::<foo>() , 4usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::<foo>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); + assert_eq!( + ::std::mem::size_of::<foo>(), + 4usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::<foo>(), + 4usize, + concat!("Alignment of ", stringify!(foo)) + ); } impl Clone for foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/struct_with_derive_debug.rs b/tests/expectations/tests/struct_with_derive_debug.rs index 03046674..f681e21e 100644 --- a/tests/expectations/tests/struct_with_derive_debug.rs +++ b/tests/expectations/tests/struct_with_derive_debug.rs @@ -11,18 +11,31 @@ pub struct LittleArray { } #[test] fn bindgen_test_layout_LittleArray() { - assert_eq!(::std::mem::size_of::<LittleArray>() , 128usize , concat ! ( - "Size of: " , stringify ! ( LittleArray ) )); - assert_eq! (::std::mem::align_of::<LittleArray>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( LittleArray ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const LittleArray ) ) . a as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( LittleArray ) , "::" , - stringify ! ( a ) )); + assert_eq!( + ::std::mem::size_of::<LittleArray>(), + 128usize, + concat!("Size of: ", stringify!(LittleArray)) + ); + assert_eq!( + ::std::mem::align_of::<LittleArray>(), + 4usize, + concat!("Alignment of ", stringify!(LittleArray)) + ); + assert_eq!( + unsafe { &(*(0 as *const LittleArray)).a as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(LittleArray), + "::", + stringify!(a) + ) + ); } impl Clone for LittleArray { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Copy)] @@ -31,21 +44,36 @@ pub struct BigArray { } #[test] fn bindgen_test_layout_BigArray() { - assert_eq!(::std::mem::size_of::<BigArray>() , 132usize , concat ! ( - "Size of: " , stringify ! ( BigArray ) )); - assert_eq! (::std::mem::align_of::<BigArray>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( BigArray ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const BigArray ) ) . a as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( BigArray ) , "::" , - stringify ! ( a ) )); + assert_eq!( + ::std::mem::size_of::<BigArray>(), + 132usize, + concat!("Size of: ", stringify!(BigArray)) + ); + assert_eq!( + ::std::mem::align_of::<BigArray>(), + 4usize, + concat!("Alignment of ", stringify!(BigArray)) + ); + assert_eq!( + unsafe { &(*(0 as *const BigArray)).a as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(BigArray), + "::", + stringify!(a) + ) + ); } impl Clone for BigArray { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for BigArray { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] @@ -54,18 +82,31 @@ pub struct WithLittleArray { } #[test] fn bindgen_test_layout_WithLittleArray() { - assert_eq!(::std::mem::size_of::<WithLittleArray>() , 128usize , concat ! - ( "Size of: " , stringify ! ( WithLittleArray ) )); - assert_eq! (::std::mem::align_of::<WithLittleArray>() , 4usize , concat ! - ( "Alignment of " , stringify ! ( WithLittleArray ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithLittleArray ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( WithLittleArray ) , - "::" , stringify ! ( a ) )); + assert_eq!( + ::std::mem::size_of::<WithLittleArray>(), + 128usize, + concat!("Size of: ", stringify!(WithLittleArray)) + ); + assert_eq!( + ::std::mem::align_of::<WithLittleArray>(), + 4usize, + concat!("Alignment of ", stringify!(WithLittleArray)) + ); + assert_eq!( + unsafe { &(*(0 as *const WithLittleArray)).a as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(WithLittleArray), + "::", + stringify!(a) + ) + ); } impl Clone for WithLittleArray { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Copy)] @@ -74,19 +115,34 @@ pub struct WithBigArray { } #[test] fn bindgen_test_layout_WithBigArray() { - assert_eq!(::std::mem::size_of::<WithBigArray>() , 132usize , concat ! ( - "Size of: " , stringify ! ( WithBigArray ) )); - assert_eq! (::std::mem::align_of::<WithBigArray>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( WithBigArray ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithBigArray ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( WithBigArray ) , "::" , - stringify ! ( a ) )); + assert_eq!( + ::std::mem::size_of::<WithBigArray>(), + 132usize, + concat!("Size of: ", stringify!(WithBigArray)) + ); + assert_eq!( + ::std::mem::align_of::<WithBigArray>(), + 4usize, + concat!("Alignment of ", stringify!(WithBigArray)) + ); + assert_eq!( + unsafe { &(*(0 as *const WithBigArray)).a as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(WithBigArray), + "::", + stringify!(a) + ) + ); } impl Clone for WithBigArray { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for WithBigArray { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/struct_with_large_array.rs b/tests/expectations/tests/struct_with_large_array.rs index 0f2accba..73b29fd9 100644 --- a/tests/expectations/tests/struct_with_large_array.rs +++ b/tests/expectations/tests/struct_with_large_array.rs @@ -11,27 +11,44 @@ pub struct S { } #[test] fn bindgen_test_layout_S() { - assert_eq!(::std::mem::size_of::<S>() , 33usize , concat ! ( - "Size of: " , stringify ! ( S ) )); - assert_eq! (::std::mem::align_of::<S>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( S ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const S ) ) . large_array as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( S ) , "::" , stringify - ! ( large_array ) )); + assert_eq!( + ::std::mem::size_of::<S>(), + 33usize, + concat!("Size of: ", stringify!(S)) + ); + assert_eq!( + ::std::mem::align_of::<S>(), + 1usize, + concat!("Alignment of ", stringify!(S)) + ); + assert_eq!( + unsafe { &(*(0 as *const S)).large_array as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(S), + "::", + stringify!(large_array) + ) + ); } impl Clone for S { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for S { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] pub struct ST<T> { pub large_array: [T; 33usize], pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } -impl <T> Default for ST<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for ST<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/struct_with_nesting.rs b/tests/expectations/tests/struct_with_nesting.rs index 7b82964f..d25fc4bc 100644 --- a/tests/expectations/tests/struct_with_nesting.rs +++ b/tests/expectations/tests/struct_with_nesting.rs @@ -26,29 +26,41 @@ pub struct foo__bindgen_ty_1__bindgen_ty_1 { } #[test] fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1__bindgen_ty_1>() , - 4usize , concat ! ( - "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_1 ) - )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1__bindgen_ty_1>() , - 2usize , concat ! ( - "Alignment of " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_1 ) ) . c1 - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( c1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_1 ) ) . c2 - as * const _ as usize } , 2usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( c2 ) - )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1__bindgen_ty_1>(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1__bindgen_ty_1>(), + 2usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1__bindgen_ty_1)).c1 as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(c1) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1__bindgen_ty_1)).c2 as *const _ as usize }, + 2usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(c2) + ) + ); } impl Clone for foo__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] @@ -60,75 +72,120 @@ pub struct foo__bindgen_ty_1__bindgen_ty_2 { } #[test] fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_2() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1__bindgen_ty_2>() , - 4usize , concat ! ( - "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_2 ) - )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1__bindgen_ty_2>() , - 1usize , concat ! ( - "Alignment of " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_2 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . d1 - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( d1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . d2 - as * const _ as usize } , 1usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( d2 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . d3 - as * const _ as usize } , 2usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( d3 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . d4 - as * const _ as usize } , 3usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( d4 ) - )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1__bindgen_ty_2>(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1__bindgen_ty_2>(), + 1usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1__bindgen_ty_2)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1__bindgen_ty_2)).d1 as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(d1) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1__bindgen_ty_2)).d2 as *const _ as usize }, + 1usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(d2) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1__bindgen_ty_2)).d3 as *const _ as usize }, + 2usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(d3) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1__bindgen_ty_2)).d4 as *const _ as usize }, + 3usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(d4) + ) + ); } impl Clone for foo__bindgen_ty_1__bindgen_ty_2 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 4usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1>(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).b as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(b) + ) + ); } impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for foo__bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[test] fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::<foo>() , 8usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::<foo>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( a ) )); + assert_eq!( + ::std::mem::size_of::<foo>(), + 8usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::<foo>(), + 4usize, + concat!("Alignment of ", stringify!(foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).a as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(foo), "::", stringify!(a)) + ); } impl Clone for foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for foo { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/struct_with_nesting_1_0.rs b/tests/expectations/tests/struct_with_nesting_1_0.rs index 5d014b95..4701409a 100644 --- a/tests/expectations/tests/struct_with_nesting_1_0.rs +++ b/tests/expectations/tests/struct_with_nesting_1_0.rs @@ -6,35 +6,47 @@ #[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(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo { @@ -57,29 +69,41 @@ pub struct foo__bindgen_ty_1__bindgen_ty_1 { } #[test] fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1__bindgen_ty_1>() , - 4usize , concat ! ( - "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_1 ) - )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1__bindgen_ty_1>() , - 2usize , concat ! ( - "Alignment of " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_1 ) ) . c1 - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( c1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_1 ) ) . c2 - as * const _ as usize } , 2usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( c2 ) - )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1__bindgen_ty_1>(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1__bindgen_ty_1>(), + 2usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1__bindgen_ty_1)).c1 as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(c1) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1__bindgen_ty_1)).c2 as *const _ as usize }, + 2usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(c2) + ) + ); } impl Clone for foo__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] @@ -91,69 +115,110 @@ pub struct foo__bindgen_ty_1__bindgen_ty_2 { } #[test] fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_2() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1__bindgen_ty_2>() , - 4usize , concat ! ( - "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_2 ) - )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1__bindgen_ty_2>() , - 1usize , concat ! ( - "Alignment of " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_2 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . d1 - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( d1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . d2 - as * const _ as usize } , 1usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( d2 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . d3 - as * const _ as usize } , 2usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( d3 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . d4 - as * const _ as usize } , 3usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( d4 ) - )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1__bindgen_ty_2>(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1__bindgen_ty_2>(), + 1usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1__bindgen_ty_2)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1__bindgen_ty_2)).d1 as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(d1) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1__bindgen_ty_2)).d2 as *const _ as usize }, + 1usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(d2) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1__bindgen_ty_2)).d3 as *const _ as usize }, + 2usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(d3) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1__bindgen_ty_2)).d4 as *const _ as usize }, + 3usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(d4) + ) + ); } impl Clone for foo__bindgen_ty_1__bindgen_ty_2 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 4usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1>(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).b as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(b) + ) + ); } impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::<foo>() , 8usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::<foo>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( a ) )); + assert_eq!( + ::std::mem::size_of::<foo>(), + 8usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::<foo>(), + 4usize, + concat!("Alignment of ", stringify!(foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).a as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(foo), "::", stringify!(a)) + ); } impl Clone for foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/struct_with_packing.rs b/tests/expectations/tests/struct_with_packing.rs index 1b3f4ca2..acdcd9b3 100644 --- a/tests/expectations/tests/struct_with_packing.rs +++ b/tests/expectations/tests/struct_with_packing.rs @@ -12,19 +12,29 @@ pub struct a { } #[test] fn bindgen_test_layout_a() { - assert_eq!(::std::mem::size_of::<a>() , 3usize , 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 ) ) . b as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( a ) , "::" , stringify - ! ( b ) )); - assert_eq! (unsafe { & ( * ( 0 as * const a ) ) . c as * const _ as usize - } , 1usize , concat ! ( - "Alignment of field: " , stringify ! ( a ) , "::" , stringify - ! ( c ) )); + assert_eq!( + ::std::mem::size_of::<a>(), + 3usize, + 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)).b as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(a), "::", stringify!(b)) + ); + assert_eq!( + unsafe { &(*(0 as *const a)).c as *const _ as usize }, + 1usize, + concat!("Alignment of field: ", stringify!(a), "::", stringify!(c)) + ); } impl Clone for a { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/struct_with_struct.rs b/tests/expectations/tests/struct_with_struct.rs index 47c99937..22676961 100644 --- a/tests/expectations/tests/struct_with_struct.rs +++ b/tests/expectations/tests/struct_with_struct.rs @@ -17,36 +17,67 @@ pub struct foo__bindgen_ty_1 { } #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 8usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . x as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( x ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . y as * const _ as - usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( y ) )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1>(), + 8usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).x as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(x) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).y as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(y) + ) + ); } impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::<foo>() , 8usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::<foo>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bar ) )); + assert_eq!( + ::std::mem::size_of::<foo>(), + 8usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::<foo>(), + 4usize, + concat!("Alignment of ", stringify!(foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).bar as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo), + "::", + stringify!(bar) + ) + ); } impl Clone for foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/struct_with_typedef_template_arg.rs b/tests/expectations/tests/struct_with_typedef_template_arg.rs index ad4f394a..2c21656a 100644 --- a/tests/expectations/tests/struct_with_typedef_template_arg.rs +++ b/tests/expectations/tests/struct_with_typedef_template_arg.rs @@ -9,5 +9,4 @@ pub struct Proxy { pub _address: u8, } -pub type Proxy_foo<T> = - ::std::option::Option<unsafe extern "C" fn(bar: *mut T)>; +pub type Proxy_foo<T> = ::std::option::Option<unsafe extern "C" fn(bar: *mut T)>; diff --git a/tests/expectations/tests/template-fun-ty.rs b/tests/expectations/tests/template-fun-ty.rs index 8403f794..cce6c24d 100644 --- a/tests/expectations/tests/template-fun-ty.rs +++ b/tests/expectations/tests/template-fun-ty.rs @@ -9,8 +9,7 @@ pub struct Foo { pub _address: u8, } -pub type Foo_FunctionPtr<T> = - ::std::option::Option<unsafe extern "C" fn() -> T>; +pub type Foo_FunctionPtr<T> = ::std::option::Option<unsafe extern "C" fn() -> T>; #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct RefPtr { @@ -21,6 +20,7 @@ pub struct RefPtr { pub struct RefPtr_Proxy { pub _address: u8, } -pub type RefPtr_Proxy_member_function<R, Args> = - ::std::option::Option<unsafe extern "C" fn(arg1: Args) -> R>; +pub type RefPtr_Proxy_member_function<R, Args> = ::std::option::Option< + unsafe extern "C" fn(arg1: Args) -> R, +>; pub type Returner<T> = ::std::option::Option<unsafe extern "C" fn() -> T>; diff --git a/tests/expectations/tests/template-param-usage-0.rs b/tests/expectations/tests/template-param-usage-0.rs index 4f74a144..d5ca7d7d 100644 --- a/tests/expectations/tests/template-param-usage-0.rs +++ b/tests/expectations/tests/template-param-usage-0.rs @@ -10,6 +10,8 @@ pub struct UsesTemplateParameter<T> { pub t: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } -impl <T> Default for UsesTemplateParameter<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for UsesTemplateParameter<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/template-param-usage-10.rs b/tests/expectations/tests/template-param-usage-10.rs index a01597c1..940be664 100644 --- a/tests/expectations/tests/template-param-usage-10.rs +++ b/tests/expectations/tests/template-param-usage-10.rs @@ -21,9 +21,13 @@ pub struct DoublyIndirectUsage_IndirectUsage<T, U> { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, pub _phantom_1: ::std::marker::PhantomData<::std::cell::UnsafeCell<U>>, } -impl <T, U> Default for DoublyIndirectUsage_IndirectUsage<T, U> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T, U> Default for DoublyIndirectUsage_IndirectUsage<T, U> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } -impl <T, U> Default for DoublyIndirectUsage<T, U> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T, U> Default for DoublyIndirectUsage<T, U> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/template-param-usage-12.rs b/tests/expectations/tests/template-param-usage-12.rs index 5912bdf5..d6a54085 100644 --- a/tests/expectations/tests/template-param-usage-12.rs +++ b/tests/expectations/tests/template-param-usage-12.rs @@ -10,8 +10,10 @@ pub struct BaseUsesT<T> { pub t: *mut T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } -impl <T> Default for BaseUsesT<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for BaseUsesT<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -20,6 +22,8 @@ pub struct CrtpUsesU<U> { pub usage: U, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<U>>, } -impl <U> Default for CrtpUsesU<U> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<U> Default for CrtpUsesU<U> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/template-param-usage-13.rs b/tests/expectations/tests/template-param-usage-13.rs index 4721968f..855c76fe 100644 --- a/tests/expectations/tests/template-param-usage-13.rs +++ b/tests/expectations/tests/template-param-usage-13.rs @@ -16,6 +16,8 @@ pub struct CrtpUsesU<U> { pub usage: U, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<U>>, } -impl <U> Default for CrtpUsesU<U> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<U> Default for CrtpUsesU<U> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/template-param-usage-14.rs b/tests/expectations/tests/template-param-usage-14.rs index d4c86652..97dbba46 100644 --- a/tests/expectations/tests/template-param-usage-14.rs +++ b/tests/expectations/tests/template-param-usage-14.rs @@ -16,5 +16,7 @@ pub struct CrtpIgnoresU { pub y: ::std::os::raw::c_int, } impl Default for CrtpIgnoresU { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/template-param-usage-15.rs b/tests/expectations/tests/template-param-usage-15.rs index 9b7f30ec..405e8198 100644 --- a/tests/expectations/tests/template-param-usage-15.rs +++ b/tests/expectations/tests/template-param-usage-15.rs @@ -10,8 +10,10 @@ pub struct BaseUsesT<T> { pub usage: *mut T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } -impl <T> Default for BaseUsesT<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for BaseUsesT<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -20,5 +22,7 @@ pub struct CrtpIgnoresU { pub y: ::std::os::raw::c_int, } impl Default for CrtpIgnoresU { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/template-param-usage-2.rs b/tests/expectations/tests/template-param-usage-2.rs index d017976b..24086724 100644 --- a/tests/expectations/tests/template-param-usage-2.rs +++ b/tests/expectations/tests/template-param-usage-2.rs @@ -16,9 +16,13 @@ pub struct UsesTemplateParameter_AlsoUsesTemplateParameter<T> { pub also: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } -impl <T> Default for UsesTemplateParameter_AlsoUsesTemplateParameter<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for UsesTemplateParameter_AlsoUsesTemplateParameter<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } -impl <T> Default for UsesTemplateParameter<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for UsesTemplateParameter<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/template-param-usage-3.rs b/tests/expectations/tests/template-param-usage-3.rs index 85a96d54..0e5d2fdf 100644 --- a/tests/expectations/tests/template-param-usage-3.rs +++ b/tests/expectations/tests/template-param-usage-3.rs @@ -18,10 +18,13 @@ pub struct UsesTemplateParameter_AlsoUsesTemplateParameterAndMore<T, U> { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, pub _phantom_1: ::std::marker::PhantomData<::std::cell::UnsafeCell<U>>, } -impl <T, U> Default for - UsesTemplateParameter_AlsoUsesTemplateParameterAndMore<T, U> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T, U> Default for UsesTemplateParameter_AlsoUsesTemplateParameterAndMore<T, U> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } -impl <T> Default for UsesTemplateParameter<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for UsesTemplateParameter<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/template-param-usage-4.rs b/tests/expectations/tests/template-param-usage-4.rs index 5e9e004c..af36754f 100644 --- a/tests/expectations/tests/template-param-usage-4.rs +++ b/tests/expectations/tests/template-param-usage-4.rs @@ -15,6 +15,8 @@ pub struct UsesTemplateParameter<T> { pub struct UsesTemplateParameter_DoesNotUseTemplateParameters { pub x: ::std::os::raw::c_int, } -impl <T> Default for UsesTemplateParameter<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for UsesTemplateParameter<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/template-param-usage-5.rs b/tests/expectations/tests/template-param-usage-5.rs index 375a60df..46ae3513 100644 --- a/tests/expectations/tests/template-param-usage-5.rs +++ b/tests/expectations/tests/template-param-usage-5.rs @@ -11,6 +11,8 @@ pub struct IndirectlyUsesTemplateParameter<T> { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } pub type IndirectlyUsesTemplateParameter_Aliased<T> = T; -impl <T> Default for IndirectlyUsesTemplateParameter<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for IndirectlyUsesTemplateParameter<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/template-param-usage-7.rs b/tests/expectations/tests/template-param-usage-7.rs index 38b3e832..b30c82b4 100644 --- a/tests/expectations/tests/template-param-usage-7.rs +++ b/tests/expectations/tests/template-param-usage-7.rs @@ -12,7 +12,9 @@ pub struct DoesNotUseU<T, V> { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, pub _phantom_1: ::std::marker::PhantomData<::std::cell::UnsafeCell<V>>, } -impl <T, V> Default for DoesNotUseU<T, V> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T, V> Default for DoesNotUseU<T, V> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } pub type Alias = DoesNotUseU<::std::os::raw::c_int, ::std::os::raw::c_char>; diff --git a/tests/expectations/tests/template-param-usage-8.rs b/tests/expectations/tests/template-param-usage-8.rs index 9a0f428f..75e14706 100644 --- a/tests/expectations/tests/template-param-usage-8.rs +++ b/tests/expectations/tests/template-param-usage-8.rs @@ -14,6 +14,8 @@ pub struct IndirectUsage<T, U> { } pub type IndirectUsage_Typedefed<T> = T; pub type IndirectUsage_Aliased<U> = U; -impl <T, U> Default for IndirectUsage<T, U> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T, U> Default for IndirectUsage<T, U> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/template-param-usage-9.rs b/tests/expectations/tests/template-param-usage-9.rs index 88fea725..3071924e 100644 --- a/tests/expectations/tests/template-param-usage-9.rs +++ b/tests/expectations/tests/template-param-usage-9.rs @@ -19,6 +19,8 @@ pub struct DoesNotUse_IndirectUsage<T, U> { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, pub _phantom_1: ::std::marker::PhantomData<::std::cell::UnsafeCell<U>>, } -impl <T, U> Default for DoesNotUse_IndirectUsage<T, U> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T, U> Default for DoesNotUse_IndirectUsage<T, U> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/template.rs b/tests/expectations/tests/template.rs index 3f397b6f..46eb0a33 100644 --- a/tests/expectations/tests/template.rs +++ b/tests/expectations/tests/template.rs @@ -411,7 +411,7 @@ pub struct NestedContainer<T> { pub inc: Incomplete<T>, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } -impl <T> Default for NestedContainer<T> { +impl<T> Default for NestedContainer<T> { fn default() -> Self { unsafe { ::std::mem::zeroed() } } @@ -422,7 +422,7 @@ pub struct Incomplete<T> { pub d: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } -impl <T> Default for Incomplete<T> { +impl<T> Default for Incomplete<T> { fn default() -> Self { unsafe { ::std::mem::zeroed() } } @@ -514,103 +514,367 @@ fn __bindgen_test_layout_Foo_open0_int_int_close0_instantiation() { 24usize, concat!( "Size of template specialization: ", - stringify ! ( Foo < :: std :: os :: raw :: c_int > ) + stringify!(Foo<::std::os::raw::c_int>) + ) + ); + assert_eq!( + ::std::mem::align_of::<Foo<::std::os::raw::c_int>>(), + 8usize, + concat!( + "Alignment of template specialization: ", + stringify!(Foo<::std::os::raw::c_int>) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < Foo < :: std :: os :: raw :: c_int > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( Foo < :: std :: os :: raw :: c_int > ) ) ); } #[test] fn __bindgen_test_layout_B_open0_unsigned_int_close0_instantiation() { - assert_eq ! ( :: std :: mem :: size_of :: < B < :: std :: os :: raw :: c_uint > > ( ) , 4usize , concat ! ( "Size of template specialization: " , stringify ! ( B < :: std :: os :: raw :: c_uint > ) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < B < :: std :: os :: raw :: c_uint > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < :: std :: os :: raw :: c_uint > ) ) ); + assert_eq!( + ::std::mem::size_of::<B<::std::os::raw::c_uint>>(), + 4usize, + concat!( + "Size of template specialization: ", + stringify!(B<::std::os::raw::c_uint>) + ) + ); + assert_eq!( + ::std::mem::align_of::<B<::std::os::raw::c_uint>>(), + 4usize, + concat!( + "Alignment of template specialization: ", + stringify!(B<::std::os::raw::c_uint>) + ) + ); } #[test] fn __bindgen_test_layout_B_open0_ptr_const_int_close0_instantiation() { - assert_eq ! ( :: std :: mem :: size_of :: < B < * const :: std :: os :: raw :: c_int > > ( ) , 8usize , concat ! ( "Size of template specialization: " , stringify ! ( B < * const :: std :: os :: raw :: c_int > ) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < B < * const :: std :: os :: raw :: c_int > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < * const :: std :: os :: raw :: c_int > ) ) ); + assert_eq!( + ::std::mem::size_of::<B<*const ::std::os::raw::c_int>>(), + 8usize, + concat!( + "Size of template specialization: ", + stringify!(B<*const ::std::os::raw::c_int>) + ) + ); + assert_eq!( + ::std::mem::align_of::<B<*const ::std::os::raw::c_int>>(), + 8usize, + concat!( + "Alignment of template specialization: ", + stringify!(B<*const ::std::os::raw::c_int>) + ) + ); } #[test] fn __bindgen_test_layout_B_open0_ptr_const_mozilla__Foo_close0_instantiation() { - assert_eq ! ( :: std :: mem :: size_of :: < B < * const mozilla_Foo > > ( ) , 8usize , concat ! ( "Size of template specialization: " , stringify ! ( B < * const mozilla_Foo > ) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < B < * const mozilla_Foo > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < * const mozilla_Foo > ) ) ); + assert_eq!( + ::std::mem::size_of::<B<*const mozilla_Foo>>(), + 8usize, + concat!( + "Size of template specialization: ", + stringify!(B<*const mozilla_Foo>) + ) + ); + assert_eq!( + ::std::mem::align_of::<B<*const mozilla_Foo>>(), + 8usize, + concat!( + "Alignment of template specialization: ", + stringify!(B<*const mozilla_Foo>) + ) + ); } #[test] fn __bindgen_test_layout_B_open0_array1_ptr_const_mozilla__Foo_close0_instantiation() { - assert_eq ! ( :: std :: mem :: size_of :: < B < [ * const mozilla_Foo ; 1usize ] > > ( ) , 8usize , concat ! ( "Size of template specialization: " , stringify ! ( B < [ * const mozilla_Foo ; 1usize ] > ) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < B < [ * const mozilla_Foo ; 1usize ] > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < [ * const mozilla_Foo ; 1usize ] > ) ) ); + assert_eq!( + ::std::mem::size_of::<B<[*const mozilla_Foo; 1usize]>>(), + 8usize, + concat!( + "Size of template specialization: ", + stringify!(B<[*const mozilla_Foo; 1usize]>) + ) + ); + assert_eq!( + ::std::mem::align_of::<B<[*const mozilla_Foo; 1usize]>>(), + 8usize, + concat!( + "Alignment of template specialization: ", + stringify!(B<[*const mozilla_Foo; 1usize]>) + ) + ); } #[test] fn __bindgen_test_layout_B_open0_const_int_close0_instantiation() { - assert_eq ! ( :: std :: mem :: size_of :: < B < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Size of template specialization: " , stringify ! ( B < :: std :: os :: raw :: c_int > ) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < B < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < :: std :: os :: raw :: c_int > ) ) ); + assert_eq!( + ::std::mem::size_of::<B<::std::os::raw::c_int>>(), + 4usize, + concat!( + "Size of template specialization: ", + stringify!(B<::std::os::raw::c_int>) + ) + ); + assert_eq!( + ::std::mem::align_of::<B<::std::os::raw::c_int>>(), + 4usize, + concat!( + "Alignment of template specialization: ", + stringify!(B<::std::os::raw::c_int>) + ) + ); } #[test] fn __bindgen_test_layout_B_open0_volatile_int_close0_instantiation() { - assert_eq ! ( :: std :: mem :: size_of :: < B < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Size of template specialization: " , stringify ! ( B < :: std :: os :: raw :: c_int > ) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < B < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < :: std :: os :: raw :: c_int > ) ) ); + assert_eq!( + ::std::mem::size_of::<B<::std::os::raw::c_int>>(), + 4usize, + concat!( + "Size of template specialization: ", + stringify!(B<::std::os::raw::c_int>) + ) + ); + assert_eq!( + ::std::mem::align_of::<B<::std::os::raw::c_int>>(), + 4usize, + concat!( + "Alignment of template specialization: ", + stringify!(B<::std::os::raw::c_int>) + ) + ); } #[test] fn __bindgen_test_layout_B_open0_const_bool_close0_instantiation() { - assert_eq ! ( :: std :: mem :: size_of :: < B < bool > > ( ) , 1usize , concat ! ( "Size of template specialization: " , stringify ! ( B < bool > ) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < B < bool > > ( ) , 1usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < bool > ) ) ); + assert_eq!( + ::std::mem::size_of::<B<bool>>(), + 1usize, + concat!("Size of template specialization: ", stringify!(B<bool>)) + ); + assert_eq!( + ::std::mem::align_of::<B<bool>>(), + 1usize, + concat!( + "Alignment of template specialization: ", + stringify!(B<bool>) + ) + ); } #[test] fn __bindgen_test_layout_B_open0_const_char16_t_close0_instantiation() { - assert_eq ! ( :: std :: mem :: size_of :: < B < u16 > > ( ) , 2usize , concat ! ( "Size of template specialization: " , stringify ! ( B < u16 > ) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < B < u16 > > ( ) , 2usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < u16 > ) ) ); + assert_eq!( + ::std::mem::size_of::<B<u16>>(), + 2usize, + concat!("Size of template specialization: ", stringify!(B<u16>)) + ); + assert_eq!( + ::std::mem::align_of::<B<u16>>(), + 2usize, + concat!("Alignment of template specialization: ", stringify!(B<u16>)) + ); } #[test] fn __bindgen_test_layout_B_open0_array1_int_close0_instantiation() { - assert_eq ! ( :: std :: mem :: size_of :: < B < [ :: std :: os :: raw :: c_int ; 1usize ] > > ( ) , 4usize , concat ! ( "Size of template specialization: " , stringify ! ( B < [ :: std :: os :: raw :: c_int ; 1usize ] > ) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < B < [ :: std :: os :: raw :: c_int ; 1usize ] > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < [ :: std :: os :: raw :: c_int ; 1usize ] > ) ) ); + assert_eq!( + ::std::mem::size_of::<B<[::std::os::raw::c_int; 1usize]>>(), + 4usize, + concat!( + "Size of template specialization: ", + stringify!(B<[::std::os::raw::c_int; 1usize]>) + ) + ); + assert_eq!( + ::std::mem::align_of::<B<[::std::os::raw::c_int; 1usize]>>(), + 4usize, + concat!( + "Alignment of template specialization: ", + stringify!(B<[::std::os::raw::c_int; 1usize]>) + ) + ); } #[test] fn __bindgen_test_layout_B_open0_array1_ptr_int_close0_instantiation() { - assert_eq ! ( :: std :: mem :: size_of :: < B < [ * mut :: std :: os :: raw :: c_int ; 1usize ] > > ( ) , 8usize , concat ! ( "Size of template specialization: " , stringify ! ( B < [ * mut :: std :: os :: raw :: c_int ; 1usize ] > ) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < B < [ * mut :: std :: os :: raw :: c_int ; 1usize ] > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < [ * mut :: std :: os :: raw :: c_int ; 1usize ] > ) ) ); + assert_eq!( + ::std::mem::size_of::<B<[*mut ::std::os::raw::c_int; 1usize]>>(), + 8usize, + concat!( + "Size of template specialization: ", + stringify!(B<[*mut ::std::os::raw::c_int; 1usize]>) + ) + ); + assert_eq!( + ::std::mem::align_of::<B<[*mut ::std::os::raw::c_int; 1usize]>>(), + 8usize, + concat!( + "Alignment of template specialization: ", + stringify!(B<[*mut ::std::os::raw::c_int; 1usize]>) + ) + ); } #[test] fn __bindgen_test_layout_B_open0_ptr_array1_int_close0_instantiation() { - assert_eq ! ( :: std :: mem :: size_of :: < B < * mut [ :: std :: os :: raw :: c_int ; 1usize ] > > ( ) , 8usize , concat ! ( "Size of template specialization: " , stringify ! ( B < * mut [ :: std :: os :: raw :: c_int ; 1usize ] > ) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < B < * mut [ :: std :: os :: raw :: c_int ; 1usize ] > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < * mut [ :: std :: os :: raw :: c_int ; 1usize ] > ) ) ); + assert_eq!( + ::std::mem::size_of::<B<*mut [::std::os::raw::c_int; 1usize]>>(), + 8usize, + concat!( + "Size of template specialization: ", + stringify!(B<*mut [::std::os::raw::c_int; 1usize]>) + ) + ); + assert_eq!( + ::std::mem::align_of::<B<*mut [::std::os::raw::c_int; 1usize]>>(), + 8usize, + concat!( + "Alignment of template specialization: ", + stringify!(B<*mut [::std::os::raw::c_int; 1usize]>) + ) + ); } #[test] fn __bindgen_test_layout_B_open0_ref_int_close0_instantiation() { - assert_eq ! ( :: std :: mem :: size_of :: < B < * mut :: std :: os :: raw :: c_int > > ( ) , 8usize , concat ! ( "Size of template specialization: " , stringify ! ( B < * mut :: std :: os :: raw :: c_int > ) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < B < * mut :: std :: os :: raw :: c_int > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < * mut :: std :: os :: raw :: c_int > ) ) ); + assert_eq!( + ::std::mem::size_of::<B<*mut ::std::os::raw::c_int>>(), + 8usize, + concat!( + "Size of template specialization: ", + stringify!(B<*mut ::std::os::raw::c_int>) + ) + ); + assert_eq!( + ::std::mem::align_of::<B<*mut ::std::os::raw::c_int>>(), + 8usize, + concat!( + "Alignment of template specialization: ", + stringify!(B<*mut ::std::os::raw::c_int>) + ) + ); } #[test] fn __bindgen_test_layout_B_open0_ref_const_int_close0_instantiation() { - assert_eq ! ( :: std :: mem :: size_of :: < B < * const :: std :: os :: raw :: c_int > > ( ) , 8usize , concat ! ( "Size of template specialization: " , stringify ! ( B < * const :: std :: os :: raw :: c_int > ) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < B < * const :: std :: os :: raw :: c_int > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < * const :: std :: os :: raw :: c_int > ) ) ); + assert_eq!( + ::std::mem::size_of::<B<*const ::std::os::raw::c_int>>(), + 8usize, + concat!( + "Size of template specialization: ", + stringify!(B<*const ::std::os::raw::c_int>) + ) + ); + assert_eq!( + ::std::mem::align_of::<B<*const ::std::os::raw::c_int>>(), + 8usize, + concat!( + "Alignment of template specialization: ", + stringify!(B<*const ::std::os::raw::c_int>) + ) + ); } #[test] fn __bindgen_test_layout_B_open0_ref_ptr_int_close0_instantiation() { - assert_eq ! ( :: std :: mem :: size_of :: < B < * mut * mut :: std :: os :: raw :: c_int > > ( ) , 8usize , concat ! ( "Size of template specialization: " , stringify ! ( B < * mut * mut :: std :: os :: raw :: c_int > ) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < B < * mut * mut :: std :: os :: raw :: c_int > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < * mut * mut :: std :: os :: raw :: c_int > ) ) ); + assert_eq!( + ::std::mem::size_of::<B<*mut *mut ::std::os::raw::c_int>>(), + 8usize, + concat!( + "Size of template specialization: ", + stringify!(B<*mut *mut ::std::os::raw::c_int>) + ) + ); + assert_eq!( + ::std::mem::align_of::<B<*mut *mut ::std::os::raw::c_int>>(), + 8usize, + concat!( + "Alignment of template specialization: ", + stringify!(B<*mut *mut ::std::os::raw::c_int>) + ) + ); } #[test] fn __bindgen_test_layout_B_open0_ref_array1_int_close0_instantiation() { - assert_eq ! ( :: std :: mem :: size_of :: < B < * mut [ :: std :: os :: raw :: c_int ; 1usize ] > > ( ) , 8usize , concat ! ( "Size of template specialization: " , stringify ! ( B < * mut [ :: std :: os :: raw :: c_int ; 1usize ] > ) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < B < * mut [ :: std :: os :: raw :: c_int ; 1usize ] > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < * mut [ :: std :: os :: raw :: c_int ; 1usize ] > ) ) ); + assert_eq!( + ::std::mem::size_of::<B<*mut [::std::os::raw::c_int; 1usize]>>(), + 8usize, + concat!( + "Size of template specialization: ", + stringify!(B<*mut [::std::os::raw::c_int; 1usize]>) + ) + ); + assert_eq!( + ::std::mem::align_of::<B<*mut [::std::os::raw::c_int; 1usize]>>(), + 8usize, + concat!( + "Alignment of template specialization: ", + stringify!(B<*mut [::std::os::raw::c_int; 1usize]>) + ) + ); } #[test] fn __bindgen_test_layout_Foo_open0_int_int_close0_instantiation_1() { - assert_eq ! ( :: std :: mem :: size_of :: < Foo < :: std :: os :: raw :: c_int > > ( ) , 24usize , concat ! ( "Size of template specialization: " , stringify ! ( Foo < :: std :: os :: raw :: c_int > ) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < Foo < :: std :: os :: raw :: c_int > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( Foo < :: std :: os :: raw :: c_int > ) ) ); + assert_eq!( + ::std::mem::size_of::<Foo<::std::os::raw::c_int>>(), + 24usize, + concat!( + "Size of template specialization: ", + stringify!(Foo<::std::os::raw::c_int>) + ) + ); + assert_eq!( + ::std::mem::align_of::<Foo<::std::os::raw::c_int>>(), + 8usize, + concat!( + "Alignment of template specialization: ", + stringify!(Foo<::std::os::raw::c_int>) + ) + ); } #[test] fn __bindgen_test_layout_Rooted_open0_ptr_void_close0_instantiation() { - assert_eq ! ( :: std :: mem :: size_of :: < Rooted < * mut :: std :: os :: raw :: c_void > > ( ) , 24usize , concat ! ( "Size of template specialization: " , stringify ! ( Rooted < * mut :: std :: os :: raw :: c_void > ) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < Rooted < * mut :: std :: os :: raw :: c_void > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( Rooted < * mut :: std :: os :: raw :: c_void > ) ) ); + assert_eq!( + ::std::mem::size_of::<Rooted<*mut ::std::os::raw::c_void>>(), + 24usize, + concat!( + "Size of template specialization: ", + stringify!(Rooted<*mut ::std::os::raw::c_void>) + ) + ); + assert_eq!( + ::std::mem::align_of::<Rooted<*mut ::std::os::raw::c_void>>(), + 8usize, + concat!( + "Alignment of template specialization: ", + stringify!(Rooted<*mut ::std::os::raw::c_void>) + ) + ); } #[test] fn __bindgen_test_layout_Rooted_open0_ptr_void_close0_instantiation_1() { - assert_eq ! ( :: std :: mem :: size_of :: < Rooted < * mut :: std :: os :: raw :: c_void > > ( ) , 24usize , concat ! ( "Size of template specialization: " , stringify ! ( Rooted < * mut :: std :: os :: raw :: c_void > ) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < Rooted < * mut :: std :: os :: raw :: c_void > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( Rooted < * mut :: std :: os :: raw :: c_void > ) ) ); + assert_eq!( + ::std::mem::size_of::<Rooted<*mut ::std::os::raw::c_void>>(), + 24usize, + concat!( + "Size of template specialization: ", + stringify!(Rooted<*mut ::std::os::raw::c_void>) + ) + ); + assert_eq!( + ::std::mem::align_of::<Rooted<*mut ::std::os::raw::c_void>>(), + 8usize, + concat!( + "Alignment of template specialization: ", + stringify!(Rooted<*mut ::std::os::raw::c_void>) + ) + ); } #[test] fn __bindgen_test_layout_WithDtor_open0_int_close0_instantiation() { - assert_eq ! ( :: std :: mem :: size_of :: < WithDtor < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Size of template specialization: " , stringify ! ( WithDtor < :: std :: os :: raw :: c_int > ) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < WithDtor < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( WithDtor < :: std :: os :: raw :: c_int > ) ) ); + assert_eq!( + ::std::mem::size_of::<WithDtor<::std::os::raw::c_int>>(), + 4usize, + concat!( + "Size of template specialization: ", + stringify!(WithDtor<::std::os::raw::c_int>) + ) + ); + assert_eq!( + ::std::mem::align_of::<WithDtor<::std::os::raw::c_int>>(), + 4usize, + concat!( + "Alignment of template specialization: ", + stringify!(WithDtor<::std::os::raw::c_int>) + ) + ); } diff --git a/tests/expectations/tests/template_alias.rs b/tests/expectations/tests/template_alias.rs index c3f080db..9b66adf6 100644 --- a/tests/expectations/tests/template_alias.rs +++ b/tests/expectations/tests/template_alias.rs @@ -11,6 +11,8 @@ pub struct JS_Rooted<T> { pub ptr: JS_detail_Wrapped<T>, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } -impl <T> Default for JS_Rooted<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for JS_Rooted<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/template_alias_namespace.rs b/tests/expectations/tests/template_alias_namespace.rs index a9cd315d..dc03a231 100644 --- a/tests/expectations/tests/template_alias_namespace.rs +++ b/tests/expectations/tests/template_alias_namespace.rs @@ -22,8 +22,10 @@ pub mod root { pub ptr: root::JS::detail::Wrapped<T>, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } - impl <T> Default for Rooted<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + impl<T> Default for Rooted<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } } } diff --git a/tests/expectations/tests/template_partial_specification.rs b/tests/expectations/tests/template_partial_specification.rs index 2ca90d40..5dcc6c40 100644 --- a/tests/expectations/tests/template_partial_specification.rs +++ b/tests/expectations/tests/template_partial_specification.rs @@ -2,6 +2,3 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - - diff --git a/tests/expectations/tests/template_typedef_transitive_param.rs b/tests/expectations/tests/template_typedef_transitive_param.rs index 7768d522..311dd974 100644 --- a/tests/expectations/tests/template_typedef_transitive_param.rs +++ b/tests/expectations/tests/template_typedef_transitive_param.rs @@ -15,7 +15,9 @@ pub struct Wrapper_Wrapped<T> { pub t: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } -impl <T> Default for Wrapper_Wrapped<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for Wrapper_Wrapped<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } pub type Wrapper_Type<T> = Wrapper_Wrapped<T>; diff --git a/tests/expectations/tests/test_multiple_header_calls_in_builder.rs b/tests/expectations/tests/test_multiple_header_calls_in_builder.rs index 88dc5d8b..c53d5de3 100644 --- a/tests/expectations/tests/test_multiple_header_calls_in_builder.rs +++ b/tests/expectations/tests/test_multiple_header_calls_in_builder.rs @@ -3,11 +3,10 @@ extern "C" { #[link_name = "\u{1}foo"] pub static mut foo: - ::std::option::Option<unsafe extern "C" fn(x: - ::std::os::raw::c_int, - y: - ::std::os::raw::c_int) - -> ::std::os::raw::c_int>; + ::std::option::Option< + unsafe extern "C" fn(x: ::std::os::raw::c_int, y: ::std::os::raw::c_int) + -> ::std::os::raw::c_int, + >; } pub type Char = ::std::os::raw::c_char; pub type SChar = ::std::os::raw::c_schar; @@ -30,71 +29,139 @@ pub struct Test { } #[test] fn bindgen_test_layout_Test() { - assert_eq!(::std::mem::size_of::<Test>() , 12usize , concat ! ( - "Size of: " , stringify ! ( Test ) )); - assert_eq! (::std::mem::align_of::<Test>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Test ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . ch as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( ch ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . u as * const _ as usize } , - 1usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( u ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . d as * const _ as usize } , - 2usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( d ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . cch as * const _ as usize } , - 3usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( cch ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . cu as * const _ as usize } , - 4usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( cu ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . cd as * const _ as usize } , - 5usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( cd ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . Cch as * const _ as usize } , - 6usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( Cch ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . Cu as * const _ as usize } , - 7usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( Cu ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . Cd as * const _ as usize } , - 8usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( Cd ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . Ccch as * const _ as usize } , - 9usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( Ccch ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . Ccu as * const _ as usize } , - 10usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( Ccu ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . Ccd as * const _ as usize } , - 11usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( Ccd ) )); + assert_eq!( + ::std::mem::size_of::<Test>(), + 12usize, + concat!("Size of: ", stringify!(Test)) + ); + assert_eq!( + ::std::mem::align_of::<Test>(), + 1usize, + concat!("Alignment of ", stringify!(Test)) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).ch as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(ch) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).u as *const _ as usize }, + 1usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(u) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).d as *const _ as usize }, + 2usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(d) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).cch as *const _ as usize }, + 3usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(cch) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).cu as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(cu) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).cd as *const _ as usize }, + 5usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(cd) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).Cch as *const _ as usize }, + 6usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(Cch) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).Cu as *const _ as usize }, + 7usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(Cu) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).Cd as *const _ as usize }, + 8usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(Cd) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).Ccch as *const _ as usize }, + 9usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(Ccch) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).Ccu as *const _ as usize }, + 10usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(Ccu) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).Ccd as *const _ as usize }, + 11usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(Ccd) + ) + ); } impl Clone for Test { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/type-referenced-by-whitelisted-function.rs b/tests/expectations/tests/type-referenced-by-whitelisted-function.rs index 63d64654..3334eff5 100644 --- a/tests/expectations/tests/type-referenced-by-whitelisted-function.rs +++ b/tests/expectations/tests/type-referenced-by-whitelisted-function.rs @@ -11,18 +11,31 @@ pub struct dl_phdr_info { } #[test] fn bindgen_test_layout_dl_phdr_info() { - assert_eq!(::std::mem::size_of::<dl_phdr_info>() , 4usize , concat ! ( - "Size of: " , stringify ! ( dl_phdr_info ) )); - assert_eq! (::std::mem::align_of::<dl_phdr_info>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( dl_phdr_info ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const dl_phdr_info ) ) . x as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( dl_phdr_info ) , "::" , - stringify ! ( x ) )); + assert_eq!( + ::std::mem::size_of::<dl_phdr_info>(), + 4usize, + concat!("Size of: ", stringify!(dl_phdr_info)) + ); + assert_eq!( + ::std::mem::align_of::<dl_phdr_info>(), + 4usize, + concat!("Alignment of ", stringify!(dl_phdr_info)) + ); + assert_eq!( + unsafe { &(*(0 as *const dl_phdr_info)).x as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(dl_phdr_info), + "::", + stringify!(x) + ) + ); } impl Clone for dl_phdr_info { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } extern "C" { pub fn dl_iterate_phdr(arg1: *mut dl_phdr_info) -> ::std::os::raw::c_int; diff --git a/tests/expectations/tests/type_alias_partial_template_especialization.rs b/tests/expectations/tests/type_alias_partial_template_especialization.rs index 21d198a6..0a2e80fb 100644 --- a/tests/expectations/tests/type_alias_partial_template_especialization.rs +++ b/tests/expectations/tests/type_alias_partial_template_especialization.rs @@ -11,6 +11,8 @@ pub struct Rooted<T> { pub ptr: MaybeWrapped<T>, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } -impl <T> Default for Rooted<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for Rooted<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/typeref.rs b/tests/expectations/tests/typeref.rs index 2bbdcbb1..f8ed525b 100644 --- a/tests/expectations/tests/typeref.rs +++ b/tests/expectations/tests/typeref.rs @@ -11,20 +11,31 @@ pub struct mozilla_FragmentOrURL { } #[test] fn bindgen_test_layout_mozilla_FragmentOrURL() { - assert_eq!(::std::mem::size_of::<mozilla_FragmentOrURL>() , 1usize , - concat ! ( "Size of: " , stringify ! ( mozilla_FragmentOrURL ) - )); - assert_eq! (::std::mem::align_of::<mozilla_FragmentOrURL>() , 1usize , - concat ! ( - "Alignment of " , stringify ! ( mozilla_FragmentOrURL ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const mozilla_FragmentOrURL ) ) . mIsLocalRef - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( mozilla_FragmentOrURL ) - , "::" , stringify ! ( mIsLocalRef ) )); + assert_eq!( + ::std::mem::size_of::<mozilla_FragmentOrURL>(), + 1usize, + concat!("Size of: ", stringify!(mozilla_FragmentOrURL)) + ); + assert_eq!( + ::std::mem::align_of::<mozilla_FragmentOrURL>(), + 1usize, + concat!("Alignment of ", stringify!(mozilla_FragmentOrURL)) + ); + assert_eq!( + unsafe { &(*(0 as *const mozilla_FragmentOrURL)).mIsLocalRef as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(mozilla_FragmentOrURL), + "::", + stringify!(mIsLocalRef) + ) + ); } impl Clone for mozilla_FragmentOrURL { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] @@ -33,13 +44,21 @@ pub struct mozilla_Position { } #[test] fn bindgen_test_layout_mozilla_Position() { - assert_eq!(::std::mem::size_of::<mozilla_Position>() , 1usize , concat ! ( - "Size of: " , stringify ! ( mozilla_Position ) )); - assert_eq! (::std::mem::align_of::<mozilla_Position>() , 1usize , concat ! - ( "Alignment of " , stringify ! ( mozilla_Position ) )); + assert_eq!( + ::std::mem::size_of::<mozilla_Position>(), + 1usize, + concat!("Size of: ", stringify!(mozilla_Position)) + ); + assert_eq!( + ::std::mem::align_of::<mozilla_Position>(), + 1usize, + concat!("Alignment of ", stringify!(mozilla_Position)) + ); } impl Clone for mozilla_Position { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] pub struct mozilla_StyleShapeSource { @@ -52,10 +71,14 @@ pub union mozilla_StyleShapeSource__bindgen_ty_1 { _bindgen_union_align: u64, } impl Default for mozilla_StyleShapeSource__bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } impl Default for mozilla_StyleShapeSource { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] @@ -64,21 +87,36 @@ pub struct Bar { } #[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 ) ) . mFoo as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Bar ) , "::" , - stringify ! ( mFoo ) )); + 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)).mFoo as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Bar), + "::", + stringify!(mFoo) + ) + ); } impl Clone for Bar { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for Bar { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] pub struct nsFoo { @@ -86,27 +124,48 @@ pub struct nsFoo { } #[test] fn bindgen_test_layout_nsFoo() { - assert_eq!(::std::mem::size_of::<nsFoo>() , 8usize , concat ! ( - "Size of: " , stringify ! ( nsFoo ) )); - assert_eq! (::std::mem::align_of::<nsFoo>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( nsFoo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const nsFoo ) ) . mBar as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( nsFoo ) , "::" , - stringify ! ( mBar ) )); + assert_eq!( + ::std::mem::size_of::<nsFoo>(), + 8usize, + concat!("Size of: ", stringify!(nsFoo)) + ); + assert_eq!( + ::std::mem::align_of::<nsFoo>(), + 8usize, + concat!("Alignment of ", stringify!(nsFoo)) + ); + assert_eq!( + unsafe { &(*(0 as *const nsFoo)).mBar as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(nsFoo), + "::", + stringify!(mBar) + ) + ); } impl Default for nsFoo { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[test] fn __bindgen_test_layout_mozilla_StyleShapeSource_open0_int_close0_instantiation() { - assert_eq!(::std::mem::size_of::<mozilla_StyleShapeSource>() , 8usize , - concat ! ( - "Size of template specialization: " , stringify ! ( - mozilla_StyleShapeSource ) )); - assert_eq!(::std::mem::align_of::<mozilla_StyleShapeSource>() , 8usize , - concat ! ( - "Alignment of template specialization: " , stringify ! ( - mozilla_StyleShapeSource ) )); + assert_eq!( + ::std::mem::size_of::<mozilla_StyleShapeSource>(), + 8usize, + concat!( + "Size of template specialization: ", + stringify!(mozilla_StyleShapeSource) + ) + ); + assert_eq!( + ::std::mem::align_of::<mozilla_StyleShapeSource>(), + 8usize, + concat!( + "Alignment of template specialization: ", + stringify!(mozilla_StyleShapeSource) + ) + ); } diff --git a/tests/expectations/tests/typeref_1_0.rs b/tests/expectations/tests/typeref_1_0.rs index a99df0ad..6796ced8 100644 --- a/tests/expectations/tests/typeref_1_0.rs +++ b/tests/expectations/tests/typeref_1_0.rs @@ -6,35 +6,47 @@ #[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(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct mozilla_FragmentOrURL { @@ -42,20 +54,31 @@ pub struct mozilla_FragmentOrURL { } #[test] fn bindgen_test_layout_mozilla_FragmentOrURL() { - assert_eq!(::std::mem::size_of::<mozilla_FragmentOrURL>() , 1usize , - concat ! ( "Size of: " , stringify ! ( mozilla_FragmentOrURL ) - )); - assert_eq! (::std::mem::align_of::<mozilla_FragmentOrURL>() , 1usize , - concat ! ( - "Alignment of " , stringify ! ( mozilla_FragmentOrURL ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const mozilla_FragmentOrURL ) ) . mIsLocalRef - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( mozilla_FragmentOrURL ) - , "::" , stringify ! ( mIsLocalRef ) )); + assert_eq!( + ::std::mem::size_of::<mozilla_FragmentOrURL>(), + 1usize, + concat!("Size of: ", stringify!(mozilla_FragmentOrURL)) + ); + assert_eq!( + ::std::mem::align_of::<mozilla_FragmentOrURL>(), + 1usize, + concat!("Alignment of ", stringify!(mozilla_FragmentOrURL)) + ); + assert_eq!( + unsafe { &(*(0 as *const mozilla_FragmentOrURL)).mIsLocalRef as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(mozilla_FragmentOrURL), + "::", + stringify!(mIsLocalRef) + ) + ); } impl Clone for mozilla_FragmentOrURL { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] @@ -64,13 +87,21 @@ pub struct mozilla_Position { } #[test] fn bindgen_test_layout_mozilla_Position() { - assert_eq!(::std::mem::size_of::<mozilla_Position>() , 1usize , concat ! ( - "Size of: " , stringify ! ( mozilla_Position ) )); - assert_eq! (::std::mem::align_of::<mozilla_Position>() , 1usize , concat ! - ( "Alignment of " , stringify ! ( mozilla_Position ) )); + assert_eq!( + ::std::mem::size_of::<mozilla_Position>(), + 1usize, + concat!("Size of: ", stringify!(mozilla_Position)) + ); + assert_eq!( + ::std::mem::align_of::<mozilla_Position>(), + 1usize, + concat!("Alignment of ", stringify!(mozilla_Position)) + ); } impl Clone for mozilla_Position { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] @@ -91,21 +122,36 @@ pub struct Bar { } #[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 ) ) . mFoo as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Bar ) , "::" , - stringify ! ( mFoo ) )); + 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)).mFoo as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Bar), + "::", + stringify!(mFoo) + ) + ); } impl Clone for Bar { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for Bar { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] @@ -114,27 +160,48 @@ pub struct nsFoo { } #[test] fn bindgen_test_layout_nsFoo() { - assert_eq!(::std::mem::size_of::<nsFoo>() , 8usize , concat ! ( - "Size of: " , stringify ! ( nsFoo ) )); - assert_eq! (::std::mem::align_of::<nsFoo>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( nsFoo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const nsFoo ) ) . mBar as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( nsFoo ) , "::" , - stringify ! ( mBar ) )); + assert_eq!( + ::std::mem::size_of::<nsFoo>(), + 8usize, + concat!("Size of: ", stringify!(nsFoo)) + ); + assert_eq!( + ::std::mem::align_of::<nsFoo>(), + 8usize, + concat!("Alignment of ", stringify!(nsFoo)) + ); + assert_eq!( + unsafe { &(*(0 as *const nsFoo)).mBar as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(nsFoo), + "::", + stringify!(mBar) + ) + ); } impl Clone for nsFoo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn __bindgen_test_layout_mozilla_StyleShapeSource_open0_int_close0_instantiation() { - assert_eq!(::std::mem::size_of::<mozilla_StyleShapeSource>() , 8usize , - concat ! ( - "Size of template specialization: " , stringify ! ( - mozilla_StyleShapeSource ) )); - assert_eq!(::std::mem::align_of::<mozilla_StyleShapeSource>() , 8usize , - concat ! ( - "Alignment of template specialization: " , stringify ! ( - mozilla_StyleShapeSource ) )); + assert_eq!( + ::std::mem::size_of::<mozilla_StyleShapeSource>(), + 8usize, + concat!( + "Size of template specialization: ", + stringify!(mozilla_StyleShapeSource) + ) + ); + assert_eq!( + ::std::mem::align_of::<mozilla_StyleShapeSource>(), + 8usize, + concat!( + "Alignment of template specialization: ", + stringify!(mozilla_StyleShapeSource) + ) + ); } diff --git a/tests/expectations/tests/union-in-ns.rs b/tests/expectations/tests/union-in-ns.rs index cb8779bd..a29b5038 100644 --- a/tests/expectations/tests/union-in-ns.rs +++ b/tests/expectations/tests/union-in-ns.rs @@ -16,20 +16,35 @@ pub mod root { } #[test] fn bindgen_test_layout_bar() { - assert_eq!(::std::mem::size_of::<bar>() , 4usize , concat ! ( - "Size of: " , stringify ! ( bar ) )); - assert_eq! (::std::mem::align_of::<bar>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( bar ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const bar ) ) . baz as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( bar ) , "::" , - stringify ! ( baz ) )); + assert_eq!( + ::std::mem::size_of::<bar>(), + 4usize, + concat!("Size of: ", stringify!(bar)) + ); + assert_eq!( + ::std::mem::align_of::<bar>(), + 4usize, + concat!("Alignment of ", stringify!(bar)) + ); + assert_eq!( + unsafe { &(*(0 as *const bar)).baz as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(bar), + "::", + stringify!(baz) + ) + ); } impl Clone for bar { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for bar { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } } diff --git a/tests/expectations/tests/union-in-ns_1_0.rs b/tests/expectations/tests/union-in-ns_1_0.rs index b3618ab7..ec2014a5 100644 --- a/tests/expectations/tests/union-in-ns_1_0.rs +++ b/tests/expectations/tests/union-in-ns_1_0.rs @@ -8,39 +8,47 @@ pub mod root { #[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) } #[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) } } - 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> {} #[allow(unused_imports)] use self::super::root; #[repr(C)] @@ -51,17 +59,30 @@ pub mod root { } #[test] fn bindgen_test_layout_bar() { - assert_eq!(::std::mem::size_of::<bar>() , 4usize , concat ! ( - "Size of: " , stringify ! ( bar ) )); - assert_eq! (::std::mem::align_of::<bar>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( bar ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const bar ) ) . baz as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( bar ) , "::" , - stringify ! ( baz ) )); + assert_eq!( + ::std::mem::size_of::<bar>(), + 4usize, + concat!("Size of: ", stringify!(bar)) + ); + assert_eq!( + ::std::mem::align_of::<bar>(), + 4usize, + concat!("Alignment of ", stringify!(bar)) + ); + assert_eq!( + unsafe { &(*(0 as *const bar)).baz as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(bar), + "::", + stringify!(baz) + ) + ); } impl Clone for bar { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } } diff --git a/tests/expectations/tests/union_dtor.rs b/tests/expectations/tests/union_dtor.rs index 0721494f..e62521bc 100644 --- a/tests/expectations/tests/union_dtor.rs +++ b/tests/expectations/tests/union_dtor.rs @@ -12,27 +12,45 @@ pub union UnionWithDtor { } #[test] fn bindgen_test_layout_UnionWithDtor() { - assert_eq!(::std::mem::size_of::<UnionWithDtor>() , 8usize , concat ! ( - "Size of: " , stringify ! ( UnionWithDtor ) )); - assert_eq! (::std::mem::align_of::<UnionWithDtor>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( UnionWithDtor ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const UnionWithDtor ) ) . mFoo as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( UnionWithDtor ) , "::" - , stringify ! ( mFoo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const UnionWithDtor ) ) . mBar as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( UnionWithDtor ) , "::" - , stringify ! ( mBar ) )); + assert_eq!( + ::std::mem::size_of::<UnionWithDtor>(), + 8usize, + concat!("Size of: ", stringify!(UnionWithDtor)) + ); + assert_eq!( + ::std::mem::align_of::<UnionWithDtor>(), + 8usize, + concat!("Alignment of ", stringify!(UnionWithDtor)) + ); + assert_eq!( + unsafe { &(*(0 as *const UnionWithDtor)).mFoo as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(UnionWithDtor), + "::", + stringify!(mFoo) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const UnionWithDtor)).mBar as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(UnionWithDtor), + "::", + stringify!(mBar) + ) + ); } extern "C" { #[link_name = "\u{1}_ZN13UnionWithDtorD1Ev"] pub fn UnionWithDtor_UnionWithDtor_destructor(this: *mut UnionWithDtor); } impl Default for UnionWithDtor { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } impl UnionWithDtor { #[inline] diff --git a/tests/expectations/tests/union_dtor_1_0.rs b/tests/expectations/tests/union_dtor_1_0.rs index c59d4f35..f7896dc7 100644 --- a/tests/expectations/tests/union_dtor_1_0.rs +++ b/tests/expectations/tests/union_dtor_1_0.rs @@ -6,35 +6,47 @@ #[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(Debug, Default)] pub struct UnionWithDtor { @@ -44,20 +56,36 @@ pub struct UnionWithDtor { } #[test] fn bindgen_test_layout_UnionWithDtor() { - assert_eq!(::std::mem::size_of::<UnionWithDtor>() , 8usize , concat ! ( - "Size of: " , stringify ! ( UnionWithDtor ) )); - assert_eq! (::std::mem::align_of::<UnionWithDtor>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( UnionWithDtor ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const UnionWithDtor ) ) . mFoo as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( UnionWithDtor ) , "::" - , stringify ! ( mFoo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const UnionWithDtor ) ) . mBar as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( UnionWithDtor ) , "::" - , stringify ! ( mBar ) )); + assert_eq!( + ::std::mem::size_of::<UnionWithDtor>(), + 8usize, + concat!("Size of: ", stringify!(UnionWithDtor)) + ); + assert_eq!( + ::std::mem::align_of::<UnionWithDtor>(), + 8usize, + concat!("Alignment of ", stringify!(UnionWithDtor)) + ); + assert_eq!( + unsafe { &(*(0 as *const UnionWithDtor)).mFoo as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(UnionWithDtor), + "::", + stringify!(mFoo) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const UnionWithDtor)).mBar as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(UnionWithDtor), + "::", + stringify!(mBar) + ) + ); } extern "C" { #[link_name = "\u{1}_ZN13UnionWithDtorD1Ev"] diff --git a/tests/expectations/tests/union_fields.rs b/tests/expectations/tests/union_fields.rs index 90319ee6..988b7ae8 100644 --- a/tests/expectations/tests/union_fields.rs +++ b/tests/expectations/tests/union_fields.rs @@ -14,29 +14,54 @@ pub union nsStyleUnion { } #[test] fn bindgen_test_layout_nsStyleUnion() { - assert_eq!(::std::mem::size_of::<nsStyleUnion>() , 8usize , concat ! ( - "Size of: " , stringify ! ( nsStyleUnion ) )); - assert_eq! (::std::mem::align_of::<nsStyleUnion>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( nsStyleUnion ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const nsStyleUnion ) ) . mInt as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( nsStyleUnion ) , "::" , - stringify ! ( mInt ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const nsStyleUnion ) ) . mFloat as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( nsStyleUnion ) , "::" , - stringify ! ( mFloat ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const nsStyleUnion ) ) . mPointer as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( nsStyleUnion ) , "::" , - stringify ! ( mPointer ) )); + assert_eq!( + ::std::mem::size_of::<nsStyleUnion>(), + 8usize, + concat!("Size of: ", stringify!(nsStyleUnion)) + ); + assert_eq!( + ::std::mem::align_of::<nsStyleUnion>(), + 8usize, + concat!("Alignment of ", stringify!(nsStyleUnion)) + ); + assert_eq!( + unsafe { &(*(0 as *const nsStyleUnion)).mInt as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(nsStyleUnion), + "::", + stringify!(mInt) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const nsStyleUnion)).mFloat as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(nsStyleUnion), + "::", + stringify!(mFloat) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const nsStyleUnion)).mPointer as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(nsStyleUnion), + "::", + stringify!(mPointer) + ) + ); } impl Clone for nsStyleUnion { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for nsStyleUnion { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/union_fields_1_0.rs b/tests/expectations/tests/union_fields_1_0.rs index 3f244b78..1e10ff97 100644 --- a/tests/expectations/tests/union_fields_1_0.rs +++ b/tests/expectations/tests/union_fields_1_0.rs @@ -6,35 +6,47 @@ #[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(Debug, Default, Copy, Hash, PartialEq)] pub struct nsStyleUnion { @@ -45,26 +57,49 @@ pub struct nsStyleUnion { } #[test] fn bindgen_test_layout_nsStyleUnion() { - assert_eq!(::std::mem::size_of::<nsStyleUnion>() , 8usize , concat ! ( - "Size of: " , stringify ! ( nsStyleUnion ) )); - assert_eq! (::std::mem::align_of::<nsStyleUnion>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( nsStyleUnion ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const nsStyleUnion ) ) . mInt as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( nsStyleUnion ) , "::" , - stringify ! ( mInt ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const nsStyleUnion ) ) . mFloat as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( nsStyleUnion ) , "::" , - stringify ! ( mFloat ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const nsStyleUnion ) ) . mPointer as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( nsStyleUnion ) , "::" , - stringify ! ( mPointer ) )); + assert_eq!( + ::std::mem::size_of::<nsStyleUnion>(), + 8usize, + concat!("Size of: ", stringify!(nsStyleUnion)) + ); + assert_eq!( + ::std::mem::align_of::<nsStyleUnion>(), + 8usize, + concat!("Alignment of ", stringify!(nsStyleUnion)) + ); + assert_eq!( + unsafe { &(*(0 as *const nsStyleUnion)).mInt as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(nsStyleUnion), + "::", + stringify!(mInt) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const nsStyleUnion)).mFloat as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(nsStyleUnion), + "::", + stringify!(mFloat) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const nsStyleUnion)).mPointer as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(nsStyleUnion), + "::", + stringify!(mPointer) + ) + ); } impl Clone for nsStyleUnion { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/union_template.rs b/tests/expectations/tests/union_template.rs index f6418fd6..515d5688 100644 --- a/tests/expectations/tests/union_template.rs +++ b/tests/expectations/tests/union_template.rs @@ -17,7 +17,9 @@ pub union NastyStruct__bindgen_ty_1 { _bindgen_union_align: u64, } impl Default for NastyStruct__bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] pub union NastyStruct__bindgen_ty_2 { @@ -26,10 +28,14 @@ pub union NastyStruct__bindgen_ty_2 { _bindgen_union_align: u64, } impl Default for NastyStruct__bindgen_ty_2 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } impl Default for NastyStruct { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] pub union Whatever { @@ -38,5 +44,7 @@ pub union Whatever { _bindgen_union_align: u64, } impl Default for Whatever { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/union_template_1_0.rs b/tests/expectations/tests/union_template_1_0.rs index afe14c70..7b350b07 100644 --- a/tests/expectations/tests/union_template_1_0.rs +++ b/tests/expectations/tests/union_template_1_0.rs @@ -6,35 +6,47 @@ #[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(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct NastyStruct { diff --git a/tests/expectations/tests/union_with_anon_struct.rs b/tests/expectations/tests/union_with_anon_struct.rs index d48538a0..320ce820 100644 --- a/tests/expectations/tests/union_with_anon_struct.rs +++ b/tests/expectations/tests/union_with_anon_struct.rs @@ -18,39 +18,72 @@ pub struct foo__bindgen_ty_1 { } #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 8usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as - usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1>(), + 8usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).a as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(a) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).b as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(b) + ) + ); } impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::<foo>() , 8usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::<foo>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bar ) )); + assert_eq!( + ::std::mem::size_of::<foo>(), + 8usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::<foo>(), + 4usize, + concat!("Alignment of ", stringify!(foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).bar as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo), + "::", + stringify!(bar) + ) + ); } impl Clone for foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for foo { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/union_with_anon_struct_1_0.rs b/tests/expectations/tests/union_with_anon_struct_1_0.rs index 8c0971f7..b79be127 100644 --- a/tests/expectations/tests/union_with_anon_struct_1_0.rs +++ b/tests/expectations/tests/union_with_anon_struct_1_0.rs @@ -6,35 +6,47 @@ #[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(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo { @@ -49,36 +61,67 @@ pub struct foo__bindgen_ty_1 { } #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 8usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as - usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1>(), + 8usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).a as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(a) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).b as *const _ as usize }, + 4usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(b) + ) + ); } impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::<foo>() , 8usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::<foo>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bar ) )); + assert_eq!( + ::std::mem::size_of::<foo>(), + 8usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::<foo>(), + 4usize, + concat!("Alignment of ", stringify!(foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).bar as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo), + "::", + stringify!(bar) + ) + ); } impl Clone for foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/union_with_anon_union.rs b/tests/expectations/tests/union_with_anon_union.rs index 29dbe7dc..cb78c900 100644 --- a/tests/expectations/tests/union_with_anon_union.rs +++ b/tests/expectations/tests/union_with_anon_union.rs @@ -19,42 +19,77 @@ pub union foo__bindgen_ty_1 { } #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 4usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1>(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).a as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(a) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).b as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(b) + ) + ); } impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for foo__bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[test] fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::<foo>() , 4usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::<foo>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bar ) )); + assert_eq!( + ::std::mem::size_of::<foo>(), + 4usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::<foo>(), + 4usize, + concat!("Alignment of ", stringify!(foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).bar as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo), + "::", + stringify!(bar) + ) + ); } impl Clone for foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for foo { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/union_with_anon_union_1_0.rs b/tests/expectations/tests/union_with_anon_union_1_0.rs index 62a62f85..958d8e67 100644 --- a/tests/expectations/tests/union_with_anon_union_1_0.rs +++ b/tests/expectations/tests/union_with_anon_union_1_0.rs @@ -6,35 +6,47 @@ #[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(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo { @@ -50,36 +62,67 @@ pub struct foo__bindgen_ty_1 { } #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 4usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1>(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).a as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(a) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).b as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(b) + ) + ); } impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::<foo>() , 4usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::<foo>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bar ) )); + assert_eq!( + ::std::mem::size_of::<foo>(), + 4usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::<foo>(), + 4usize, + concat!("Alignment of ", stringify!(foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).bar as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo), + "::", + stringify!(bar) + ) + ); } impl Clone for foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/union_with_anon_unnamed_struct.rs b/tests/expectations/tests/union_with_anon_unnamed_struct.rs index 61b36d1a..8dd829e2 100644 --- a/tests/expectations/tests/union_with_anon_unnamed_struct.rs +++ b/tests/expectations/tests/union_with_anon_unnamed_struct.rs @@ -21,50 +21,92 @@ pub struct pixel__bindgen_ty_1 { } #[test] fn bindgen_test_layout_pixel__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<pixel__bindgen_ty_1>() , 4usize , concat - ! ( "Size of: " , stringify ! ( pixel__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<pixel__bindgen_ty_1>() , 1usize , - concat ! ( - "Alignment of " , stringify ! ( pixel__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const pixel__bindgen_ty_1 ) ) . r as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( pixel__bindgen_ty_1 ) , - "::" , stringify ! ( r ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const pixel__bindgen_ty_1 ) ) . g as * const _ - as usize } , 1usize , concat ! ( - "Alignment of field: " , stringify ! ( pixel__bindgen_ty_1 ) , - "::" , stringify ! ( g ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const pixel__bindgen_ty_1 ) ) . b as * const _ - as usize } , 2usize , concat ! ( - "Alignment of field: " , stringify ! ( pixel__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const pixel__bindgen_ty_1 ) ) . a as * const _ - as usize } , 3usize , concat ! ( - "Alignment of field: " , stringify ! ( pixel__bindgen_ty_1 ) , - "::" , stringify ! ( a ) )); + assert_eq!( + ::std::mem::size_of::<pixel__bindgen_ty_1>(), + 4usize, + concat!("Size of: ", stringify!(pixel__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<pixel__bindgen_ty_1>(), + 1usize, + concat!("Alignment of ", stringify!(pixel__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const pixel__bindgen_ty_1)).r as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(pixel__bindgen_ty_1), + "::", + stringify!(r) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const pixel__bindgen_ty_1)).g as *const _ as usize }, + 1usize, + concat!( + "Alignment of field: ", + stringify!(pixel__bindgen_ty_1), + "::", + stringify!(g) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const pixel__bindgen_ty_1)).b as *const _ as usize }, + 2usize, + concat!( + "Alignment of field: ", + stringify!(pixel__bindgen_ty_1), + "::", + stringify!(b) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const pixel__bindgen_ty_1)).a as *const _ as usize }, + 3usize, + concat!( + "Alignment of field: ", + stringify!(pixel__bindgen_ty_1), + "::", + stringify!(a) + ) + ); } impl Clone for pixel__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_pixel() { - assert_eq!(::std::mem::size_of::<pixel>() , 4usize , concat ! ( - "Size of: " , stringify ! ( pixel ) )); - assert_eq! (::std::mem::align_of::<pixel>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( pixel ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const pixel ) ) . rgba as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( pixel ) , "::" , - stringify ! ( rgba ) )); + assert_eq!( + ::std::mem::size_of::<pixel>(), + 4usize, + concat!("Size of: ", stringify!(pixel)) + ); + assert_eq!( + ::std::mem::align_of::<pixel>(), + 4usize, + concat!("Alignment of ", stringify!(pixel)) + ); + assert_eq!( + unsafe { &(*(0 as *const pixel)).rgba as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(pixel), + "::", + stringify!(rgba) + ) + ); } impl Clone for pixel { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for pixel { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs b/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs index 45d824ba..d0dc0088 100644 --- a/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs +++ b/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs @@ -6,35 +6,47 @@ #[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(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct pixel { @@ -52,47 +64,87 @@ pub struct pixel__bindgen_ty_1 { } #[test] fn bindgen_test_layout_pixel__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<pixel__bindgen_ty_1>() , 4usize , concat - ! ( "Size of: " , stringify ! ( pixel__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<pixel__bindgen_ty_1>() , 1usize , - concat ! ( - "Alignment of " , stringify ! ( pixel__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const pixel__bindgen_ty_1 ) ) . r as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( pixel__bindgen_ty_1 ) , - "::" , stringify ! ( r ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const pixel__bindgen_ty_1 ) ) . g as * const _ - as usize } , 1usize , concat ! ( - "Alignment of field: " , stringify ! ( pixel__bindgen_ty_1 ) , - "::" , stringify ! ( g ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const pixel__bindgen_ty_1 ) ) . b as * const _ - as usize } , 2usize , concat ! ( - "Alignment of field: " , stringify ! ( pixel__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const pixel__bindgen_ty_1 ) ) . a as * const _ - as usize } , 3usize , concat ! ( - "Alignment of field: " , stringify ! ( pixel__bindgen_ty_1 ) , - "::" , stringify ! ( a ) )); + assert_eq!( + ::std::mem::size_of::<pixel__bindgen_ty_1>(), + 4usize, + concat!("Size of: ", stringify!(pixel__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<pixel__bindgen_ty_1>(), + 1usize, + concat!("Alignment of ", stringify!(pixel__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const pixel__bindgen_ty_1)).r as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(pixel__bindgen_ty_1), + "::", + stringify!(r) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const pixel__bindgen_ty_1)).g as *const _ as usize }, + 1usize, + concat!( + "Alignment of field: ", + stringify!(pixel__bindgen_ty_1), + "::", + stringify!(g) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const pixel__bindgen_ty_1)).b as *const _ as usize }, + 2usize, + concat!( + "Alignment of field: ", + stringify!(pixel__bindgen_ty_1), + "::", + stringify!(b) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const pixel__bindgen_ty_1)).a as *const _ as usize }, + 3usize, + concat!( + "Alignment of field: ", + stringify!(pixel__bindgen_ty_1), + "::", + stringify!(a) + ) + ); } impl Clone for pixel__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_pixel() { - assert_eq!(::std::mem::size_of::<pixel>() , 4usize , concat ! ( - "Size of: " , stringify ! ( pixel ) )); - assert_eq! (::std::mem::align_of::<pixel>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( pixel ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const pixel ) ) . rgba as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( pixel ) , "::" , - stringify ! ( rgba ) )); + assert_eq!( + ::std::mem::size_of::<pixel>(), + 4usize, + concat!("Size of: ", stringify!(pixel)) + ); + assert_eq!( + ::std::mem::align_of::<pixel>(), + 4usize, + concat!("Alignment of ", stringify!(pixel)) + ); + assert_eq!( + unsafe { &(*(0 as *const pixel)).rgba as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(pixel), + "::", + stringify!(rgba) + ) + ); } impl Clone for pixel { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/union_with_anon_unnamed_union.rs b/tests/expectations/tests/union_with_anon_unnamed_union.rs index 4e0f4a18..dea8b39e 100644 --- a/tests/expectations/tests/union_with_anon_unnamed_union.rs +++ b/tests/expectations/tests/union_with_anon_unnamed_union.rs @@ -20,42 +20,72 @@ pub union foo__bindgen_ty_1 { } #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 2usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1>() , 2usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . c as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( c ) )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1>(), + 2usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1>(), + 2usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).b as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(b) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).c as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(c) + ) + ); } impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for foo__bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[test] fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::<foo>() , 4usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::<foo>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( a ) )); + assert_eq!( + ::std::mem::size_of::<foo>(), + 4usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::<foo>(), + 4usize, + concat!("Alignment of ", stringify!(foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).a as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(foo), "::", stringify!(a)) + ); } impl Clone for foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for foo { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs b/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs index a33c1ccd..d746d45d 100644 --- a/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs +++ b/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs @@ -6,35 +6,47 @@ #[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(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo { @@ -51,36 +63,62 @@ pub struct foo__bindgen_ty_1 { } #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 2usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1>() , 2usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . c as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( c ) )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1>(), + 2usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1>(), + 2usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).b as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(b) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1)).c as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1), + "::", + stringify!(c) + ) + ); } impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::<foo>() , 4usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::<foo>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( a ) )); + assert_eq!( + ::std::mem::size_of::<foo>(), + 4usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::<foo>(), + 4usize, + concat!("Alignment of ", stringify!(foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).a as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(foo), "::", stringify!(a)) + ); } impl Clone for foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/union_with_big_member.rs b/tests/expectations/tests/union_with_big_member.rs index 9e86f429..d5d19a9b 100644 --- a/tests/expectations/tests/union_with_big_member.rs +++ b/tests/expectations/tests/union_with_big_member.rs @@ -13,26 +13,46 @@ pub union WithBigArray { } #[test] fn bindgen_test_layout_WithBigArray() { - assert_eq!(::std::mem::size_of::<WithBigArray>() , 132usize , concat ! ( - "Size of: " , stringify ! ( WithBigArray ) )); - assert_eq! (::std::mem::align_of::<WithBigArray>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( WithBigArray ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithBigArray ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( WithBigArray ) , "::" , - stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithBigArray ) ) . b as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( WithBigArray ) , "::" , - stringify ! ( b ) )); + assert_eq!( + ::std::mem::size_of::<WithBigArray>(), + 132usize, + concat!("Size of: ", stringify!(WithBigArray)) + ); + assert_eq!( + ::std::mem::align_of::<WithBigArray>(), + 4usize, + concat!("Alignment of ", stringify!(WithBigArray)) + ); + assert_eq!( + unsafe { &(*(0 as *const WithBigArray)).a as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(WithBigArray), + "::", + stringify!(a) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const WithBigArray)).b as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(WithBigArray), + "::", + stringify!(b) + ) + ); } impl Clone for WithBigArray { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for WithBigArray { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Copy)] @@ -43,26 +63,46 @@ pub union WithBigArray2 { } #[test] fn bindgen_test_layout_WithBigArray2() { - assert_eq!(::std::mem::size_of::<WithBigArray2>() , 36usize , concat ! ( - "Size of: " , stringify ! ( WithBigArray2 ) )); - assert_eq! (::std::mem::align_of::<WithBigArray2>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( WithBigArray2 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithBigArray2 ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( WithBigArray2 ) , "::" - , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithBigArray2 ) ) . b as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( WithBigArray2 ) , "::" - , stringify ! ( b ) )); + assert_eq!( + ::std::mem::size_of::<WithBigArray2>(), + 36usize, + concat!("Size of: ", stringify!(WithBigArray2)) + ); + assert_eq!( + ::std::mem::align_of::<WithBigArray2>(), + 4usize, + concat!("Alignment of ", stringify!(WithBigArray2)) + ); + assert_eq!( + unsafe { &(*(0 as *const WithBigArray2)).a as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(WithBigArray2), + "::", + stringify!(a) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const WithBigArray2)).b as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(WithBigArray2), + "::", + stringify!(b) + ) + ); } impl Clone for WithBigArray2 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for WithBigArray2 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Copy)] @@ -73,24 +113,44 @@ pub union WithBigMember { } #[test] fn bindgen_test_layout_WithBigMember() { - assert_eq!(::std::mem::size_of::<WithBigMember>() , 132usize , concat ! ( - "Size of: " , stringify ! ( WithBigMember ) )); - assert_eq! (::std::mem::align_of::<WithBigMember>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( WithBigMember ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithBigMember ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( WithBigMember ) , "::" - , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithBigMember ) ) . b as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( WithBigMember ) , "::" - , stringify ! ( b ) )); + assert_eq!( + ::std::mem::size_of::<WithBigMember>(), + 132usize, + concat!("Size of: ", stringify!(WithBigMember)) + ); + assert_eq!( + ::std::mem::align_of::<WithBigMember>(), + 4usize, + concat!("Alignment of ", stringify!(WithBigMember)) + ); + assert_eq!( + unsafe { &(*(0 as *const WithBigMember)).a as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(WithBigMember), + "::", + stringify!(a) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const WithBigMember)).b as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(WithBigMember), + "::", + stringify!(b) + ) + ); } impl Clone for WithBigMember { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for WithBigMember { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/union_with_big_member_1_0.rs b/tests/expectations/tests/union_with_big_member_1_0.rs index 03226cce..abf86dc8 100644 --- a/tests/expectations/tests/union_with_big_member_1_0.rs +++ b/tests/expectations/tests/union_with_big_member_1_0.rs @@ -6,35 +6,47 @@ #[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 WithBigArray { @@ -44,26 +56,46 @@ pub struct WithBigArray { } #[test] fn bindgen_test_layout_WithBigArray() { - assert_eq!(::std::mem::size_of::<WithBigArray>() , 132usize , concat ! ( - "Size of: " , stringify ! ( WithBigArray ) )); - assert_eq! (::std::mem::align_of::<WithBigArray>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( WithBigArray ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithBigArray ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( WithBigArray ) , "::" , - stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithBigArray ) ) . b as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( WithBigArray ) , "::" , - stringify ! ( b ) )); + assert_eq!( + ::std::mem::size_of::<WithBigArray>(), + 132usize, + concat!("Size of: ", stringify!(WithBigArray)) + ); + assert_eq!( + ::std::mem::align_of::<WithBigArray>(), + 4usize, + concat!("Alignment of ", stringify!(WithBigArray)) + ); + assert_eq!( + unsafe { &(*(0 as *const WithBigArray)).a as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(WithBigArray), + "::", + stringify!(a) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const WithBigArray)).b as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(WithBigArray), + "::", + stringify!(b) + ) + ); } impl Clone for WithBigArray { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for WithBigArray { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] @@ -74,23 +106,41 @@ pub struct WithBigArray2 { } #[test] fn bindgen_test_layout_WithBigArray2() { - assert_eq!(::std::mem::size_of::<WithBigArray2>() , 36usize , concat ! ( - "Size of: " , stringify ! ( WithBigArray2 ) )); - assert_eq! (::std::mem::align_of::<WithBigArray2>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( WithBigArray2 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithBigArray2 ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( WithBigArray2 ) , "::" - , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithBigArray2 ) ) . b as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( WithBigArray2 ) , "::" - , stringify ! ( b ) )); + assert_eq!( + ::std::mem::size_of::<WithBigArray2>(), + 36usize, + concat!("Size of: ", stringify!(WithBigArray2)) + ); + assert_eq!( + ::std::mem::align_of::<WithBigArray2>(), + 4usize, + concat!("Alignment of ", stringify!(WithBigArray2)) + ); + assert_eq!( + unsafe { &(*(0 as *const WithBigArray2)).a as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(WithBigArray2), + "::", + stringify!(a) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const WithBigArray2)).b as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(WithBigArray2), + "::", + stringify!(b) + ) + ); } impl Clone for WithBigArray2 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Copy)] @@ -101,24 +151,44 @@ pub struct WithBigMember { } #[test] fn bindgen_test_layout_WithBigMember() { - assert_eq!(::std::mem::size_of::<WithBigMember>() , 132usize , concat ! ( - "Size of: " , stringify ! ( WithBigMember ) )); - assert_eq! (::std::mem::align_of::<WithBigMember>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( WithBigMember ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithBigMember ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( WithBigMember ) , "::" - , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithBigMember ) ) . b as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( WithBigMember ) , "::" - , stringify ! ( b ) )); + assert_eq!( + ::std::mem::size_of::<WithBigMember>(), + 132usize, + concat!("Size of: ", stringify!(WithBigMember)) + ); + assert_eq!( + ::std::mem::align_of::<WithBigMember>(), + 4usize, + concat!("Alignment of ", stringify!(WithBigMember)) + ); + assert_eq!( + unsafe { &(*(0 as *const WithBigMember)).a as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(WithBigMember), + "::", + stringify!(a) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const WithBigMember)).b as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(WithBigMember), + "::", + stringify!(b) + ) + ); } impl Clone for WithBigMember { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for WithBigMember { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/union_with_nesting.rs b/tests/expectations/tests/union_with_nesting.rs index 7ba8afcb..9b27335d 100644 --- a/tests/expectations/tests/union_with_nesting.rs +++ b/tests/expectations/tests/union_with_nesting.rs @@ -26,32 +26,46 @@ pub union foo__bindgen_ty_1__bindgen_ty_1 { } #[test] fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1__bindgen_ty_1>() , - 2usize , concat ! ( - "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_1 ) - )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1__bindgen_ty_1>() , - 2usize , concat ! ( - "Alignment of " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_1 ) ) . b1 - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( b1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_1 ) ) . b2 - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( b2 ) - )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1__bindgen_ty_1>(), + 2usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1__bindgen_ty_1>(), + 2usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1__bindgen_ty_1)).b1 as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(b1) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1__bindgen_ty_1)).b2 as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(b2) + ) + ); } impl Clone for foo__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for foo__bindgen_ty_1__bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Copy)] @@ -62,61 +76,95 @@ pub union foo__bindgen_ty_1__bindgen_ty_2 { } #[test] fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_2() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1__bindgen_ty_2>() , - 2usize , concat ! ( - "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_2 ) - )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1__bindgen_ty_2>() , - 2usize , concat ! ( - "Alignment of " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_2 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . c1 - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( c1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . c2 - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( c2 ) - )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1__bindgen_ty_2>(), + 2usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1__bindgen_ty_2>(), + 2usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1__bindgen_ty_2)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1__bindgen_ty_2)).c1 as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(c1) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1__bindgen_ty_2)).c2 as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(c2) + ) + ); } impl Clone for foo__bindgen_ty_1__bindgen_ty_2 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for foo__bindgen_ty_1__bindgen_ty_2 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 4usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1>() , 2usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1>(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1>(), + 2usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1)) + ); } impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for foo__bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[test] fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::<foo>() , 4usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::<foo>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( a ) )); + assert_eq!( + ::std::mem::size_of::<foo>(), + 4usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::<foo>(), + 4usize, + concat!("Alignment of ", stringify!(foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).a as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(foo), "::", stringify!(a)) + ); } impl Clone for foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for foo { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/union_with_nesting_1_0.rs b/tests/expectations/tests/union_with_nesting_1_0.rs index 13870758..1667c07e 100644 --- a/tests/expectations/tests/union_with_nesting_1_0.rs +++ b/tests/expectations/tests/union_with_nesting_1_0.rs @@ -6,35 +6,47 @@ #[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(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct foo { @@ -57,29 +69,41 @@ pub struct foo__bindgen_ty_1__bindgen_ty_1 { } #[test] fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1__bindgen_ty_1>() , - 2usize , concat ! ( - "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_1 ) - )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1__bindgen_ty_1>() , - 2usize , concat ! ( - "Alignment of " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_1 ) ) . b1 - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( b1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_1 ) ) . b2 - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( b2 ) - )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1__bindgen_ty_1>(), + 2usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1__bindgen_ty_1>(), + 2usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1__bindgen_ty_1)).b1 as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(b1) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1__bindgen_ty_1)).b2 as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(b2) + ) + ); } impl Clone for foo__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] @@ -90,52 +114,80 @@ pub struct foo__bindgen_ty_1__bindgen_ty_2 { } #[test] fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_2() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1__bindgen_ty_2>() , - 2usize , concat ! ( - "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_2 ) - )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1__bindgen_ty_2>() , - 2usize , concat ! ( - "Alignment of " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_2 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . c1 - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( c1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . c2 - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( c2 ) - )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1__bindgen_ty_2>(), + 2usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1__bindgen_ty_2>(), + 2usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1__bindgen_ty_2)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1__bindgen_ty_2)).c1 as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(c1) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const foo__bindgen_ty_1__bindgen_ty_2)).c2 as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(c2) + ) + ); } impl Clone for foo__bindgen_ty_1__bindgen_ty_2 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 4usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1>() , 2usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq!( + ::std::mem::size_of::<foo__bindgen_ty_1>(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<foo__bindgen_ty_1>(), + 2usize, + concat!("Alignment of ", stringify!(foo__bindgen_ty_1)) + ); } impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[test] fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::<foo>() , 4usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::<foo>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( a ) )); + assert_eq!( + ::std::mem::size_of::<foo>(), + 4usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::<foo>(), + 4usize, + concat!("Alignment of ", stringify!(foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).a as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(foo), "::", stringify!(a)) + ); } impl Clone for foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/unknown_attr.rs b/tests/expectations/tests/unknown_attr.rs index dcd1e18e..5f7c1c30 100644 --- a/tests/expectations/tests/unknown_attr.rs +++ b/tests/expectations/tests/unknown_attr.rs @@ -14,21 +14,34 @@ pub struct max_align_t { } #[test] fn bindgen_test_layout_max_align_t() { - assert_eq!(::std::mem::size_of::<max_align_t>() , 32usize , concat ! ( - "Size of: " , stringify ! ( max_align_t ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const max_align_t ) ) . - __clang_max_align_nonce1 as * const _ as usize } , 0usize , - concat ! ( - "Alignment of field: " , stringify ! ( max_align_t ) , "::" , - stringify ! ( __clang_max_align_nonce1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const max_align_t ) ) . - __clang_max_align_nonce2 as * const _ as usize } , 16usize , - concat ! ( - "Alignment of field: " , stringify ! ( max_align_t ) , "::" , - stringify ! ( __clang_max_align_nonce2 ) )); + assert_eq!( + ::std::mem::size_of::<max_align_t>(), + 32usize, + concat!("Size of: ", stringify!(max_align_t)) + ); + assert_eq!( + unsafe { &(*(0 as *const max_align_t)).__clang_max_align_nonce1 as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(max_align_t), + "::", + stringify!(__clang_max_align_nonce1) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const max_align_t)).__clang_max_align_nonce2 as *const _ as usize }, + 16usize, + concat!( + "Alignment of field: ", + stringify!(max_align_t), + "::", + stringify!(__clang_max_align_nonce2) + ) + ); } impl Clone for max_align_t { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/use-core.rs b/tests/expectations/tests/use-core.rs index b884f4f2..093c4a83 100644 --- a/tests/expectations/tests/use-core.rs +++ b/tests/expectations/tests/use-core.rs @@ -14,31 +14,46 @@ pub struct foo { } #[test] fn bindgen_test_layout_foo() { - assert_eq!(::core::mem::size_of::<foo>() , 16usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::core::mem::align_of::<foo>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . b as * const _ as usize } , - 4usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( b ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , - 8usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bar ) )); + assert_eq!( + ::core::mem::size_of::<foo>(), + 16usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::core::mem::align_of::<foo>(), + 8usize, + concat!("Alignment of ", stringify!(foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).a as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(foo), "::", stringify!(a)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).b as *const _ as usize }, + 4usize, + concat!("Alignment of field: ", stringify!(foo), "::", stringify!(b)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).bar as *const _ as usize }, + 8usize, + concat!( + "Alignment of field: ", + stringify!(foo), + "::", + stringify!(bar) + ) + ); } impl Clone for foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for foo { - fn default() -> Self { unsafe { ::core::mem::zeroed() } } + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } } #[repr(C)] #[derive(Copy)] @@ -49,30 +64,49 @@ pub union _bindgen_ty_1 { } #[test] fn bindgen_test_layout__bindgen_ty_1() { - assert_eq!(::core::mem::size_of::<_bindgen_ty_1>() , 8usize , concat ! ( - "Size of: " , stringify ! ( _bindgen_ty_1 ) )); - assert_eq! (::core::mem::align_of::<_bindgen_ty_1>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( _bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const _bindgen_ty_1 ) ) . bar as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( _bindgen_ty_1 ) , "::" - , stringify ! ( bar ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const _bindgen_ty_1 ) ) . baz as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( _bindgen_ty_1 ) , "::" - , stringify ! ( baz ) )); + assert_eq!( + ::core::mem::size_of::<_bindgen_ty_1>(), + 8usize, + concat!("Size of: ", stringify!(_bindgen_ty_1)) + ); + assert_eq!( + ::core::mem::align_of::<_bindgen_ty_1>(), + 8usize, + concat!("Alignment of ", stringify!(_bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const _bindgen_ty_1)).bar as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(_bindgen_ty_1), + "::", + stringify!(bar) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const _bindgen_ty_1)).baz as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(_bindgen_ty_1), + "::", + stringify!(baz) + ) + ); } impl Clone for _bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for _bindgen_ty_1 { - fn default() -> Self { unsafe { ::core::mem::zeroed() } } + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } } extern "C" { #[link_name = "\u{1}bazz"] pub static mut bazz: _bindgen_ty_1; } -pub type fooFunction = - ::core::option::Option<unsafe extern "C" fn(bar: ::std::os::raw::c_int)>; +pub type fooFunction = ::core::option::Option<unsafe extern "C" fn(bar: ::std::os::raw::c_int)>; diff --git a/tests/expectations/tests/use-core_1_0.rs b/tests/expectations/tests/use-core_1_0.rs index 7caa0b0f..4342d606 100644 --- a/tests/expectations/tests/use-core_1_0.rs +++ b/tests/expectations/tests/use-core_1_0.rs @@ -7,35 +7,47 @@ extern crate core; #[repr(C)] pub struct __BindgenUnionField<T>(::core::marker::PhantomData<T>); -impl <T> __BindgenUnionField<T> { +impl<T> __BindgenUnionField<T> { #[inline] - pub fn new() -> Self { __BindgenUnionField(::core::marker::PhantomData) } + pub fn new() -> Self { + __BindgenUnionField(::core::marker::PhantomData) + } #[inline] - pub unsafe fn as_ref(&self) -> &T { ::core::mem::transmute(self) } + pub unsafe fn as_ref(&self) -> &T { + ::core::mem::transmute(self) + } #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::core::mem::transmute(self) } + pub unsafe fn as_mut(&mut self) -> &mut T { + ::core::mem::transmute(self) + } } -impl <T> ::core::default::Default for __BindgenUnionField<T> { +impl<T> ::core::default::Default for __BindgenUnionField<T> { #[inline] - fn default() -> Self { Self::new() } + fn default() -> Self { + Self::new() + } } -impl <T> ::core::clone::Clone for __BindgenUnionField<T> { +impl<T> ::core::clone::Clone for __BindgenUnionField<T> { #[inline] - fn clone(&self) -> Self { Self::new() } + fn clone(&self) -> Self { + Self::new() + } } -impl <T> ::core::marker::Copy for __BindgenUnionField<T> { } -impl <T> ::core::fmt::Debug for __BindgenUnionField<T> { +impl<T> ::core::marker::Copy for __BindgenUnionField<T> {} +impl<T> ::core::fmt::Debug for __BindgenUnionField<T> { fn fmt(&self, fmt: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { fmt.write_str("__BindgenUnionField") } } -impl <T> ::core::hash::Hash for __BindgenUnionField<T> { - fn hash<H: ::core::hash::Hasher>(&self, _state: &mut H) { } +impl<T> ::core::hash::Hash for __BindgenUnionField<T> { + fn hash<H: ::core::hash::Hasher>(&self, _state: &mut H) {} } -impl <T> ::core::cmp::PartialEq for __BindgenUnionField<T> { - fn eq(&self, _other: &__BindgenUnionField<T>) -> bool { true } +impl<T> ::core::cmp::PartialEq for __BindgenUnionField<T> { + fn eq(&self, _other: &__BindgenUnionField<T>) -> bool { + true + } } -impl <T> ::core::cmp::Eq for __BindgenUnionField<T> { } +impl<T> ::core::cmp::Eq for __BindgenUnionField<T> {} #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct foo { @@ -45,31 +57,46 @@ pub struct foo { } #[test] fn bindgen_test_layout_foo() { - assert_eq!(::core::mem::size_of::<foo>() , 16usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::core::mem::align_of::<foo>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . b as * const _ as usize } , - 4usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( b ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , - 8usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bar ) )); + assert_eq!( + ::core::mem::size_of::<foo>(), + 16usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::core::mem::align_of::<foo>(), + 8usize, + concat!("Alignment of ", stringify!(foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).a as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(foo), "::", stringify!(a)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).b as *const _ as usize }, + 4usize, + concat!("Alignment of field: ", stringify!(foo), "::", stringify!(b)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).bar as *const _ as usize }, + 8usize, + concat!( + "Alignment of field: ", + stringify!(foo), + "::", + stringify!(bar) + ) + ); } impl Clone for foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for foo { - fn default() -> Self { unsafe { ::core::mem::zeroed() } } + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] @@ -80,27 +107,44 @@ pub struct _bindgen_ty_1 { } #[test] fn bindgen_test_layout__bindgen_ty_1() { - assert_eq!(::core::mem::size_of::<_bindgen_ty_1>() , 8usize , concat ! ( - "Size of: " , stringify ! ( _bindgen_ty_1 ) )); - assert_eq! (::core::mem::align_of::<_bindgen_ty_1>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( _bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const _bindgen_ty_1 ) ) . bar as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( _bindgen_ty_1 ) , "::" - , stringify ! ( bar ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const _bindgen_ty_1 ) ) . baz as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( _bindgen_ty_1 ) , "::" - , stringify ! ( baz ) )); + assert_eq!( + ::core::mem::size_of::<_bindgen_ty_1>(), + 8usize, + concat!("Size of: ", stringify!(_bindgen_ty_1)) + ); + assert_eq!( + ::core::mem::align_of::<_bindgen_ty_1>(), + 8usize, + concat!("Alignment of ", stringify!(_bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(0 as *const _bindgen_ty_1)).bar as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(_bindgen_ty_1), + "::", + stringify!(bar) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const _bindgen_ty_1)).baz as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(_bindgen_ty_1), + "::", + stringify!(baz) + ) + ); } impl Clone for _bindgen_ty_1 { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } extern "C" { #[link_name = "\u{1}bazz"] pub static mut bazz: _bindgen_ty_1; } -pub type fooFunction = - ::core::option::Option<unsafe extern "C" fn(bar: ::std::os::raw::c_int)>; +pub type fooFunction = ::core::option::Option<unsafe extern "C" fn(bar: ::std::os::raw::c_int)>; diff --git a/tests/expectations/tests/using.rs b/tests/expectations/tests/using.rs index 0dc1ec21..9bc5e303 100644 --- a/tests/expectations/tests/using.rs +++ b/tests/expectations/tests/using.rs @@ -11,8 +11,10 @@ pub struct Point<T> { pub y: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } -impl <T> Default for Point<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for Point<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } pub type IntPoint2D = Point<::std::os::raw::c_int>; pub type IntVec2D = Point<::std::os::raw::c_int>; diff --git a/tests/expectations/tests/var-tracing.rs b/tests/expectations/tests/var-tracing.rs index 54ce9293..5042f3f7 100644 --- a/tests/expectations/tests/var-tracing.rs +++ b/tests/expectations/tests/var-tracing.rs @@ -11,22 +11,35 @@ pub struct Bar { } #[test] fn bindgen_test_layout_Bar() { - assert_eq!(::std::mem::size_of::<Bar>() , 4usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::<Bar>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Bar ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Bar ) ) . m_baz as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Bar ) , "::" , - stringify ! ( m_baz ) )); + assert_eq!( + ::std::mem::size_of::<Bar>(), + 4usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::<Bar>(), + 4usize, + concat!("Alignment of ", stringify!(Bar)) + ); + assert_eq!( + unsafe { &(*(0 as *const Bar)).m_baz as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Bar), + "::", + stringify!(m_baz) + ) + ); } extern "C" { #[link_name = "\u{1}_ZN3BarC1Ei"] pub fn Bar_Bar(this: *mut Bar, baz: ::std::os::raw::c_int); } impl Clone for Bar { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Bar { #[inline] @@ -47,11 +60,19 @@ extern "C" { } #[test] fn bindgen_test_layout_Baz() { - assert_eq!(::std::mem::size_of::<Baz>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Baz ) )); - assert_eq! (::std::mem::align_of::<Baz>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Baz ) )); + assert_eq!( + ::std::mem::size_of::<Baz>(), + 1usize, + concat!("Size of: ", stringify!(Baz)) + ); + assert_eq!( + ::std::mem::align_of::<Baz>(), + 1usize, + concat!("Alignment of ", stringify!(Baz)) + ); } impl Clone for Baz { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/variadic-method.rs b/tests/expectations/tests/variadic-method.rs index 6ef20b76..6b3f70b3 100644 --- a/tests/expectations/tests/variadic-method.rs +++ b/tests/expectations/tests/variadic-method.rs @@ -15,15 +15,23 @@ pub struct Bar { } #[test] fn bindgen_test_layout_Bar() { - assert_eq!(::std::mem::size_of::<Bar>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::<Bar>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Bar ) )); + assert_eq!( + ::std::mem::size_of::<Bar>(), + 1usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::<Bar>(), + 1usize, + concat!("Alignment of ", stringify!(Bar)) + ); } extern "C" { #[link_name = "\u{1}_ZN3Bar3fooEPKcz"] pub fn Bar_foo(this: *mut Bar, fmt: *const ::std::os::raw::c_char, ...); } impl Clone for Bar { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/vector.rs b/tests/expectations/tests/vector.rs index a4b87c7f..87096aa9 100644 --- a/tests/expectations/tests/vector.rs +++ b/tests/expectations/tests/vector.rs @@ -11,16 +11,29 @@ pub struct foo { } #[test] fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::<foo>() , 8usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::<foo>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . mMember as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( mMember ) )); + assert_eq!( + ::std::mem::size_of::<foo>(), + 8usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::<foo>(), + 8usize, + concat!("Alignment of ", stringify!(foo)) + ); + assert_eq!( + unsafe { &(*(0 as *const foo)).mMember as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(foo), + "::", + stringify!(mMember) + ) + ); } impl Clone for foo { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } diff --git a/tests/expectations/tests/virtual_dtor.rs b/tests/expectations/tests/virtual_dtor.rs index 0a9a5d09..72086053 100644 --- a/tests/expectations/tests/virtual_dtor.rs +++ b/tests/expectations/tests/virtual_dtor.rs @@ -13,13 +13,21 @@ pub struct nsSlots { } #[test] fn bindgen_test_layout_nsSlots() { - assert_eq!(::std::mem::size_of::<nsSlots>() , 8usize , concat ! ( - "Size of: " , stringify ! ( nsSlots ) )); - assert_eq! (::std::mem::align_of::<nsSlots>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( nsSlots ) )); + assert_eq!( + ::std::mem::size_of::<nsSlots>(), + 8usize, + concat!("Size of: ", stringify!(nsSlots)) + ); + assert_eq!( + ::std::mem::align_of::<nsSlots>(), + 8usize, + concat!("Alignment of ", stringify!(nsSlots)) + ); } impl Default for nsSlots { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } extern "C" { #[link_name = "\u{1}_ZN7nsSlotsD0Ev"] diff --git a/tests/expectations/tests/virtual_inheritance.rs b/tests/expectations/tests/virtual_inheritance.rs index e177dca8..40e5859f 100644 --- a/tests/expectations/tests/virtual_inheritance.rs +++ b/tests/expectations/tests/virtual_inheritance.rs @@ -11,18 +11,26 @@ pub struct A { } #[test] fn bindgen_test_layout_A() { - assert_eq!(::std::mem::size_of::<A>() , 4usize , concat ! ( - "Size of: " , stringify ! ( A ) )); - assert_eq! (::std::mem::align_of::<A>() , 4usize , concat ! ( - "Alignment of " , stringify ! ( A ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const A ) ) . foo as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( A ) , "::" , stringify - ! ( foo ) )); + assert_eq!( + ::std::mem::size_of::<A>(), + 4usize, + concat!("Size of: ", stringify!(A)) + ); + assert_eq!( + ::std::mem::align_of::<A>(), + 4usize, + concat!("Alignment of ", stringify!(A)) + ); + assert_eq!( + unsafe { &(*(0 as *const A)).foo as *const _ as usize }, + 0usize, + concat!("Alignment of field: ", stringify!(A), "::", stringify!(foo)) + ); } impl Clone for A { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } #[repr(C)] pub struct B__bindgen_vtable(::std::os::raw::c_void); @@ -34,21 +42,31 @@ pub struct B { } #[test] fn bindgen_test_layout_B() { - assert_eq!(::std::mem::size_of::<B>() , 16usize , concat ! ( - "Size of: " , stringify ! ( B ) )); - assert_eq! (::std::mem::align_of::<B>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( B ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const B ) ) . bar as * const _ as usize } , - 8usize , concat ! ( - "Alignment of field: " , stringify ! ( B ) , "::" , stringify - ! ( bar ) )); + assert_eq!( + ::std::mem::size_of::<B>(), + 16usize, + concat!("Size of: ", stringify!(B)) + ); + assert_eq!( + ::std::mem::align_of::<B>(), + 8usize, + concat!("Alignment of ", stringify!(B)) + ); + assert_eq!( + unsafe { &(*(0 as *const B)).bar as *const _ as usize }, + 8usize, + concat!("Alignment of field: ", stringify!(B), "::", stringify!(bar)) + ); } impl Clone for B { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for B { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] pub struct C__bindgen_vtable(::std::os::raw::c_void); @@ -60,21 +78,31 @@ pub struct C { } #[test] fn bindgen_test_layout_C() { - assert_eq!(::std::mem::size_of::<C>() , 16usize , concat ! ( - "Size of: " , stringify ! ( C ) )); - assert_eq! (::std::mem::align_of::<C>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( C ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C ) ) . baz as * const _ as usize } , - 8usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( baz ) )); + assert_eq!( + ::std::mem::size_of::<C>(), + 16usize, + concat!("Size of: ", stringify!(C)) + ); + assert_eq!( + ::std::mem::align_of::<C>(), + 8usize, + concat!("Alignment of ", stringify!(C)) + ); + assert_eq!( + unsafe { &(*(0 as *const C)).baz as *const _ as usize }, + 8usize, + concat!("Alignment of field: ", stringify!(C), "::", stringify!(baz)) + ); } 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() } + } } #[repr(C)] #[derive(Debug, Copy)] @@ -85,14 +113,24 @@ pub struct D { } #[test] fn bindgen_test_layout_D() { - assert_eq!(::std::mem::size_of::<D>() , 40usize , concat ! ( - "Size of: " , stringify ! ( D ) )); - assert_eq! (::std::mem::align_of::<D>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( D ) )); + assert_eq!( + ::std::mem::size_of::<D>(), + 40usize, + concat!("Size of: ", stringify!(D)) + ); + assert_eq!( + ::std::mem::align_of::<D>(), + 8usize, + concat!("Alignment of ", stringify!(D)) + ); } impl Clone for D { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for D { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/virtual_overloaded.rs b/tests/expectations/tests/virtual_overloaded.rs index ce9a198d..949fb386 100644 --- a/tests/expectations/tests/virtual_overloaded.rs +++ b/tests/expectations/tests/virtual_overloaded.rs @@ -13,24 +13,32 @@ pub struct C { } #[test] fn bindgen_test_layout_C() { - assert_eq!(::std::mem::size_of::<C>() , 8usize , concat ! ( - "Size of: " , stringify ! ( C ) )); - assert_eq! (::std::mem::align_of::<C>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( C ) )); + assert_eq!( + ::std::mem::size_of::<C>(), + 8usize, + concat!("Size of: ", stringify!(C)) + ); + assert_eq!( + ::std::mem::align_of::<C>(), + 8usize, + concat!("Alignment of ", stringify!(C)) + ); } 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() } + } } extern "C" { #[link_name = "\u{1}_ZN1C8do_thingEc"] - pub fn C_do_thing(this: *mut ::std::os::raw::c_void, - arg1: ::std::os::raw::c_char); + pub fn C_do_thing(this: *mut ::std::os::raw::c_void, arg1: ::std::os::raw::c_char); } extern "C" { #[link_name = "\u{1}_ZN1C8do_thingEi"] - pub fn C_do_thing1(this: *mut ::std::os::raw::c_void, - arg1: ::std::os::raw::c_int); + pub fn C_do_thing1(this: *mut ::std::os::raw::c_void, arg1: ::std::os::raw::c_int); } diff --git a/tests/expectations/tests/vtable_recursive_sig.rs b/tests/expectations/tests/vtable_recursive_sig.rs index 66841342..0f35890c 100644 --- a/tests/expectations/tests/vtable_recursive_sig.rs +++ b/tests/expectations/tests/vtable_recursive_sig.rs @@ -13,16 +13,26 @@ pub struct Base { } #[test] fn bindgen_test_layout_Base() { - assert_eq!(::std::mem::size_of::<Base>() , 8usize , concat ! ( - "Size of: " , stringify ! ( Base ) )); - assert_eq! (::std::mem::align_of::<Base>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( Base ) )); + assert_eq!( + ::std::mem::size_of::<Base>(), + 8usize, + concat!("Size of: ", stringify!(Base)) + ); + assert_eq!( + ::std::mem::align_of::<Base>(), + 8usize, + concat!("Alignment of ", stringify!(Base)) + ); } impl Clone for Base { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for Base { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } extern "C" { #[link_name = "\u{1}_ZN4Base9AsDerivedEv"] @@ -35,14 +45,24 @@ pub struct Derived { } #[test] fn bindgen_test_layout_Derived() { - assert_eq!(::std::mem::size_of::<Derived>() , 8usize , concat ! ( - "Size of: " , stringify ! ( Derived ) )); - assert_eq! (::std::mem::align_of::<Derived>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( Derived ) )); + assert_eq!( + ::std::mem::size_of::<Derived>(), + 8usize, + concat!("Size of: ", stringify!(Derived)) + ); + assert_eq!( + ::std::mem::align_of::<Derived>(), + 8usize, + concat!("Alignment of ", stringify!(Derived)) + ); } impl Clone for Derived { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } impl Default for Derived { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/what_is_going_on.rs b/tests/expectations/tests/what_is_going_on.rs index daa6407b..49dc9960 100644 --- a/tests/expectations/tests/what_is_going_on.rs +++ b/tests/expectations/tests/what_is_going_on.rs @@ -11,13 +11,21 @@ pub struct UnknownUnits { } #[test] fn bindgen_test_layout_UnknownUnits() { - assert_eq!(::std::mem::size_of::<UnknownUnits>() , 1usize , concat ! ( - "Size of: " , stringify ! ( UnknownUnits ) )); - assert_eq! (::std::mem::align_of::<UnknownUnits>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( UnknownUnits ) )); + assert_eq!( + ::std::mem::size_of::<UnknownUnits>(), + 1usize, + concat!("Size of: ", stringify!(UnknownUnits)) + ); + assert_eq!( + ::std::mem::align_of::<UnknownUnits>(), + 1usize, + concat!("Alignment of ", stringify!(UnknownUnits)) + ); } impl Clone for UnknownUnits { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } pub type Float = f32; #[repr(C)] @@ -27,7 +35,9 @@ pub struct PointTyped<F> { pub y: F, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<F>>, } -impl <F> Default for PointTyped<F> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<F> Default for PointTyped<F> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } pub type IntPoint = PointTyped<f32>; diff --git a/tests/expectations/tests/whitelist-namespaces-basic.rs b/tests/expectations/tests/whitelist-namespaces-basic.rs index bdb35589..316ed44d 100644 --- a/tests/expectations/tests/whitelist-namespaces-basic.rs +++ b/tests/expectations/tests/whitelist-namespaces-basic.rs @@ -21,13 +21,21 @@ pub mod root { } #[test] fn bindgen_test_layout_Helper() { - assert_eq!(::std::mem::size_of::<Helper>() , 1usize , concat ! - ( "Size of: " , stringify ! ( Helper ) )); - assert_eq! (::std::mem::align_of::<Helper>() , 1usize , concat - ! ( "Alignment of " , stringify ! ( Helper ) )); + assert_eq!( + ::std::mem::size_of::<Helper>(), + 1usize, + concat!("Size of: ", stringify!(Helper)) + ); + assert_eq!( + ::std::mem::align_of::<Helper>(), + 1usize, + concat!("Alignment of ", stringify!(Helper)) + ); } impl Clone for Helper { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } } } diff --git a/tests/expectations/tests/whitelist-namespaces.rs b/tests/expectations/tests/whitelist-namespaces.rs index e19bdba3..01dce09a 100644 --- a/tests/expectations/tests/whitelist-namespaces.rs +++ b/tests/expectations/tests/whitelist-namespaces.rs @@ -21,13 +21,21 @@ pub mod root { } #[test] fn bindgen_test_layout_Helper() { - assert_eq!(::std::mem::size_of::<Helper>() , 1usize , concat ! - ( "Size of: " , stringify ! ( Helper ) )); - assert_eq! (::std::mem::align_of::<Helper>() , 1usize , concat - ! ( "Alignment of " , stringify ! ( Helper ) )); + assert_eq!( + ::std::mem::size_of::<Helper>(), + 1usize, + concat!("Size of: ", stringify!(Helper)) + ); + assert_eq!( + ::std::mem::align_of::<Helper>(), + 1usize, + concat!("Alignment of ", stringify!(Helper)) + ); } impl Clone for Helper { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } } #[repr(C)] @@ -37,18 +45,31 @@ pub mod root { } #[test] fn bindgen_test_layout_Test() { - assert_eq!(::std::mem::size_of::<Test>() , 1usize , concat ! ( - "Size of: " , stringify ! ( Test ) )); - assert_eq! (::std::mem::align_of::<Test>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Test ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . helper as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( helper ) )); + assert_eq!( + ::std::mem::size_of::<Test>(), + 1usize, + concat!("Size of: ", stringify!(Test)) + ); + assert_eq!( + ::std::mem::align_of::<Test>(), + 1usize, + concat!("Alignment of ", stringify!(Test)) + ); + assert_eq!( + unsafe { &(*(0 as *const Test)).helper as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(Test), + "::", + stringify!(helper) + ) + ); } impl Clone for Test { - fn clone(&self) -> Self { *self } + fn clone(&self) -> Self { + *self + } } } } diff --git a/tests/expectations/tests/whitelist_basic.rs b/tests/expectations/tests/whitelist_basic.rs index af151e3e..7ff1160d 100644 --- a/tests/expectations/tests/whitelist_basic.rs +++ b/tests/expectations/tests/whitelist_basic.rs @@ -17,9 +17,13 @@ pub struct WhitelistMe_Inner<T> { pub bar: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, } -impl <T> Default for WhitelistMe_Inner<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for WhitelistMe_Inner<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } -impl <T> Default for WhitelistMe<T> { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl<T> Default for WhitelistMe<T> { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } |