diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index ac28244c54..6396e95346 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -1424,7 +1424,7 @@ impl CodeGenerator for CompInfo { // // FIXME: Once we generate proper vtables, we need to codegen the // vtable, but *not* generate a field for it in the case that - // needs_explicit_vtable is false but has_vtable is true. + // HasVtable::has_vtable_ptr is false but HasVtable::has_vtable is true. // // Also, we need to generate the vtable in such a way it "inherits" from // the parent too. @@ -1434,7 +1434,7 @@ impl CodeGenerator for CompInfo { StructLayoutTracker::new(ctx, self, &canonical_name); if !is_opaque { - if self.needs_explicit_vtable(ctx, item) { + if item.has_vtable_ptr(ctx) { let vtable = Vtable::new(item.id(), self.methods(), self.base_members()); vtable.codegen(ctx, result, item); diff --git a/src/ir/analysis/has_vtable.rs b/src/ir/analysis/has_vtable.rs index 92d6a38f78..f3f2a69534 100644 --- a/src/ir/analysis/has_vtable.rs +++ b/src/ir/analysis/has_vtable.rs @@ -4,8 +4,66 @@ use super::{ConstrainResult, MonotoneFramework, generate_dependencies}; use ir::context::{BindgenContext, ItemId}; use ir::traversal::EdgeKind; use ir::ty::TypeKind; +use std::cmp; use std::collections::HashMap; -use std::collections::HashSet; +use std::collections::hash_map::Entry; +use std::ops; + +/// The result of the `HasVtableAnalysis` for an individual item. +#[derive(Copy, Clone, Debug, PartialEq, Eq, Ord)] +pub enum HasVtableResult { + /// The item has a vtable, but the actual vtable pointer is in a base + /// member. + BaseHasVtable, + + /// The item has a vtable and the actual vtable pointer is within this item. + SelfHasVtable, + + /// The item does not have a vtable pointer. + No +} + +impl Default for HasVtableResult { + fn default() -> Self { + HasVtableResult::No + } +} + +impl cmp::PartialOrd for HasVtableResult { + fn partial_cmp(&self, rhs: &Self) -> Option { + use self::HasVtableResult::*; + + match (*self, *rhs) { + (x, y) if x == y => Some(cmp::Ordering::Equal), + (BaseHasVtable, _) => Some(cmp::Ordering::Greater), + (_, BaseHasVtable) => Some(cmp::Ordering::Less), + (SelfHasVtable, _) => Some(cmp::Ordering::Greater), + (_, SelfHasVtable) => Some(cmp::Ordering::Less), + _ => unreachable!(), + } + } +} + +impl HasVtableResult { + /// Take the least upper bound of `self` and `rhs`. + pub fn join(self, rhs: Self) -> Self { + cmp::max(self, rhs) + } +} + +impl ops::BitOr for HasVtableResult { + type Output = Self; + + fn bitor(self, rhs: HasVtableResult) -> Self::Output { + self.join(rhs) + } +} + +impl ops::BitOrAssign for HasVtableResult { + fn bitor_assign(&mut self, rhs: HasVtableResult) { + *self = self.join(rhs) + } +} /// An analysis that finds for each IR item whether it has vtable or not /// @@ -23,7 +81,7 @@ pub struct HasVtableAnalysis<'ctx> { // The incremental result of this analysis's computation. Everything in this // set definitely has a vtable. - have_vtable: HashSet, + have_vtable: HashMap, // Dependencies saying that if a key ItemId has been inserted into the // `have_vtable` set, then each of the ids in Vec need to be @@ -47,26 +105,50 @@ impl<'ctx> HasVtableAnalysis<'ctx> { } } - fn insert>(&mut self, id: Id) -> ConstrainResult { + fn insert>(&mut self, id: Id, result: HasVtableResult) -> ConstrainResult { + if let HasVtableResult::No = result { + return ConstrainResult::Same; + } + let id = id.into(); - let was_not_already_in_set = self.have_vtable.insert(id); - assert!( - was_not_already_in_set, - "We shouldn't try and insert {:?} twice because if it was \ - already in the set, `constrain` should have exited early.", - id - ); - ConstrainResult::Changed + match self.have_vtable.entry(id) { + Entry::Occupied(mut entry) => { + if *entry.get() < result { + entry.insert(result); + ConstrainResult::Changed + } else { + ConstrainResult::Same + } + } + Entry::Vacant(entry) => { + entry.insert(result); + ConstrainResult::Changed + } + } + } + + fn forward(&mut self, from: Id1, to: Id2) -> ConstrainResult + where + Id1: Into, + Id2: Into, + { + let from = from.into(); + let to = to.into(); + + match self.have_vtable.get(&from).cloned() { + None => ConstrainResult::Same, + Some(r) => self.insert(to, r), + } } } impl<'ctx> MonotoneFramework for HasVtableAnalysis<'ctx> { type Node = ItemId; type Extra = &'ctx BindgenContext; - type Output = HashSet; + type Output = HashMap; fn new(ctx: &'ctx BindgenContext) -> HasVtableAnalysis<'ctx> { - let have_vtable = HashSet::new(); + let have_vtable = HashMap::new(); let dependencies = generate_dependencies(ctx, Self::consider_edge); HasVtableAnalysis { @@ -81,11 +163,7 @@ impl<'ctx> MonotoneFramework for HasVtableAnalysis<'ctx> { } fn constrain(&mut self, id: ItemId) -> ConstrainResult { - if self.have_vtable.contains(&id) { - // We've already computed that this type has a vtable and that can't - // change. - return ConstrainResult::Same; - } + trace!("constrain {:?}", id); let item = self.ctx.resolve_item(id); let ty = match item.as_type() { @@ -99,33 +177,32 @@ impl<'ctx> MonotoneFramework for HasVtableAnalysis<'ctx> { TypeKind::Alias(t) | TypeKind::ResolvedTypeRef(t) | TypeKind::Reference(t) => { - if self.have_vtable.contains(&t.into()) { - self.insert(id) - } else { - ConstrainResult::Same - } + trace!(" aliases and references forward to their inner type"); + self.forward(t, id) } TypeKind::Comp(ref info) => { + trace!(" comp considers its own methods and bases"); + let mut result = HasVtableResult::No; + if info.has_own_virtual_method() { - return self.insert(id); + trace!(" comp has its own virtual method"); + result |= HasVtableResult::SelfHasVtable; } + let bases_has_vtable = info.base_members().iter().any(|base| { - self.have_vtable.contains(&base.ty.into()) + trace!(" comp has a base with a vtable: {:?}", base); + self.have_vtable.contains_key(&base.ty.into()) }); if bases_has_vtable { - self.insert(id) - } else { - ConstrainResult::Same + result |= HasVtableResult::BaseHasVtable; } + + self.insert(id, result) } TypeKind::TemplateInstantiation(ref inst) => { - if self.have_vtable.contains(&inst.template_definition().into()) { - self.insert(id) - } else { - ConstrainResult::Same - } + self.forward(inst.template_definition(), id) } _ => ConstrainResult::Same, @@ -145,8 +222,13 @@ impl<'ctx> MonotoneFramework for HasVtableAnalysis<'ctx> { } } -impl<'ctx> From> for HashSet { +impl<'ctx> From> for HashMap { fn from(analysis: HasVtableAnalysis<'ctx>) -> Self { + // We let the lack of an entry mean "No" to save space. + extra_assert!(analysis.have_vtable.values().all(|v| { + *v != HasVtableResult::No + })); + analysis.have_vtable } } @@ -160,4 +242,8 @@ impl<'ctx> From> for HashSet { pub trait HasVtable { /// Return `true` if this thing has vtable, `false` otherwise. fn has_vtable(&self, ctx: &BindgenContext) -> bool; + + /// Return `true` if this thing has an actual vtable pointer in itself, as + /// opposed to transitively in a base member. + fn has_vtable_ptr(&self, ctx: &BindgenContext) -> bool; } diff --git a/src/ir/analysis/mod.rs b/src/ir/analysis/mod.rs index dfc96f0ada..6caf33139b 100644 --- a/src/ir/analysis/mod.rs +++ b/src/ir/analysis/mod.rs @@ -43,8 +43,7 @@ pub use self::template_params::UsedTemplateParameters; mod derive_debug; pub use self::derive_debug::CannotDeriveDebug; mod has_vtable; -pub use self::has_vtable::HasVtable; -pub use self::has_vtable::HasVtableAnalysis; +pub use self::has_vtable::{HasVtable, HasVtableAnalysis, HasVtableResult}; mod has_destructor; pub use self::has_destructor::HasDestructorAnalysis; mod derive_default; @@ -64,6 +63,7 @@ use ir::context::{BindgenContext, ItemId}; use ir::traversal::{EdgeKind, Trace}; use std::collections::HashMap; use std::fmt; +use std::ops; /// An analysis in the monotone framework. /// @@ -125,6 +125,7 @@ pub trait MonotoneFramework: Sized + fmt::Debug { /// Whether an analysis's `constrain` function modified the incremental results /// or not. +#[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum ConstrainResult { /// The incremental results were updated, and the fix-point computation /// should continue. @@ -134,6 +135,30 @@ pub enum ConstrainResult { Same, } +impl Default for ConstrainResult { + fn default() -> Self { + ConstrainResult::Same + } +} + +impl ops::BitOr for ConstrainResult { + type Output = Self; + + fn bitor(self, rhs: ConstrainResult) -> Self::Output { + if self == ConstrainResult::Changed || rhs == ConstrainResult::Changed { + ConstrainResult::Changed + } else { + ConstrainResult::Same + } + } +} + +impl ops::BitOrAssign for ConstrainResult { + fn bitor_assign(&mut self, rhs: ConstrainResult) { + *self = *self | rhs; + } +} + /// Run an analysis in the monotone framework. pub fn analyze(extra: Analysis::Extra) -> Analysis::Output where diff --git a/src/ir/comp.rs b/src/ir/comp.rs index c77834ee36..374dca8dbb 100644 --- a/src/ir/comp.rs +++ b/src/ir/comp.rs @@ -1012,7 +1012,7 @@ impl CompInfo { /// Is this compound type unsized? pub fn is_unsized(&self, ctx: &BindgenContext, id: TypeId) -> bool { - !ctx.lookup_has_vtable(id) && self.fields().is_empty() && + !id.has_vtable(ctx) && self.fields().is_empty() && self.base_members.iter().all(|base| { ctx.resolve_type(base.ty).canonical_type(ctx).is_unsized( ctx, @@ -1451,27 +1451,6 @@ impl CompInfo { self.packed } - /// Returns whether this type needs an explicit vtable because it has - /// virtual methods and none of its base classes has already a vtable. - pub fn needs_explicit_vtable( - &self, - ctx: &BindgenContext, - item: &Item, - ) -> bool { - item.has_vtable(ctx) && !self.base_members.iter().any(|base| { - // NB: Ideally, we could rely in all these types being `comp`, and - // life would be beautiful. - // - // Unfortunately, given the way we implement --match-pat, and also - // that you can inherit from templated types, we need to handle - // other cases here too. - ctx.resolve_type(base.ty) - .canonical_type(ctx) - .as_comp() - .map_or(false, |_| base.ty.has_vtable(ctx)) - }) - } - /// Returns true if compound type has been forward declared pub fn is_forward_declaration(&self) -> bool { self.is_forward_declaration diff --git a/src/ir/context.rs b/src/ir/context.rs index 560f6ec247..da69286601 100644 --- a/src/ir/context.rs +++ b/src/ir/context.rs @@ -3,8 +3,8 @@ use super::analysis::{CannotDeriveCopy, CannotDeriveDebug, CannotDeriveDefault, CannotDeriveHash, CannotDerivePartialEqOrPartialOrd, HasTypeParameterInArray, - HasVtableAnalysis, HasDestructorAnalysis, UsedTemplateParameters, - HasFloat, analyze}; + HasVtableAnalysis, HasVtableResult, HasDestructorAnalysis, + UsedTemplateParameters, HasFloat, analyze}; use super::derive::{CanDeriveCopy, CanDeriveDebug, CanDeriveDefault, CanDeriveHash, CanDerivePartialOrd, CanDeriveOrd, CanDerivePartialEq, CanDeriveEq, CannotDeriveReason}; @@ -432,7 +432,7 @@ pub struct BindgenContext { /// /// Populated when we enter codegen by `compute_has_vtable`; always `None` /// before that and `Some` after. - have_vtable: Option>, + have_vtable: Option>, /// The set of (`ItemId's of`) types that has destructor. /// @@ -1267,7 +1267,7 @@ impl BindgenContext { } /// Look up whether the item with `id` has vtable or not. - pub fn lookup_has_vtable(&self, id: TypeId) -> bool { + pub fn lookup_has_vtable(&self, id: TypeId) -> HasVtableResult { assert!( self.in_codegen_phase(), "We only compute vtables when we enter codegen" @@ -1275,7 +1275,12 @@ impl BindgenContext { // Look up the computed value for whether the item with `id` has a // vtable or not. - self.have_vtable.as_ref().unwrap().contains(&id.into()) + self.have_vtable + .as_ref() + .unwrap() + .get(&id.into()) + .cloned() + .unwrap_or(HasVtableResult::No) } /// Compute whether the type has a destructor. diff --git a/src/ir/item.rs b/src/ir/item.rs index dbc352eb84..ac50ef3b81 100644 --- a/src/ir/item.rs +++ b/src/ir/item.rs @@ -1,6 +1,6 @@ //! Bindgen's core intermediate representation type. -use super::analysis::HasVtable; +use super::analysis::{HasVtable, HasVtableResult}; use super::annotations::Annotations; use super::comment; use super::comp::MethodKind; @@ -1001,15 +1001,29 @@ where fn has_vtable(&self, ctx: &BindgenContext) -> bool { let id: ItemId = (*self).into(); id.as_type_id(ctx) - .map_or(false, |id| ctx.lookup_has_vtable(id)) + .map_or(false, |id| match ctx.lookup_has_vtable(id) { + HasVtableResult::No => false, + _ => true, + }) + } + + fn has_vtable_ptr(&self, ctx: &BindgenContext) -> bool { + let id: ItemId = (*self).into(); + id.as_type_id(ctx) + .map_or(false, |id| match ctx.lookup_has_vtable(id) { + HasVtableResult::SelfHasVtable => true, + _ => false, + }) } } impl HasVtable for Item { fn has_vtable(&self, ctx: &BindgenContext) -> bool { - self.id() - .as_type_id(ctx) - .map_or(false, |id| ctx.lookup_has_vtable(id)) + self.id().has_vtable(ctx) + } + + fn has_vtable_ptr(&self, ctx: &BindgenContext) -> bool { + self.id().has_vtable_ptr(ctx) } } diff --git a/tests/expectations/tests/16-byte-alignment.rs b/tests/expectations/tests/16-byte-alignment.rs index 8610365697..4b764daa80 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::() - , 4usize , concat ! ( - "Size of: " , stringify ! ( - rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() - , 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::(), + 4usize, + concat!( + "Size of: ", + stringify!(rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize - , concat ! ( - "Size of: " , stringify ! ( rte_ipv4_tuple__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , - 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::(), + 4usize, + concat!("Size of: ", stringify!(rte_ipv4_tuple__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 12usize , concat ! ( - "Size of: " , stringify ! ( rte_ipv4_tuple ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 12usize, + concat!("Size of: ", stringify!(rte_ipv4_tuple)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() - , 4usize , concat ! ( - "Size of: " , stringify ! ( - rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() - , 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::(), + 4usize, + concat!( + "Size of: ", + stringify!(rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize - , concat ! ( - "Size of: " , stringify ! ( rte_ipv6_tuple__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , - 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::(), + 4usize, + concat!("Size of: ", stringify!(rte_ipv6_tuple__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 36usize , concat ! ( - "Size of: " , stringify ! ( rte_ipv6_tuple ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 36usize, + concat!("Size of: ", stringify!(rte_ipv6_tuple)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 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::(), + 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 98cb1a49de..712bc51971 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(::std::marker::PhantomData); -impl __BindgenUnionField { +impl __BindgenUnionField { #[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 ::std::default::Default for __BindgenUnionField { +impl ::std::default::Default for __BindgenUnionField { #[inline] - fn default() -> Self { Self::new() } + fn default() -> Self { + Self::new() + } } -impl ::std::clone::Clone for __BindgenUnionField { +impl ::std::clone::Clone for __BindgenUnionField { #[inline] - fn clone(&self) -> Self { Self::new() } + fn clone(&self) -> Self { + Self::new() + } } -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { +impl ::std::marker::Copy for __BindgenUnionField {} +impl ::std::fmt::Debug for __BindgenUnionField { fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { fmt.write_str("__BindgenUnionField") } } -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) {} } -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { true } +impl ::std::cmp::PartialEq for __BindgenUnionField { + fn eq(&self, _other: &__BindgenUnionField) -> bool { + true + } } -impl ::std::cmp::Eq for __BindgenUnionField { } +impl ::std::cmp::Eq for __BindgenUnionField {} #[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::() - , 4usize , concat ! ( - "Size of: " , stringify ! ( - rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() - , 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::(), + 4usize, + concat!( + "Size of: ", + stringify!(rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize - , concat ! ( - "Size of: " , stringify ! ( rte_ipv4_tuple__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , - 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::(), + 4usize, + concat!("Size of: ", stringify!(rte_ipv4_tuple__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 12usize , concat ! ( - "Size of: " , stringify ! ( rte_ipv4_tuple ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 12usize, + concat!("Size of: ", stringify!(rte_ipv4_tuple)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() - , 4usize , concat ! ( - "Size of: " , stringify ! ( - rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() - , 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::(), + 4usize, + concat!( + "Size of: ", + stringify!(rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize - , concat ! ( - "Size of: " , stringify ! ( rte_ipv6_tuple__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , - 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::(), + 4usize, + concat!("Size of: ", stringify!(rte_ipv6_tuple__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 36usize , concat ! ( - "Size of: " , stringify ! ( rte_ipv6_tuple ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 36usize, + concat!("Size of: ", stringify!(rte_ipv6_tuple)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 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::(), + 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 df1732c4c1..3c8953e624 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::() , 16usize , concat ! ( - "Size of: " , stringify ! ( SomeAccessors ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 16usize, + concat!("Size of: ", stringify!(SomeAccessors)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( AllAccessors ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(AllAccessors)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! - ( "Size of: " , stringify ! ( AllUnsafeAccessors ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(AllUnsafeAccessors)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 16usize , concat - ! ( "Size of: " , stringify ! ( ContradictAccessors ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 16usize, + concat!("Size of: ", stringify!(ContradictAccessors)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Replaced ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(Replaced)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Wrapper ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(Wrapper)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 b1004274f8..b185aae5c7 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Test ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(Test)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 f0c1d364f5..c037a08bc4 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 d3f542757e..c639410f9a 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 783a62cf02..87329d1af3 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::() , 4usize , - concat ! ( "Size of: " , stringify ! ( s__bindgen_ty_1_inner ) - )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(s__bindgen_ty_1_inner)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( s__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(s__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( s ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(s)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 8c29f8e4f0..8e2e6bea76 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(::std::marker::PhantomData); -impl __BindgenUnionField { +impl __BindgenUnionField { #[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 ::std::default::Default for __BindgenUnionField { +impl ::std::default::Default for __BindgenUnionField { #[inline] - fn default() -> Self { Self::new() } + fn default() -> Self { + Self::new() + } } -impl ::std::clone::Clone for __BindgenUnionField { +impl ::std::clone::Clone for __BindgenUnionField { #[inline] - fn clone(&self) -> Self { Self::new() } + fn clone(&self) -> Self { + Self::new() + } } -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { +impl ::std::marker::Copy for __BindgenUnionField {} +impl ::std::fmt::Debug for __BindgenUnionField { fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { fmt.write_str("__BindgenUnionField") } } -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) {} } -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { true } +impl ::std::cmp::PartialEq for __BindgenUnionField { + fn eq(&self, _other: &__BindgenUnionField) -> bool { + true + } } -impl ::std::cmp::Eq for __BindgenUnionField { } +impl ::std::cmp::Eq for __BindgenUnionField {} #[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::() , 4usize , - concat ! ( "Size of: " , stringify ! ( s__bindgen_ty_1_inner ) - )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(s__bindgen_ty_1_inner)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( s__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(s__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( s ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(s)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 f2da118da2..fdf01a7a5d 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::() , 24usize , concat ! ( - "Size of: " , stringify ! ( ErrorResult ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( ErrorResult ) )); + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(ErrorResult)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 24usize , concat ! ( - "Size of template specialization: " , stringify ! ( - TErrorResult ) )); - assert_eq!(::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of template specialization: " , stringify ! ( - TErrorResult ) )); + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!( + "Size of template specialization: ", + stringify!(TErrorResult) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 b96928d42a..8d19c9fc3d 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(::std::marker::PhantomData); -impl __BindgenUnionField { +impl __BindgenUnionField { #[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 ::std::default::Default for __BindgenUnionField { +impl ::std::default::Default for __BindgenUnionField { #[inline] - fn default() -> Self { Self::new() } + fn default() -> Self { + Self::new() + } } -impl ::std::clone::Clone for __BindgenUnionField { +impl ::std::clone::Clone for __BindgenUnionField { #[inline] - fn clone(&self) -> Self { Self::new() } + fn clone(&self) -> Self { + Self::new() + } } -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { +impl ::std::marker::Copy for __BindgenUnionField {} +impl ::std::fmt::Debug for __BindgenUnionField { fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { fmt.write_str("__BindgenUnionField") } } -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) {} } -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { true } +impl ::std::cmp::PartialEq for __BindgenUnionField { + fn eq(&self, _other: &__BindgenUnionField) -> bool { + true + } } -impl ::std::cmp::Eq for __BindgenUnionField { } +impl ::std::cmp::Eq for __BindgenUnionField {} #[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::() , 24usize , concat ! ( - "Size of: " , stringify ! ( ErrorResult ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( ErrorResult ) )); + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(ErrorResult)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 24usize , concat ! ( - "Size of template specialization: " , stringify ! ( - TErrorResult ) )); - assert_eq!(::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of template specialization: " , stringify ! ( - TErrorResult ) )); + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!( + "Size of template specialization: ", + stringify!(TErrorResult) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 532e2427c9..0fedfe4532 100644 --- a/tests/expectations/tests/anonymous-template-types.rs +++ b/tests/expectations/tests/anonymous-template-types.rs @@ -10,8 +10,10 @@ pub struct Foo { pub t_member: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for Foo { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for Foo { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] @@ -24,8 +26,10 @@ pub struct Quux { pub v_member: V, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for Quux { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for Quux { + 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 3bd9bec0b8..901bec60d2 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 0a9e1c3535..7042226cbf 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( false_type ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( false_type ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(false_type)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 ebb3fef43e..b7c24fb2a1 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 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 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 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 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 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 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 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 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Dummy ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Dummy ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Dummy)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 5606f64e4a..facc7338b0 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::() , 16usize , concat ! ( - "Size of: " , stringify ! ( HasBigBitfield ) )); + assert_eq!( + ::std::mem::size_of::(), + 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::() , 16usize , concat - ! ( "Size of: " , stringify ! ( HasTwoBigBitfields ) )); + assert_eq!( + ::std::mem::size_of::(), + 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 c599b01bac..6542081093 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::() , 0usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::(), + 0usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 8272aebc92..cf14bf20de 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Bar ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 1e45c74319..daad07b417 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::() , 12usize , concat ! ( - "Size of: " , stringify ! ( Test ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 12usize, + concat!("Size of: ", stringify!(Test)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 d7ee8b5207..351f041a2b 100644 --- a/tests/expectations/tests/class.rs +++ b/tests/expectations/tests/class.rs @@ -7,13 +7,15 @@ #[repr(C)] #[derive(Default)] pub struct __IncompleteArrayField(::std::marker::PhantomData); -impl __IncompleteArrayField { +impl __IncompleteArrayField { #[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 __IncompleteArrayField { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } } -impl ::std::fmt::Debug for __IncompleteArrayField { +impl ::std::fmt::Debug for __IncompleteArrayField { fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { fmt.write_str("__IncompleteArrayField") } } -impl ::std::clone::Clone for __IncompleteArrayField { +impl ::std::clone::Clone for __IncompleteArrayField { #[inline] - fn clone(&self) -> Self { Self::new() } + fn clone(&self) -> Self { + Self::new() + } } -impl ::std::marker::Copy for __IncompleteArrayField { } +impl ::std::marker::Copy for __IncompleteArrayField {} #[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::() , 40usize , concat ! ( - "Size of: " , stringify ! ( C ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 40usize, + concat!("Size of: ", stringify!(C)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 40usize , - concat ! ( - "Size of: " , stringify ! ( C_with_zero_length_array ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 40usize, + concat!("Size of: ", stringify!(C_with_zero_length_array)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 40usize , - concat ! ( - "Size of: " , stringify ! ( C_with_incomplete_array ) )); - assert_eq! (::std::mem::align_of::() , 4usize , - concat ! ( - "Alignment of " , stringify ! ( C_with_incomplete_array ) )); + assert_eq!( + ::std::mem::size_of::(), + 40usize, + concat!("Size of: ", stringify!(C_with_incomplete_array)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() - , 40usize , concat ! ( - "Size of: " , stringify ! ( - C_with_zero_length_array_and_incomplete_array ) )); - assert_eq! (::std::mem::align_of::() - , 4usize , concat ! ( - "Alignment of " , stringify ! ( - C_with_zero_length_array_and_incomplete_array ) )); + assert_eq!( + ::std::mem::size_of::(), + 40usize, + concat!( + "Size of: ", + stringify!(C_with_zero_length_array_and_incomplete_array) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( WithDtor ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(WithDtor)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , - concat ! ( - "Size of: " , stringify ! ( IncompleteArrayNonCopiable ) )); - assert_eq! (::std::mem::align_of::() , 8usize - , concat ! ( - "Alignment of " , stringify ! ( IncompleteArrayNonCopiable ) - )); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(IncompleteArrayNonCopiable)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Union ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(Union)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( WithUnion ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(WithUnion)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , - 1usize , concat ! ( - "Size of: " , stringify ! ( RealAbstractionWithTonsOfMethods ) - )); - assert_eq! (::std::mem::align_of::() , - 1usize , concat ! ( - "Alignment of " , stringify ! ( - RealAbstractionWithTonsOfMethods ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(RealAbstractionWithTonsOfMethods)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 cb99f81bcf..32b01f86ff 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::>(), + 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::(), + 4usize, + concat!("Size of: ", stringify!(D)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 7fc05c5fd7..c41f0b0433 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( whatever ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( whatever ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(whatever)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( whatever_child ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( whatever_child ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(whatever_child)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , - concat ! ( - "Size of: " , stringify ! ( whatever_child_with_member ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(whatever_child_with_member)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 93ab954258..e03938a033 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( MyClass ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( MyClass ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(MyClass)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 9a4b542524..945236de81 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( A ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( A ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(A)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 08e3aa88ac..36ad630722 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::>(), + 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 03df600838..f471a75710 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( A_Segment ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(A_Segment)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( A__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(A__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( A__bindgen_ty_2 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(A__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 12usize , concat ! ( - "Size of: " , stringify ! ( A ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 12usize, + concat!("Size of: ", stringify!(A)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( B_Segment ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(B_Segment)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( B ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(B)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , - 16usize , concat ! ( - "Size of: " , stringify ! ( C__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , - 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::(), + 16usize, + concat!("Size of: ", stringify!(C__bindgen_ty_1__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize - , concat ! ( - "Size of: " , stringify ! ( C__bindgen_ty_1__bindgen_ty_2 ) )); - assert_eq! (::std::mem::align_of::() , - 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::(), + 8usize, + concat!("Size of: ", stringify!(C__bindgen_ty_1__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 16usize , concat ! ( - "Size of: " , stringify ! ( C__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 16usize, + concat!("Size of: ", stringify!(C__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( C_Segment ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(C_Segment)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 20usize , concat ! ( - "Size of: " , stringify ! ( C ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 20usize, + concat!("Size of: ", stringify!(C)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 42376deea7..07a2fe4806 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(::std::marker::PhantomData); -impl __BindgenUnionField { +impl __BindgenUnionField { #[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 ::std::default::Default for __BindgenUnionField { +impl ::std::default::Default for __BindgenUnionField { #[inline] - fn default() -> Self { Self::new() } + fn default() -> Self { + Self::new() + } } -impl ::std::clone::Clone for __BindgenUnionField { +impl ::std::clone::Clone for __BindgenUnionField { #[inline] - fn clone(&self) -> Self { Self::new() } + fn clone(&self) -> Self { + Self::new() + } } -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { +impl ::std::marker::Copy for __BindgenUnionField {} +impl ::std::fmt::Debug for __BindgenUnionField { fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { fmt.write_str("__BindgenUnionField") } } -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) {} } -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { true } +impl ::std::cmp::PartialEq for __BindgenUnionField { + fn eq(&self, _other: &__BindgenUnionField) -> bool { + true + } } -impl ::std::cmp::Eq for __BindgenUnionField { } +impl ::std::cmp::Eq for __BindgenUnionField {} #[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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( A_Segment ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(A_Segment)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( A__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(A__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( A__bindgen_ty_2 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(A__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 12usize , concat ! ( - "Size of: " , stringify ! ( A ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 12usize, + concat!("Size of: ", stringify!(A)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( B_Segment ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(B_Segment)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( B ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(B)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , - 16usize , concat ! ( - "Size of: " , stringify ! ( C__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , - 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::(), + 16usize, + concat!("Size of: ", stringify!(C__bindgen_ty_1__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize - , concat ! ( - "Size of: " , stringify ! ( C__bindgen_ty_1__bindgen_ty_2 ) )); - assert_eq! (::std::mem::align_of::() , - 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::(), + 8usize, + concat!("Size of: ", stringify!(C__bindgen_ty_1__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 16usize , concat ! ( - "Size of: " , stringify ! ( C__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 16usize, + concat!("Size of: ", stringify!(C__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( C_Segment ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(C_Segment)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 20usize , concat ! ( - "Size of: " , stringify ! ( C ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 20usize, + concat!("Size of: ", stringify!(C)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 480b6b34be..90648fcc46 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::() , 72usize , concat ! ( - "Size of: " , stringify ! ( C ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 72usize, + concat!("Size of: ", stringify!(C)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 80usize , concat ! ( - "Size of: " , stringify ! ( D ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 80usize, + concat!("Size of: ", stringify!(D)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 127c1b0e07..3563da26db 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo_Bar ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo_Bar ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Foo_Bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Baz ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(Baz)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! - ( "Size of: " , stringify ! ( InInlineNS ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat - ! ( "Alignment of " , stringify ! ( InInlineNS ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(InInlineNS)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Bazz ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Bazz ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Bazz)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 6159f979a0..67721d06fc 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::() , 16usize , concat ! ( - "Size of: " , stringify ! ( TestDouble ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 16usize, + concat!("Size of: ", stringify!(TestDouble)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( TestDoublePtr ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(TestDoublePtr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( TestFloat ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(TestFloat)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( TestFloatPtr ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(TestFloatPtr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 98c6240fa2..2749321f59 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 9c101ec6a3..218abbdbce 100644 --- a/tests/expectations/tests/const_tparam.rs +++ b/tests/expectations/tests/const_tparam.rs @@ -11,6 +11,8 @@ pub struct C { pub bar: *mut T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for C { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for C { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/constify-enum.rs b/tests/expectations/tests/constify-enum.rs index 1d04210b0f..78644ae4d5 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 4db009be78..0a44963f12 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( bar ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 9b5fd7b88c..58debcc682 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( bar ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 4f8d46c5e8..32c173ef64 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::() , 16usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 16usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 0c25780b8f..2d516fe4d2 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::() , 48usize , concat ! ( - "Size of: " , stringify ! ( bar ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 48usize, + concat!("Size of: ", stringify!(bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Baz ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(Baz)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 { pub thing: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for Thing { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for Thing { + 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 534f70e3f3..081abf8955 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Bar ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 bb0d294a14..8d0c8c2dcf 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( TestOverload ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( TestOverload ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(TestOverload)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( TestPublicNoArgs ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! - ( "Alignment of " , stringify ! ( TestPublicNoArgs ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(TestPublicNoArgs)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 08570f16db..325682d11e 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::() , 24usize , concat ! ( - "Size of: " , stringify ! ( mbedtls_mpi ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 24usize, + concat!("Size of: ", stringify!(mbedtls_mpi)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 906da262ba..8d6f3b9255 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::() , 48usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 48usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 c894b95c97..f84a70055b 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 f2b1dbd853..eb560b3b77 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Derived ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Derived ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Derived)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize - , concat ! ( - "Size of: " , stringify ! ( DerivedFromBaseWithDestructor ) )); - assert_eq! (::std::mem::align_of::() , - 1usize , concat ! ( - "Alignment of " , stringify ! ( DerivedFromBaseWithDestructor - ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(DerivedFromBaseWithDestructor)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(DerivedFromBaseWithDestructor)) + ); } #[test] fn __bindgen_test_layout_Base_open0_Derived_close0_instantiation() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of template specialization: " , stringify ! ( Base ) )); - assert_eq!(::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of template specialization: " , stringify ! ( Base ) - )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of template specialization: ", stringify!(Base)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of template specialization: ", stringify!(Base)) + ); } #[test] -fn __bindgen_test_layout_BaseWithDestructor_open0_DerivedFromBaseWithDestructor_close0_instantiation() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! - ( - "Size of template specialization: " , stringify ! ( - BaseWithDestructor ) )); - assert_eq!(::std::mem::align_of::() , 1usize , concat - ! ( - "Alignment of template specialization: " , stringify ! ( - BaseWithDestructor ) )); +fn __bindgen_test_layout_BaseWithDestructor_open0_DerivedFromBaseWithDestructor_close0_instantiation( +) { + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!( + "Size of template specialization: ", + stringify!(BaseWithDestructor) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 03cafe9769..5c929909c5 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; +pub type Nice_Function = ::std::option::Option; #[test] fn bindgen_test_layout_Nice() { - assert_eq!(::std::mem::size_of::() , 144usize , concat ! ( - "Size of: " , stringify ! ( Nice ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 144usize, + concat!("Size of: ", stringify!(Nice)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() + ) } } diff --git a/tests/expectations/tests/derive-debug-opaque-template-instantiation.rs b/tests/expectations/tests/derive-debug-opaque-template-instantiation.rs index e552925527..5bc6e20dfc 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::() , 200usize , concat ! ( - "Size of: " , stringify ! ( Instance ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 200usize, + concat!("Size of: ", stringify!(Instance)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 267aca11f4..29c1d79154 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::() , 164usize , concat ! ( - "Size of: " , stringify ! ( Opaque ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Opaque ) )); + assert_eq!( + ::std::mem::size_of::(), + 164usize, + concat!("Size of: ", stringify!(Opaque)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 164usize , concat ! ( - "Size of: " , stringify ! ( OpaqueUser ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 164usize, + concat!("Size of: ", stringify!(OpaqueUser)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 ac4792969e..096a67d510 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; +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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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; +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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 114b73e398..9830777455 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::() , - 4usize , concat ! ( - "Size of: " , stringify ! ( WouldBeCopyButWeAreNotDerivingCopy - ) )); - assert_eq! (::std::mem::align_of::() , - 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::(), + 4usize, + concat!("Size of: ", stringify!(WouldBeCopyButWeAreNotDerivingCopy)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 292533d995..002e44750f 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Doggo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(Doggo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Null ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Null ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Null)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( DoggoOrNull ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( DoggoOrNull ) )); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(DoggoOrNull)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 67ca77d66f..d907a19cc0 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 9eafbbd2a4..70c308307f 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 c77bf11d66..f12c08d347 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 b3e49f4f8f..d6b41610d1 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::() , 16usize , concat ! ( - "Size of: " , stringify ! ( C ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 16usize, + concat!("Size of: ", stringify!(C)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 5b6102c987..a91999ed2b 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 73fc23f517..7ff0ef51e4 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 8c8195354e..06dea12630 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 b47fdf091b..100f27db2e 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 75b68ee15b..cc85b55326 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 789ed438ee..e257b7bca4 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 ::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 2ca90d4006..5dcc6c4008 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 6b07841844..c5eeb88e8d 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::>(), 8usize, + concat!("Size of template specialization: ", stringify!(RefPtr)) + ); + assert_eq!( + ::std::mem::align_of::>(), + 8usize, concat!( - "Size of template specialization: ", - stringify ! ( RefPtr < Foo > ) + "Alignment of template specialization: ", + stringify!(RefPtr) ) ); - 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 8b705f2aca..5502c4c4f8 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 05c6d3ee99..19772dbe06 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 { pub next: *mut Rooted, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for js_RootedBase { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for js_RootedBase { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -20,6 +22,8 @@ pub struct Rooted { pub _base: js_RootedBase, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for Rooted { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for Rooted { + 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 e3f2b225ea..a2399bcb7c 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 e02ba76cb8..a4eaa17c8f 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo_empty ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo_empty ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Foo_empty)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 e02ba76cb8..a4eaa17c8f 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo_empty ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo_empty ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Foo_empty)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 a0f0c13726..4450e65d59 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( a ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(a)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( c ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(c)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 789ed438ee..e257b7bca4 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 ::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 79f27df267..730849c059 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 ::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 e3d1abffe0..55c75ff14e 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 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 c894b95c97..f84a70055b 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 64373d7510..0f75ce0b35 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 c13abf8317..a7bf40285d 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 f123acef92..f4dafb45ac 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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-from-template-instantiation-with-vtable.rs b/tests/expectations/tests/inherit-from-template-instantiation-with-vtable.rs new file mode 100644 index 0000000000..365114ba86 --- /dev/null +++ b/tests/expectations/tests/inherit-from-template-instantiation-with-vtable.rs @@ -0,0 +1,228 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +pub struct BaseWithVtable__bindgen_vtable(::std::os::raw::c_void); +/// This should have an explicit vtable. +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct BaseWithVtable { + pub vtable_: *const BaseWithVtable__bindgen_vtable, + pub t: T, + pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, +} +impl Default for BaseWithVtable { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +/// This should not have an explicit vtable. +#[repr(C)] +#[derive(Debug, Copy)] +pub struct DerivedWithNoVirtualMethods { + pub _base: BaseWithVtable<*mut ::std::os::raw::c_char>, +} +#[test] +fn bindgen_test_layout_DerivedWithNoVirtualMethods() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(DerivedWithNoVirtualMethods)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(DerivedWithNoVirtualMethods)) + ); +} +impl Clone for DerivedWithNoVirtualMethods { + fn clone(&self) -> Self { + *self + } +} +impl Default for DerivedWithNoVirtualMethods { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +/// This should not have an explicit vtable. +#[repr(C)] +#[derive(Debug, Copy)] +pub struct DerivedWithVirtualMethods { + pub _base: BaseWithVtable<*mut ::std::os::raw::c_char>, +} +#[test] +fn bindgen_test_layout_DerivedWithVirtualMethods() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(DerivedWithVirtualMethods)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(DerivedWithVirtualMethods)) + ); +} +impl Clone for DerivedWithVirtualMethods { + fn clone(&self) -> Self { + *self + } +} +impl Default for DerivedWithVirtualMethods { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +/// This should not have any vtable. +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct BaseWithoutVtable { + pub u: U, + pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, +} +impl Default for BaseWithoutVtable { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +pub struct DerivedWithVtable__bindgen_vtable(::std::os::raw::c_void); +/// This should have an explicit vtable. +#[repr(C)] +#[derive(Debug, Copy)] +pub struct DerivedWithVtable { + pub vtable_: *const DerivedWithVtable__bindgen_vtable, + pub _base: BaseWithoutVtable<*mut ::std::os::raw::c_char>, +} +#[test] +fn bindgen_test_layout_DerivedWithVtable() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(DerivedWithVtable)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(DerivedWithVtable)) + ); +} +impl Clone for DerivedWithVtable { + fn clone(&self) -> Self { + *self + } +} +impl Default for DerivedWithVtable { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +/// This should not have any vtable. +#[repr(C)] +#[derive(Debug, Copy)] +pub struct DerivedWithoutVtable { + pub _base: BaseWithoutVtable<*mut ::std::os::raw::c_char>, +} +#[test] +fn bindgen_test_layout_DerivedWithoutVtable() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(DerivedWithoutVtable)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(DerivedWithoutVtable)) + ); +} +impl Clone for DerivedWithoutVtable { + fn clone(&self) -> Self { + *self + } +} +impl Default for DerivedWithoutVtable { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[test] +fn __bindgen_test_layout_BaseWithVtable_open0_ptr_char_close0_instantiation() { + assert_eq!( + ::std::mem::size_of::>(), + 16usize, + concat!( + "Size of template specialization: ", + stringify!(BaseWithVtable<*mut ::std::os::raw::c_char>) + ) + ); + assert_eq!( + ::std::mem::align_of::>(), + 8usize, + concat!( + "Alignment of template specialization: ", + stringify!(BaseWithVtable<*mut ::std::os::raw::c_char>) + ) + ); +} +#[test] +fn __bindgen_test_layout_BaseWithVtable_open0_ptr_char_close0_instantiation_1() { + assert_eq!( + ::std::mem::size_of::>(), + 16usize, + concat!( + "Size of template specialization: ", + stringify!(BaseWithVtable<*mut ::std::os::raw::c_char>) + ) + ); + assert_eq!( + ::std::mem::align_of::>(), + 8usize, + concat!( + "Alignment of template specialization: ", + stringify!(BaseWithVtable<*mut ::std::os::raw::c_char>) + ) + ); +} +#[test] +fn __bindgen_test_layout_BaseWithoutVtable_open0_ptr_char_close0_instantiation() { + assert_eq!( + ::std::mem::size_of::>(), + 8usize, + concat!( + "Size of template specialization: ", + stringify!(BaseWithoutVtable<*mut ::std::os::raw::c_char>) + ) + ); + assert_eq!( + ::std::mem::align_of::>(), + 8usize, + concat!( + "Alignment of template specialization: ", + stringify!(BaseWithoutVtable<*mut ::std::os::raw::c_char>) + ) + ); +} +#[test] +fn __bindgen_test_layout_BaseWithoutVtable_open0_ptr_char_close0_instantiation_1() { + assert_eq!( + ::std::mem::size_of::>(), + 8usize, + concat!( + "Size of template specialization: ", + stringify!(BaseWithoutVtable<*mut ::std::os::raw::c_char>) + ) + ); + assert_eq!( + ::std::mem::align_of::>(), + 8usize, + concat!( + "Alignment of template specialization: ", + stringify!(BaseWithoutVtable<*mut ::std::os::raw::c_char>) + ) + ); +} diff --git a/tests/expectations/tests/inherit-namespaced.rs b/tests/expectations/tests/inherit-namespaced.rs index e3f2b225ea..a2399bcb7c 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 0503804a7c..fadf270ebf 100644 --- a/tests/expectations/tests/inherit_named.rs +++ b/tests/expectations/tests/inherit_named.rs @@ -15,6 +15,8 @@ pub struct Weeee { pub _base: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for Weeee { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for Weeee { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/inherit_typedef.rs b/tests/expectations/tests/inherit_typedef.rs index 85af3e03af..1c07e1df4c 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Bar ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 2ca90d4006..5dcc6c4008 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 13f3b8ee7c..b31bbe04b2 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 406d9f5ece..39e156116e 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 c2592e577c..e208f0dcc6 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 { pub inline_storage: [CharT; 4usize], pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for std_basic_string__bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for std_basic_string__bindgen_ty_1 { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } -impl Default for std_basic_string { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for std_basic_string { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/inner_const.rs b/tests/expectations/tests/inner_const.rs index 1315bb6ac9..0a49c3f2ef 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 b94ba60f70..e58226595b 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::() , 16usize , concat ! ( - "Size of: " , stringify ! ( InstantiateIt ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 16usize, + concat!("Size of: ", stringify!(InstantiateIt)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 16usize , concat ! ( - "Size of template specialization: " , stringify ! ( LinkedList - ) )); - assert_eq!(::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of template specialization: " , stringify ! ( - LinkedList ) )); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of template specialization: ", stringify!(LinkedList)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 2ca90d4006..5dcc6c4008 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 c094b3337a..892148aa7d 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 6924d0a9d7..c2516bdacd 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::() , 24usize , concat ! ( - "Size of: " , stringify ! ( i ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 24usize, + concat!("Size of: ", stringify!(i)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 24usize , concat ! ( - "Size of: " , stringify ! ( d ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 24usize, + concat!("Size of: ", stringify!(d)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 264usize , concat ! ( - "Size of: " , stringify ! ( F ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 264usize, + concat!("Size of: ", stringify!(F)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 2fcefa123e..938cd5979d 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 d416548d88..d5634d53a6 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 66e1c04358..323da81eb3 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 7a9473660d..8975938d40 100644 --- a/tests/expectations/tests/issue-493.rs +++ b/tests/expectations/tests/issue-493.rs @@ -6,35 +6,47 @@ #[repr(C)] pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { +impl __BindgenUnionField { #[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 ::std::default::Default for __BindgenUnionField { +impl ::std::default::Default for __BindgenUnionField { #[inline] - fn default() -> Self { Self::new() } + fn default() -> Self { + Self::new() + } } -impl ::std::clone::Clone for __BindgenUnionField { +impl ::std::clone::Clone for __BindgenUnionField { #[inline] - fn clone(&self) -> Self { Self::new() } + fn clone(&self) -> Self { + Self::new() + } } -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { +impl ::std::marker::Copy for __BindgenUnionField {} +impl ::std::fmt::Debug for __BindgenUnionField { fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { fmt.write_str("__BindgenUnionField") } } -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) {} } -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { true } +impl ::std::cmp::PartialEq for __BindgenUnionField { + fn eq(&self, _other: &__BindgenUnionField) -> bool { + true + } } -impl ::std::cmp::Eq for __BindgenUnionField { } +impl ::std::cmp::Eq for __BindgenUnionField {} #[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 710cd41e26..da6dac7700 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(::std::marker::PhantomData); -impl __BindgenUnionField { +impl __BindgenUnionField { #[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 ::std::default::Default for __BindgenUnionField { +impl ::std::default::Default for __BindgenUnionField { #[inline] - fn default() -> Self { Self::new() } + fn default() -> Self { + Self::new() + } } -impl ::std::clone::Clone for __BindgenUnionField { +impl ::std::clone::Clone for __BindgenUnionField { #[inline] - fn clone(&self) -> Self { Self::new() } + fn clone(&self) -> Self { + Self::new() + } } -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { +impl ::std::marker::Copy for __BindgenUnionField {} +impl ::std::fmt::Debug for __BindgenUnionField { fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { fmt.write_str("__BindgenUnionField") } } -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) {} } -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { true } +impl ::std::cmp::PartialEq for __BindgenUnionField { + fn eq(&self, _other: &__BindgenUnionField) -> bool { + true + } } -impl ::std::cmp::Eq for __BindgenUnionField { } +impl ::std::cmp::Eq for __BindgenUnionField {} #[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 e217fe249d..071111a453 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 3eae94880a..d3814fba69 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( JS_AutoIdVector ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! - ( "Alignment of " , stringify ! ( JS_AutoIdVector ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(JS_AutoIdVector)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! ( - "Size of template specialization: " , stringify ! ( JS_Base ) - )); - assert_eq!(::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of template specialization: " , stringify ! ( - JS_Base ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of template specialization: ", stringify!(JS_Base)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 50ea61e075..fba41d1a51 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( AutoIdVector ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 1usize, + concat!("Size of: ", stringify!(AutoIdVector)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! ( - "Size of template specialization: " , stringify ! ( Outer ) )); - assert_eq!(::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of template specialization: " , stringify ! ( Outer - ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of template specialization: ", stringify!(Outer)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 0d13c10dca..e0554090ab 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::() , 1usize , concat ! ( - "Size of template specialization: " , stringify ! ( a ) )); - assert_eq!(::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of template specialization: " , stringify ! ( a ) - )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of template specialization: ", stringify!(a)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 87b38f283f..433c0baddd 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( A ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( A ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(A)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 { pub d: RefPtr, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for e { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for e { + 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( g ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 1usize, + concat!("Size of: ", stringify!(g)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( b ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( b ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(b)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! ( - "Size of template specialization: " , stringify ! ( f ) )); - assert_eq!(::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of template specialization: " , stringify ! ( f ) - )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of template specialization: ", stringify!(f)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 4bda092739..11571a2d6c 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 { pub use_of_t: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for RefPtr { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for RefPtr { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -20,6 +22,8 @@ pub struct UsesRefPtrWithAliasedTypeParam { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } pub type UsesRefPtrWithAliasedTypeParam_V = U; -impl Default for UsesRefPtrWithAliasedTypeParam { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for UsesRefPtrWithAliasedTypeParam { + 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 e67400cc82..2a48641f70 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Foo_Bar ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(Foo_Bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Baz_Bar ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(Baz_Bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Baz ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Baz ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Baz)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 82be5c925c..f0375cc8b4 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(::std::marker::PhantomData); -impl __IncompleteArrayField { +impl __IncompleteArrayField { #[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 __IncompleteArrayField { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } } -impl ::std::fmt::Debug for __IncompleteArrayField { +impl ::std::fmt::Debug for __IncompleteArrayField { fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { fmt.write_str("__IncompleteArrayField") } } -impl ::std::clone::Clone for __IncompleteArrayField { +impl ::std::clone::Clone for __IncompleteArrayField { #[inline] - fn clone(&self) -> Self { Self::new() } + fn clone(&self) -> Self { + Self::new() + } } -impl ::std::marker::Copy for __IncompleteArrayField { } +impl ::std::marker::Copy for __IncompleteArrayField {} #[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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( rte_ring_prod ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(rte_ring_prod)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( rte_ring_cons ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(rte_ring_cons)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 16usize , concat ! ( - "Size of: " , stringify ! ( rte_ring ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( rte_ring ) )); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(rte_ring)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 87228ec6b3..4d65c0aec5 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); +#[derive(Clone, Copy, Debug)] +pub struct RefPtr(T); #[repr(C)] pub struct HasRefPtr { @@ -11,6 +12,8 @@ pub struct HasRefPtr { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } pub type HasRefPtr_TypedefOfT = T; -impl Default for HasRefPtr { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for HasRefPtr { + 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 3e7c41954e..f5ecbd5e2d 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 { pub a: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for RefPtr { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for RefPtr { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -19,8 +21,10 @@ pub struct nsMainThreadPtrHolder { pub a: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for nsMainThreadPtrHolder { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for nsMainThreadPtrHolder { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -28,6 +32,8 @@ pub struct nsMainThreadPtrHandle { pub mPtr: RefPtr>, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for nsMainThreadPtrHandle { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for nsMainThreadPtrHandle { + 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 a1b97ca6ac..9e685b3add 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); +#[derive(Clone, Copy, Debug)] +pub struct RefPtr(T); #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -11,14 +12,18 @@ pub struct nsMainThreadPtrHolder { pub a: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for nsMainThreadPtrHolder { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for nsMainThreadPtrHolder { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] pub struct nsMainThreadPtrHandle { pub mPtr: RefPtr>, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for nsMainThreadPtrHandle { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for nsMainThreadPtrHandle { + 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 31fe3c5396..ee71cc554d 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::() , 1usize , - concat ! ( - "Size of: " , stringify ! ( CapturingContentInfo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 1usize, + concat!("Size of: ", stringify!(CapturingContentInfo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 cfbef26944..299909788e 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( c ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 1usize, + concat!("Size of: ", stringify!(c)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( B ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 1usize, + concat!("Size of: ", stringify!(B)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , - concat ! ( - "Size of template specialization: " , stringify ! ( - root::StaticRefPtr ) )); - assert_eq!(::std::mem::align_of::() , 1usize , - concat ! ( - "Alignment of template specialization: " , stringify ! ( - root::StaticRefPtr ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!( + "Size of template specialization: ", + stringify!(root::StaticRefPtr) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 71f794c387..f98720aaee 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( a ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 1usize, + concat!("Size of: ", stringify!(a)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( nsCSSValue ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 1usize, + concat!("Size of: ", stringify!(nsCSSValue)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 09f5ee20ee..aef7ed4a72 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( VirtualMethods ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( VirtualMethods ) )); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(VirtualMethods)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , - concat ! ( - "Size of: " , stringify ! ( ServoElementSnapshotTable ) )); - assert_eq! (::std::mem::align_of::() , 4usize , - concat ! ( - "Alignment of " , stringify ! ( ServoElementSnapshotTable ) - )); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(ServoElementSnapshotTable)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of template specialization: " , stringify ! ( Set ) )); - assert_eq!(::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of template specialization: " , stringify ! ( Set ) - )); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of template specialization: ", stringify!(Set)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 17e6398138..30d59ab702 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::() , 32usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 b07e17c4b5..896a9a6ca5 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( B ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( B ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(B)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( C ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 1usize, + concat!("Size of: ", stringify!(C)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 1e15360685..63ec6982b9 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Pupper ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Pupper ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Pupper)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Doggo ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Doggo ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Doggo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( SuchWow ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( SuchWow ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(SuchWow)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Opaque ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Opaque ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Opaque)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Whitelisted ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 1usize, + concat!("Size of: ", stringify!(Whitelisted)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 c894b95c97..f84a70055b 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 4900bf2dcc..aa19dd1bd9 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 9de7c64f01..4ee4602ab9 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 { pub hdr: *const T } +#[repr(C)] +pub struct nsTArray { + 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 1e507ad21f..35f0c13fc2 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( U ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( U ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(U)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 9f446d7045..6d2b0c5e32 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Type ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Type ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Type)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 c5ecb96665..a464442e45 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::() , - 1usize , concat ! ( - "Size of: " , stringify ! ( jsval_layout__bindgen_ty_1 ) - )); - assert_eq! (::std::mem::align_of::() , - 1usize , concat ! ( - "Alignment of " , stringify ! ( jsval_layout__bindgen_ty_1 - ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(jsval_layout__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( jsval_layout ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! - ( "Alignment of " , stringify ! ( jsval_layout ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(jsval_layout)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 28ebdc76f3..eedf1e2b62 100644 --- a/tests/expectations/tests/layout.rs +++ b/tests/expectations/tests/layout.rs @@ -7,13 +7,15 @@ #[repr(C)] #[derive(Default)] pub struct __IncompleteArrayField(::std::marker::PhantomData); -impl __IncompleteArrayField { +impl __IncompleteArrayField { #[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 __IncompleteArrayField { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } } -impl ::std::fmt::Debug for __IncompleteArrayField { +impl ::std::fmt::Debug for __IncompleteArrayField { fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { fmt.write_str("__IncompleteArrayField") } } -impl ::std::clone::Clone for __IncompleteArrayField { +impl ::std::clone::Clone for __IncompleteArrayField { #[inline] - fn clone(&self) -> Self { Self::new() } + fn clone(&self) -> Self { + Self::new() + } } -impl ::std::marker::Copy for __IncompleteArrayField { } +impl ::std::marker::Copy for __IncompleteArrayField {} #[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::
() , 16usize , concat ! ( - "Size of: " , stringify ! ( header ) )); + assert_eq!( + ::std::mem::size_of::
(), + 16usize, + concat!("Size of: ", stringify!(header)) + ); } diff --git a/tests/expectations/tests/layout_arp.rs b/tests/expectations/tests/layout_arp.rs index 8f8530686e..4f9145b6a8 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::() , 6usize , concat ! ( - "Size of: " , stringify ! ( ether_addr ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 6usize, + concat!("Size of: ", stringify!(ether_addr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 20usize , concat ! ( - "Size of: " , stringify ! ( arp_ipv4 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 20usize, + concat!("Size of: ", stringify!(arp_ipv4)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 28usize , concat ! ( - "Size of: " , stringify ! ( arp_hdr ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 28usize, + concat!("Size of: ", stringify!(arp_hdr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 6cfd85a483..53c6d8c39a 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 72552bea93..facc85b244 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::() , 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::(), + 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 0d86acda61..7c8ab86580 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(::std::marker::PhantomData); -impl __IncompleteArrayField { +impl __IncompleteArrayField { #[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 __IncompleteArrayField { ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } } -impl ::std::fmt::Debug for __IncompleteArrayField { +impl ::std::fmt::Debug for __IncompleteArrayField { fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { fmt.write_str("__IncompleteArrayField") } } -impl ::std::clone::Clone for __IncompleteArrayField { +impl ::std::clone::Clone for __IncompleteArrayField { #[inline] - fn clone(&self) -> Self { Self::new() } + fn clone(&self) -> Self { + Self::new() + } } -impl ::std::marker::Copy for __IncompleteArrayField { } +impl ::std::marker::Copy for __IncompleteArrayField {} 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::() , 16usize , concat ! ( - "Size of: " , stringify ! ( ip_frag ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 16usize, + concat!("Size of: ", stringify!(ip_frag)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 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::() , 40usize , concat ! ( - "Size of: " , stringify ! ( ip_frag_key ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 40usize, + concat!("Size of: ", stringify!(ip_frag_key)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 16usize , - concat ! ( - "Size of: " , stringify ! ( ip_frag_pkt__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 16usize, + concat!("Size of: ", stringify!(ip_frag_pkt__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 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::(), + 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::() , 16usize , concat ! ( - "Size of: " , stringify ! ( ip_pkt_list ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 16usize, + concat!("Size of: ", stringify!(ip_pkt_list)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 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::(), + 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::() , 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::(), + 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 96186774b1..e237eeef19 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 96186774b1..e237eeef19 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 6f758141b5..39a020ad76 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 ffaf52cf2a..747ccbf58f 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 e44b6e7dbc..eada760b5b 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 ad2c92fc6d..0e1d5641e4 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Test ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Test ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Test)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 589f8995a8..848c656f6a 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( A ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(A)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 06f1df5068..2af91b4c0d 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Bar ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Baz ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Baz ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Baz)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 9c98613769..f7f580b2cb 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( C ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(C)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( NonCopiable ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(NonCopiable)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() - , 4usize , concat ! ( - "Size of: " , stringify ! ( - NonCopiableWithNonCopiableMutableMember ) )); - assert_eq! (::std::mem::align_of::() - , 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::(), + 4usize, + concat!( + "Size of: ", + stringify!(NonCopiableWithNonCopiableMutableMember) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 6349748d00..e6077152ff 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; } } diff --git a/tests/expectations/tests/nested.rs b/tests/expectations/tests/nested.rs index 929732f68b..a8c7775c5f 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Calc ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(Calc)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat - ! ( "Size of: " , stringify ! ( Test_Size_Dimension ) )); - assert_eq! (::std::mem::align_of::() , 4usize , - concat ! ( - "Alignment of " , stringify ! ( Test_Size_Dimension ) )); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(Test_Size_Dimension)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Test_Size ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(Test_Size)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Test ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Test ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Test)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 d6579ec24e..0da5289ed0 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( nsISupports ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( nsISupports ) )); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(nsISupports)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( nsIRunnable ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( nsIRunnable ) )); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(nsIRunnable)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Runnable ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( Runnable ) )); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(Runnable)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 8021b831f2..d291a53738 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Bar_Baz ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(Bar_Baz)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Baz ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(Baz)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 e67b156beb..b097acd62d 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 30dc9e6979..3901339a98 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 41b3b18402..252b51ff44 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::() , 16usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::core::mem::align_of::() , 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::(), + 16usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::core::mem::align_of::(), + 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 c367d8060d..4a6626a095 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::() , 40usize , concat ! ( - "Size of: " , stringify ! ( UsesArray ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 40usize, + concat!("Size of: ", stringify!(UsesArray)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 d9287e00ba..0c9f1ec618 100644 --- a/tests/expectations/tests/nsStyleAutoArray.rs +++ b/tests/expectations/tests/nsStyleAutoArray.rs @@ -10,8 +10,10 @@ pub struct nsTArray { pub mBuff: *mut T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for nsTArray { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for nsTArray { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -25,6 +27,8 @@ pub struct nsStyleAutoArray { pub enum nsStyleAutoArray_WithSingleInitialElement { WITH_SINGLE_INITIAL_ELEMENT = 0, } -impl Default for nsStyleAutoArray { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for nsStyleAutoArray { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/objc_category.rs b/tests/expectations/tests/objc_category.rs index 2f29adc970..ba37b819cf 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 2f6f00c755..b5c15a0e2a 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 1108219d86..e8c1278ac2 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 0b3721efe7..446e638450 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( FooStruct ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(FooStruct)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 aa7e729126..33a81fa44c 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 9c05aca0bc..8802c206ea 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 4eba7c7f94..38881ad0fe 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 0981844689..e541e64839 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) + ) + ); + assert_eq!( + ::std::mem::align_of::>(), + 1usize, + concat!( + "Alignment of template specialization: ", + stringify!(root::zoidberg::Template) ) ); - 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 480dba4855..779c32a60e 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::>(), + 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 afae3127e6..62f63c4298 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Container ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Container ) )); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(Container)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 bc4a5347cc..0e8700dc56 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 ab417e8e2d..28b783c334 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 d5dca70c76..df9ecf3cda 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 e29ad1ba57..73f6377d4c 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( HasPrivate ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(HasPrivate)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 + } } ///
#[repr(C)] @@ -40,23 +58,41 @@ pub struct VeryPrivate { } #[test] fn bindgen_test_layout_VeryPrivate() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( VeryPrivate ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(VeryPrivate)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 + } } ///
#[repr(C)] @@ -68,21 +104,39 @@ pub struct ContradictPrivate { } #[test] fn bindgen_test_layout_ContradictPrivate() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! - ( "Size of: " , stringify ! ( ContradictPrivate ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(ContradictPrivate)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 dab2976292..f551c2cbf5 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( cv_String ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( cv_String ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(cv_String)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 ea5d0e18d1..fd57dd5732 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( nsID ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( nsID ) )); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(nsID)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 c9e859114b..0402c95c44 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 7f8127fd65..9d49052e67 100644 --- a/tests/expectations/tests/replaces_double.rs +++ b/tests/expectations/tests/replaces_double.rs @@ -10,8 +10,10 @@ pub struct Wrapper_Wrapped { pub t: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for Wrapper_Wrapped { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for Wrapper_Wrapped { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } pub type Wrapper_Type = Wrapper_Wrapped; #[repr(C)] @@ -22,6 +24,8 @@ pub struct Rooted { } ///
pub type Rooted_MaybeWrapped = T; -impl Default for Rooted { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for Rooted { + 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 e406cf33b5..3575a581aa 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( JS_shadow_Zone ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(JS_shadow_Zone)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 7d105c2a85..61d35e25d3 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 73eb45d7d8..c3b26da93a 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 b3adbee6bc..16a72e25b7 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::() , 12usize , concat ! ( - "Size of: " , stringify ! ( C ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 12usize, + concat!("Size of: ", stringify!(C)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 db47ce6fd5..12e13dc8cf 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::
() , 8usize , concat ! ( - "Size of: " , stringify ! ( a ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(a)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( b ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(b)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 fb680b6988..f1e195fdf1 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::() , 1usize , concat - ! ( "Size of: " , stringify ! ( typedef_named_struct ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 1usize, + concat!("Size of: ", stringify!(typedef_named_struct)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 024eaac44d..d386c79b8f 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::() , 8usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 fe3e8b0c97..2826c36e57 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::() , 8usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_2 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 208usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 208usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 006de1cd4f..bf3ad0499d 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::() , 8usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 a43ba4eef7..665ec30867 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::() , 4usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 4a25fd6d5b..e02e78e916 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(::std::marker::PhantomData); -impl __BindgenUnionField { +impl __BindgenUnionField { #[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 ::std::default::Default for __BindgenUnionField { +impl ::std::default::Default for __BindgenUnionField { #[inline] - fn default() -> Self { Self::new() } + fn default() -> Self { + Self::new() + } } -impl ::std::clone::Clone for __BindgenUnionField { +impl ::std::clone::Clone for __BindgenUnionField { #[inline] - fn clone(&self) -> Self { Self::new() } + fn clone(&self) -> Self { + Self::new() + } } -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { +impl ::std::marker::Copy for __BindgenUnionField {} +impl ::std::fmt::Debug for __BindgenUnionField { fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { fmt.write_str("__BindgenUnionField") } } -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) {} } -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { true } +impl ::std::cmp::PartialEq for __BindgenUnionField { + fn eq(&self, _other: &__BindgenUnionField) -> bool { + true + } } -impl ::std::cmp::Eq for __BindgenUnionField { } +impl ::std::cmp::Eq for __BindgenUnionField {} #[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::() , 4usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 0349d70ce1..ba596f334e 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::() , 8usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 af25e4e497..37ba81c332 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::() , 4usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 5ce4064f67..0f958b039a 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(::std::marker::PhantomData); -impl __BindgenUnionField { +impl __BindgenUnionField { #[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 ::std::default::Default for __BindgenUnionField { +impl ::std::default::Default for __BindgenUnionField { #[inline] - fn default() -> Self { Self::new() } + fn default() -> Self { + Self::new() + } } -impl ::std::clone::Clone for __BindgenUnionField { +impl ::std::clone::Clone for __BindgenUnionField { #[inline] - fn clone(&self) -> Self { Self::new() } + fn clone(&self) -> Self { + Self::new() + } } -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { +impl ::std::marker::Copy for __BindgenUnionField {} +impl ::std::fmt::Debug for __BindgenUnionField { fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { fmt.write_str("__BindgenUnionField") } } -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) {} } -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { true } +impl ::std::cmp::PartialEq for __BindgenUnionField { + fn eq(&self, _other: &__BindgenUnionField) -> bool { + true + } } -impl ::std::cmp::Eq for __BindgenUnionField { } +impl ::std::cmp::Eq for __BindgenUnionField {} #[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::() , 4usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 03046674d3..f681e21e94 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::() , 128usize , concat ! ( - "Size of: " , stringify ! ( LittleArray ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 128usize, + concat!("Size of: ", stringify!(LittleArray)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 132usize , concat ! ( - "Size of: " , stringify ! ( BigArray ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 132usize, + concat!("Size of: ", stringify!(BigArray)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 128usize , concat ! - ( "Size of: " , stringify ! ( WithLittleArray ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 128usize, + concat!("Size of: ", stringify!(WithLittleArray)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 132usize , concat ! ( - "Size of: " , stringify ! ( WithBigArray ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 132usize, + concat!("Size of: ", stringify!(WithBigArray)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 0f2accba00..73b29fd90d 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::() , 33usize , concat ! ( - "Size of: " , stringify ! ( S ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 33usize, + concat!("Size of: ", stringify!(S)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 { pub large_array: [T; 33usize], pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for ST { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for ST { + 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 7b82964f41..d25fc4bc28 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::() , - 4usize , concat ! ( - "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_1 ) - )); - assert_eq! (::std::mem::align_of::() , - 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::(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , - 4usize , concat ! ( - "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_2 ) - )); - assert_eq! (::std::mem::align_of::() , - 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::(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 5d014b9505..4701409aab 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(::std::marker::PhantomData); -impl __BindgenUnionField { +impl __BindgenUnionField { #[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 ::std::default::Default for __BindgenUnionField { +impl ::std::default::Default for __BindgenUnionField { #[inline] - fn default() -> Self { Self::new() } + fn default() -> Self { + Self::new() + } } -impl ::std::clone::Clone for __BindgenUnionField { +impl ::std::clone::Clone for __BindgenUnionField { #[inline] - fn clone(&self) -> Self { Self::new() } + fn clone(&self) -> Self { + Self::new() + } } -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { +impl ::std::marker::Copy for __BindgenUnionField {} +impl ::std::fmt::Debug for __BindgenUnionField { fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { fmt.write_str("__BindgenUnionField") } } -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) {} } -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { true } +impl ::std::cmp::PartialEq for __BindgenUnionField { + fn eq(&self, _other: &__BindgenUnionField) -> bool { + true + } } -impl ::std::cmp::Eq for __BindgenUnionField { } +impl ::std::cmp::Eq for __BindgenUnionField {} #[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::() , - 4usize , concat ! ( - "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_1 ) - )); - assert_eq! (::std::mem::align_of::() , - 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::(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , - 4usize , concat ! ( - "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_2 ) - )); - assert_eq! (::std::mem::align_of::() , - 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::(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 1b3f4ca28a..acdcd9b37f 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::() , 3usize , concat ! ( - "Size of: " , stringify ! ( a ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 3usize, + concat!("Size of: ", stringify!(a)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 47c99937f9..22676961e8 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::() , 8usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 ad4f394a04..2c21656ad6 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 = - ::std::option::Option; +pub type Proxy_foo = ::std::option::Option; diff --git a/tests/expectations/tests/template-fun-ty.rs b/tests/expectations/tests/template-fun-ty.rs index 8403f794a6..cce6c24d3c 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 = - ::std::option::Option T>; +pub type Foo_FunctionPtr = ::std::option::Option 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 = - ::std::option::Option R>; +pub type RefPtr_Proxy_member_function = ::std::option::Option< + unsafe extern "C" fn(arg1: Args) -> R, +>; pub type Returner = ::std::option::Option T>; diff --git a/tests/expectations/tests/template-param-usage-0.rs b/tests/expectations/tests/template-param-usage-0.rs index 4f74a1448c..d5ca7d7dac 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 { pub t: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for UsesTemplateParameter { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for UsesTemplateParameter { + 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 a01597c12f..940be664bc 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 { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub _phantom_1: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for DoublyIndirectUsage_IndirectUsage { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for DoublyIndirectUsage_IndirectUsage { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } -impl Default for DoublyIndirectUsage { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for DoublyIndirectUsage { + 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 5912bdf592..d6a540851b 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 { pub t: *mut T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for BaseUsesT { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for BaseUsesT { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -20,6 +22,8 @@ pub struct CrtpUsesU { pub usage: U, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for CrtpUsesU { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for CrtpUsesU { + 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 4721968f27..855c76fefd 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 { pub usage: U, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for CrtpUsesU { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for CrtpUsesU { + 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 d4c8665286..97dbba46fd 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 9b7f30ec9c..405e8198e8 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 { pub usage: *mut T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for BaseUsesT { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for BaseUsesT { + 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 d017976b05..24086724a0 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 { pub also: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for UsesTemplateParameter_AlsoUsesTemplateParameter { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for UsesTemplateParameter_AlsoUsesTemplateParameter { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } -impl Default for UsesTemplateParameter { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for UsesTemplateParameter { + 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 85a96d542c..0e5d2fdf0e 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 { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub _phantom_1: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for - UsesTemplateParameter_AlsoUsesTemplateParameterAndMore { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for UsesTemplateParameter_AlsoUsesTemplateParameterAndMore { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } -impl Default for UsesTemplateParameter { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for UsesTemplateParameter { + 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 5e9e004c42..af36754f00 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 { pub struct UsesTemplateParameter_DoesNotUseTemplateParameters { pub x: ::std::os::raw::c_int, } -impl Default for UsesTemplateParameter { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for UsesTemplateParameter { + 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 375a60dfd4..46ae3513c6 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 { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } pub type IndirectlyUsesTemplateParameter_Aliased = T; -impl Default for IndirectlyUsesTemplateParameter { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for IndirectlyUsesTemplateParameter { + 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 38b3e832b1..b30c82b40e 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 { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub _phantom_1: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for DoesNotUseU { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for DoesNotUseU { + 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 9a0f428faa..75e14706f5 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 { } pub type IndirectUsage_Typedefed = T; pub type IndirectUsage_Aliased = U; -impl Default for IndirectUsage { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for IndirectUsage { + 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 88fea7254d..3071924e49 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 { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub _phantom_1: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for DoesNotUse_IndirectUsage { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for DoesNotUse_IndirectUsage { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/template.rs b/tests/expectations/tests/template.rs index 3f397b6ff3..46eb0a33e5 100644 --- a/tests/expectations/tests/template.rs +++ b/tests/expectations/tests/template.rs @@ -411,7 +411,7 @@ pub struct NestedContainer { pub inc: Incomplete, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for NestedContainer { +impl Default for NestedContainer { fn default() -> Self { unsafe { ::std::mem::zeroed() } } @@ -422,7 +422,7 @@ pub struct Incomplete { pub d: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for Incomplete { +impl Default for Incomplete { 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::>(), + 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::>(), + 4usize, + concat!( + "Size of template specialization: ", + stringify!(B<::std::os::raw::c_uint>) + ) + ); + assert_eq!( + ::std::mem::align_of::>(), + 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::>(), + 8usize, + concat!( + "Size of template specialization: ", + stringify!(B<*const ::std::os::raw::c_int>) + ) + ); + assert_eq!( + ::std::mem::align_of::>(), + 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::>(), + 8usize, + concat!( + "Size of template specialization: ", + stringify!(B<*const mozilla_Foo>) + ) + ); + assert_eq!( + ::std::mem::align_of::>(), + 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::>(), + 8usize, + concat!( + "Size of template specialization: ", + stringify!(B<[*const mozilla_Foo; 1usize]>) + ) + ); + assert_eq!( + ::std::mem::align_of::>(), + 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::>(), + 4usize, + concat!( + "Size of template specialization: ", + stringify!(B<::std::os::raw::c_int>) + ) + ); + assert_eq!( + ::std::mem::align_of::>(), + 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::>(), + 4usize, + concat!( + "Size of template specialization: ", + stringify!(B<::std::os::raw::c_int>) + ) + ); + assert_eq!( + ::std::mem::align_of::>(), + 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::>(), + 1usize, + concat!("Size of template specialization: ", stringify!(B)) + ); + assert_eq!( + ::std::mem::align_of::>(), + 1usize, + concat!( + "Alignment of template specialization: ", + stringify!(B) + ) + ); } #[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::>(), + 2usize, + concat!("Size of template specialization: ", stringify!(B)) + ); + assert_eq!( + ::std::mem::align_of::>(), + 2usize, + concat!("Alignment of template specialization: ", stringify!(B)) + ); } #[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::>(), + 4usize, + concat!( + "Size of template specialization: ", + stringify!(B<[::std::os::raw::c_int; 1usize]>) + ) + ); + assert_eq!( + ::std::mem::align_of::>(), + 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::>(), + 8usize, + concat!( + "Size of template specialization: ", + stringify!(B<[*mut ::std::os::raw::c_int; 1usize]>) + ) + ); + assert_eq!( + ::std::mem::align_of::>(), + 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::>(), + 8usize, + concat!( + "Size of template specialization: ", + stringify!(B<*mut [::std::os::raw::c_int; 1usize]>) + ) + ); + assert_eq!( + ::std::mem::align_of::>(), + 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::>(), + 8usize, + concat!( + "Size of template specialization: ", + stringify!(B<*mut ::std::os::raw::c_int>) + ) + ); + assert_eq!( + ::std::mem::align_of::>(), + 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::>(), + 8usize, + concat!( + "Size of template specialization: ", + stringify!(B<*const ::std::os::raw::c_int>) + ) + ); + assert_eq!( + ::std::mem::align_of::>(), + 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::>(), + 8usize, + concat!( + "Size of template specialization: ", + stringify!(B<*mut *mut ::std::os::raw::c_int>) + ) + ); + assert_eq!( + ::std::mem::align_of::>(), + 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::>(), + 8usize, + concat!( + "Size of template specialization: ", + stringify!(B<*mut [::std::os::raw::c_int; 1usize]>) + ) + ); + assert_eq!( + ::std::mem::align_of::>(), + 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::>(), + 24usize, + concat!( + "Size of template specialization: ", + stringify!(Foo<::std::os::raw::c_int>) + ) + ); + assert_eq!( + ::std::mem::align_of::>(), + 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::>(), + 24usize, + concat!( + "Size of template specialization: ", + stringify!(Rooted<*mut ::std::os::raw::c_void>) + ) + ); + assert_eq!( + ::std::mem::align_of::>(), + 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::>(), + 24usize, + concat!( + "Size of template specialization: ", + stringify!(Rooted<*mut ::std::os::raw::c_void>) + ) + ); + assert_eq!( + ::std::mem::align_of::>(), + 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::>(), + 4usize, + concat!( + "Size of template specialization: ", + stringify!(WithDtor<::std::os::raw::c_int>) + ) + ); + assert_eq!( + ::std::mem::align_of::>(), + 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 c3f080dbf9..9b66adf64e 100644 --- a/tests/expectations/tests/template_alias.rs +++ b/tests/expectations/tests/template_alias.rs @@ -11,6 +11,8 @@ pub struct JS_Rooted { pub ptr: JS_detail_Wrapped, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for JS_Rooted { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for JS_Rooted { + 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 a9cd315d90..dc03a23173 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, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } - impl Default for Rooted { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + impl Default for Rooted { + 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 2ca90d4006..5dcc6c4008 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 7768d522e6..311dd97441 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 { pub t: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for Wrapper_Wrapped { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for Wrapper_Wrapped { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } pub type Wrapper_Type = Wrapper_Wrapped; 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 88dc5d8b5f..c53d5de35c 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 ::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::() , 12usize , concat ! ( - "Size of: " , stringify ! ( Test ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 12usize, + concat!("Size of: ", stringify!(Test)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 63d64654f4..3334eff5a2 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( dl_phdr_info ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(dl_phdr_info)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 21d198a65a..0a2e80fb2d 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 { pub ptr: MaybeWrapped, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for Rooted { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for Rooted { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/expectations/tests/typeref.rs b/tests/expectations/tests/typeref.rs index 2bbdcbb148..f8ed525bdb 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::() , 1usize , - concat ! ( "Size of: " , stringify ! ( mozilla_FragmentOrURL ) - )); - assert_eq! (::std::mem::align_of::() , 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::(), + 1usize, + concat!("Size of: ", stringify!(mozilla_FragmentOrURL)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( mozilla_Position ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! - ( "Alignment of " , stringify ! ( mozilla_Position ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(mozilla_Position)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( nsFoo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(nsFoo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , - concat ! ( - "Size of template specialization: " , stringify ! ( - mozilla_StyleShapeSource ) )); - assert_eq!(::std::mem::align_of::() , 8usize , - concat ! ( - "Alignment of template specialization: " , stringify ! ( - mozilla_StyleShapeSource ) )); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!( + "Size of template specialization: ", + stringify!(mozilla_StyleShapeSource) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 a99df0ad9b..6796ced809 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(::std::marker::PhantomData); -impl __BindgenUnionField { +impl __BindgenUnionField { #[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 ::std::default::Default for __BindgenUnionField { +impl ::std::default::Default for __BindgenUnionField { #[inline] - fn default() -> Self { Self::new() } + fn default() -> Self { + Self::new() + } } -impl ::std::clone::Clone for __BindgenUnionField { +impl ::std::clone::Clone for __BindgenUnionField { #[inline] - fn clone(&self) -> Self { Self::new() } + fn clone(&self) -> Self { + Self::new() + } } -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { +impl ::std::marker::Copy for __BindgenUnionField {} +impl ::std::fmt::Debug for __BindgenUnionField { fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { fmt.write_str("__BindgenUnionField") } } -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) {} } -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { true } +impl ::std::cmp::PartialEq for __BindgenUnionField { + fn eq(&self, _other: &__BindgenUnionField) -> bool { + true + } } -impl ::std::cmp::Eq for __BindgenUnionField { } +impl ::std::cmp::Eq for __BindgenUnionField {} #[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::() , 1usize , - concat ! ( "Size of: " , stringify ! ( mozilla_FragmentOrURL ) - )); - assert_eq! (::std::mem::align_of::() , 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::(), + 1usize, + concat!("Size of: ", stringify!(mozilla_FragmentOrURL)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( mozilla_Position ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! - ( "Alignment of " , stringify ! ( mozilla_Position ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(mozilla_Position)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( nsFoo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(nsFoo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , - concat ! ( - "Size of template specialization: " , stringify ! ( - mozilla_StyleShapeSource ) )); - assert_eq!(::std::mem::align_of::() , 8usize , - concat ! ( - "Alignment of template specialization: " , stringify ! ( - mozilla_StyleShapeSource ) )); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!( + "Size of template specialization: ", + stringify!(mozilla_StyleShapeSource) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 cb8779bd3c..a29b503835 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( bar ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 b3618ab7a6..ec2014a519 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(::std::marker::PhantomData); - impl __BindgenUnionField { + impl __BindgenUnionField { #[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 ::std::default::Default for __BindgenUnionField { + impl ::std::default::Default for __BindgenUnionField { #[inline] - fn default() -> Self { Self::new() } + fn default() -> Self { + Self::new() + } } - impl ::std::clone::Clone for __BindgenUnionField { + impl ::std::clone::Clone for __BindgenUnionField { #[inline] - fn clone(&self) -> Self { Self::new() } + fn clone(&self) -> Self { + Self::new() + } } - impl ::std::marker::Copy for __BindgenUnionField { } - impl ::std::fmt::Debug for __BindgenUnionField { + impl ::std::marker::Copy for __BindgenUnionField {} + impl ::std::fmt::Debug for __BindgenUnionField { fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { fmt.write_str("__BindgenUnionField") } } - impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } + impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) {} } - impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { true } + impl ::std::cmp::PartialEq for __BindgenUnionField { + fn eq(&self, _other: &__BindgenUnionField) -> bool { + true + } } - impl ::std::cmp::Eq for __BindgenUnionField { } + impl ::std::cmp::Eq for __BindgenUnionField {} #[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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( bar ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 0721494f38..e62521bc07 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( UnionWithDtor ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(UnionWithDtor)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 c59d4f35a4..f7896dc736 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(::std::marker::PhantomData); -impl __BindgenUnionField { +impl __BindgenUnionField { #[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 ::std::default::Default for __BindgenUnionField { +impl ::std::default::Default for __BindgenUnionField { #[inline] - fn default() -> Self { Self::new() } + fn default() -> Self { + Self::new() + } } -impl ::std::clone::Clone for __BindgenUnionField { +impl ::std::clone::Clone for __BindgenUnionField { #[inline] - fn clone(&self) -> Self { Self::new() } + fn clone(&self) -> Self { + Self::new() + } } -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { +impl ::std::marker::Copy for __BindgenUnionField {} +impl ::std::fmt::Debug for __BindgenUnionField { fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { fmt.write_str("__BindgenUnionField") } } -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) {} } -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { true } +impl ::std::cmp::PartialEq for __BindgenUnionField { + fn eq(&self, _other: &__BindgenUnionField) -> bool { + true + } } -impl ::std::cmp::Eq for __BindgenUnionField { } +impl ::std::cmp::Eq for __BindgenUnionField {} #[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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( UnionWithDtor ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(UnionWithDtor)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 90319ee6bd..988b7ae8e1 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( nsStyleUnion ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(nsStyleUnion)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 3f244b787d..1e10ff971c 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(::std::marker::PhantomData); -impl __BindgenUnionField { +impl __BindgenUnionField { #[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 ::std::default::Default for __BindgenUnionField { +impl ::std::default::Default for __BindgenUnionField { #[inline] - fn default() -> Self { Self::new() } + fn default() -> Self { + Self::new() + } } -impl ::std::clone::Clone for __BindgenUnionField { +impl ::std::clone::Clone for __BindgenUnionField { #[inline] - fn clone(&self) -> Self { Self::new() } + fn clone(&self) -> Self { + Self::new() + } } -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { +impl ::std::marker::Copy for __BindgenUnionField {} +impl ::std::fmt::Debug for __BindgenUnionField { fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { fmt.write_str("__BindgenUnionField") } } -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) {} } -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { true } +impl ::std::cmp::PartialEq for __BindgenUnionField { + fn eq(&self, _other: &__BindgenUnionField) -> bool { + true + } } -impl ::std::cmp::Eq for __BindgenUnionField { } +impl ::std::cmp::Eq for __BindgenUnionField {} #[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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( nsStyleUnion ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(nsStyleUnion)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 f6418fd6b2..515d568867 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 afe14c7018..7b350b0786 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(::std::marker::PhantomData); -impl __BindgenUnionField { +impl __BindgenUnionField { #[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 ::std::default::Default for __BindgenUnionField { +impl ::std::default::Default for __BindgenUnionField { #[inline] - fn default() -> Self { Self::new() } + fn default() -> Self { + Self::new() + } } -impl ::std::clone::Clone for __BindgenUnionField { +impl ::std::clone::Clone for __BindgenUnionField { #[inline] - fn clone(&self) -> Self { Self::new() } + fn clone(&self) -> Self { + Self::new() + } } -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { +impl ::std::marker::Copy for __BindgenUnionField {} +impl ::std::fmt::Debug for __BindgenUnionField { fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { fmt.write_str("__BindgenUnionField") } } -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) {} } -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { true } +impl ::std::cmp::PartialEq for __BindgenUnionField { + fn eq(&self, _other: &__BindgenUnionField) -> bool { + true + } } -impl ::std::cmp::Eq for __BindgenUnionField { } +impl ::std::cmp::Eq for __BindgenUnionField {} #[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 d48538a0cb..320ce820bf 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::() , 8usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 8c0971f7bc..b79be1277e 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(::std::marker::PhantomData); -impl __BindgenUnionField { +impl __BindgenUnionField { #[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 ::std::default::Default for __BindgenUnionField { +impl ::std::default::Default for __BindgenUnionField { #[inline] - fn default() -> Self { Self::new() } + fn default() -> Self { + Self::new() + } } -impl ::std::clone::Clone for __BindgenUnionField { +impl ::std::clone::Clone for __BindgenUnionField { #[inline] - fn clone(&self) -> Self { Self::new() } + fn clone(&self) -> Self { + Self::new() + } } -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { +impl ::std::marker::Copy for __BindgenUnionField {} +impl ::std::fmt::Debug for __BindgenUnionField { fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { fmt.write_str("__BindgenUnionField") } } -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) {} } -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { true } +impl ::std::cmp::PartialEq for __BindgenUnionField { + fn eq(&self, _other: &__BindgenUnionField) -> bool { + true + } } -impl ::std::cmp::Eq for __BindgenUnionField { } +impl ::std::cmp::Eq for __BindgenUnionField {} #[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::() , 8usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 29dbe7dc2e..cb78c900bf 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::() , 4usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 62a62f85d6..958d8e67d7 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(::std::marker::PhantomData); -impl __BindgenUnionField { +impl __BindgenUnionField { #[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 ::std::default::Default for __BindgenUnionField { +impl ::std::default::Default for __BindgenUnionField { #[inline] - fn default() -> Self { Self::new() } + fn default() -> Self { + Self::new() + } } -impl ::std::clone::Clone for __BindgenUnionField { +impl ::std::clone::Clone for __BindgenUnionField { #[inline] - fn clone(&self) -> Self { Self::new() } + fn clone(&self) -> Self { + Self::new() + } } -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { +impl ::std::marker::Copy for __BindgenUnionField {} +impl ::std::fmt::Debug for __BindgenUnionField { fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { fmt.write_str("__BindgenUnionField") } } -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) {} } -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { true } +impl ::std::cmp::PartialEq for __BindgenUnionField { + fn eq(&self, _other: &__BindgenUnionField) -> bool { + true + } } -impl ::std::cmp::Eq for __BindgenUnionField { } +impl ::std::cmp::Eq for __BindgenUnionField {} #[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::() , 4usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 61b36d1aa7..8dd829e23b 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::() , 4usize , concat - ! ( "Size of: " , stringify ! ( pixel__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(pixel__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( pixel ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(pixel)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 45d824bae3..d0dc0088cd 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(::std::marker::PhantomData); -impl __BindgenUnionField { +impl __BindgenUnionField { #[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 ::std::default::Default for __BindgenUnionField { +impl ::std::default::Default for __BindgenUnionField { #[inline] - fn default() -> Self { Self::new() } + fn default() -> Self { + Self::new() + } } -impl ::std::clone::Clone for __BindgenUnionField { +impl ::std::clone::Clone for __BindgenUnionField { #[inline] - fn clone(&self) -> Self { Self::new() } + fn clone(&self) -> Self { + Self::new() + } } -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { +impl ::std::marker::Copy for __BindgenUnionField {} +impl ::std::fmt::Debug for __BindgenUnionField { fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { fmt.write_str("__BindgenUnionField") } } -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) {} } -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { true } +impl ::std::cmp::PartialEq for __BindgenUnionField { + fn eq(&self, _other: &__BindgenUnionField) -> bool { + true + } } -impl ::std::cmp::Eq for __BindgenUnionField { } +impl ::std::cmp::Eq for __BindgenUnionField {} #[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::() , 4usize , concat - ! ( "Size of: " , stringify ! ( pixel__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(pixel__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( pixel ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(pixel)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 4e0f4a18ba..dea8b39e16 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::() , 2usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 2usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 a33c1ccd0c..d746d45d7d 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(::std::marker::PhantomData); -impl __BindgenUnionField { +impl __BindgenUnionField { #[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 ::std::default::Default for __BindgenUnionField { +impl ::std::default::Default for __BindgenUnionField { #[inline] - fn default() -> Self { Self::new() } + fn default() -> Self { + Self::new() + } } -impl ::std::clone::Clone for __BindgenUnionField { +impl ::std::clone::Clone for __BindgenUnionField { #[inline] - fn clone(&self) -> Self { Self::new() } + fn clone(&self) -> Self { + Self::new() + } } -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { +impl ::std::marker::Copy for __BindgenUnionField {} +impl ::std::fmt::Debug for __BindgenUnionField { fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { fmt.write_str("__BindgenUnionField") } } -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) {} } -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { true } +impl ::std::cmp::PartialEq for __BindgenUnionField { + fn eq(&self, _other: &__BindgenUnionField) -> bool { + true + } } -impl ::std::cmp::Eq for __BindgenUnionField { } +impl ::std::cmp::Eq for __BindgenUnionField {} #[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::() , 2usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 2usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 9e86f42906..d5d19a9bee 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::() , 132usize , concat ! ( - "Size of: " , stringify ! ( WithBigArray ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 132usize, + concat!("Size of: ", stringify!(WithBigArray)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 36usize , concat ! ( - "Size of: " , stringify ! ( WithBigArray2 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 36usize, + concat!("Size of: ", stringify!(WithBigArray2)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 132usize , concat ! ( - "Size of: " , stringify ! ( WithBigMember ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 132usize, + concat!("Size of: ", stringify!(WithBigMember)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 03226ccef4..abf86dc8e5 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(::std::marker::PhantomData); -impl __BindgenUnionField { +impl __BindgenUnionField { #[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 ::std::default::Default for __BindgenUnionField { +impl ::std::default::Default for __BindgenUnionField { #[inline] - fn default() -> Self { Self::new() } + fn default() -> Self { + Self::new() + } } -impl ::std::clone::Clone for __BindgenUnionField { +impl ::std::clone::Clone for __BindgenUnionField { #[inline] - fn clone(&self) -> Self { Self::new() } + fn clone(&self) -> Self { + Self::new() + } } -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { +impl ::std::marker::Copy for __BindgenUnionField {} +impl ::std::fmt::Debug for __BindgenUnionField { fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { fmt.write_str("__BindgenUnionField") } } -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) {} } -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { true } +impl ::std::cmp::PartialEq for __BindgenUnionField { + fn eq(&self, _other: &__BindgenUnionField) -> bool { + true + } } -impl ::std::cmp::Eq for __BindgenUnionField { } +impl ::std::cmp::Eq for __BindgenUnionField {} #[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::() , 132usize , concat ! ( - "Size of: " , stringify ! ( WithBigArray ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 132usize, + concat!("Size of: ", stringify!(WithBigArray)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 36usize , concat ! ( - "Size of: " , stringify ! ( WithBigArray2 ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 36usize, + concat!("Size of: ", stringify!(WithBigArray2)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 132usize , concat ! ( - "Size of: " , stringify ! ( WithBigMember ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 132usize, + concat!("Size of: ", stringify!(WithBigMember)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 7ba8afcb41..9b27335d11 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::() , - 2usize , concat ! ( - "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_1 ) - )); - assert_eq! (::std::mem::align_of::() , - 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::(), + 2usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , - 2usize , concat ! ( - "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_2 ) - )); - assert_eq! (::std::mem::align_of::() , - 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::(), + 2usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 2usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 138707580f..1667c07e06 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(::std::marker::PhantomData); -impl __BindgenUnionField { +impl __BindgenUnionField { #[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 ::std::default::Default for __BindgenUnionField { +impl ::std::default::Default for __BindgenUnionField { #[inline] - fn default() -> Self { Self::new() } + fn default() -> Self { + Self::new() + } } -impl ::std::clone::Clone for __BindgenUnionField { +impl ::std::clone::Clone for __BindgenUnionField { #[inline] - fn clone(&self) -> Self { Self::new() } + fn clone(&self) -> Self { + Self::new() + } } -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { +impl ::std::marker::Copy for __BindgenUnionField {} +impl ::std::fmt::Debug for __BindgenUnionField { fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { fmt.write_str("__BindgenUnionField") } } -impl ::std::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) {} } -impl ::std::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { true } +impl ::std::cmp::PartialEq for __BindgenUnionField { + fn eq(&self, _other: &__BindgenUnionField) -> bool { + true + } } -impl ::std::cmp::Eq for __BindgenUnionField { } +impl ::std::cmp::Eq for __BindgenUnionField {} #[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::() , - 2usize , concat ! ( - "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_1 ) - )); - assert_eq! (::std::mem::align_of::() , - 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::(), + 2usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , - 2usize , concat ! ( - "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_2 ) - )); - assert_eq! (::std::mem::align_of::() , - 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::(), + 2usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 2usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(foo__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 dcd1e18ee1..5f7c1c3000 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::() , 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::(), + 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 b884f4f282..093c4a8345 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::() , 16usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::core::mem::align_of::() , 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::(), + 16usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::core::mem::align_of::(), + 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; +pub type fooFunction = ::core::option::Option; diff --git a/tests/expectations/tests/use-core_1_0.rs b/tests/expectations/tests/use-core_1_0.rs index 7caa0b0f23..4342d60627 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(::core::marker::PhantomData); -impl __BindgenUnionField { +impl __BindgenUnionField { #[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 ::core::default::Default for __BindgenUnionField { +impl ::core::default::Default for __BindgenUnionField { #[inline] - fn default() -> Self { Self::new() } + fn default() -> Self { + Self::new() + } } -impl ::core::clone::Clone for __BindgenUnionField { +impl ::core::clone::Clone for __BindgenUnionField { #[inline] - fn clone(&self) -> Self { Self::new() } + fn clone(&self) -> Self { + Self::new() + } } -impl ::core::marker::Copy for __BindgenUnionField { } -impl ::core::fmt::Debug for __BindgenUnionField { +impl ::core::marker::Copy for __BindgenUnionField {} +impl ::core::fmt::Debug for __BindgenUnionField { fn fmt(&self, fmt: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { fmt.write_str("__BindgenUnionField") } } -impl ::core::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) { } +impl ::core::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) {} } -impl ::core::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { true } +impl ::core::cmp::PartialEq for __BindgenUnionField { + fn eq(&self, _other: &__BindgenUnionField) -> bool { + true + } } -impl ::core::cmp::Eq for __BindgenUnionField { } +impl ::core::cmp::Eq for __BindgenUnionField {} #[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::() , 16usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::core::mem::align_of::() , 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::(), + 16usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::core::mem::align_of::(), + 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; +pub type fooFunction = ::core::option::Option; diff --git a/tests/expectations/tests/using.rs b/tests/expectations/tests/using.rs index 0dc1ec21cb..9bc5e303d4 100644 --- a/tests/expectations/tests/using.rs +++ b/tests/expectations/tests/using.rs @@ -11,8 +11,10 @@ pub struct Point { pub y: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for Point { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for Point { + 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 54ce92936a..5042f3f784 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Baz ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Baz ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Baz)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 6ef20b7653..6b3f70b3ce 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Bar ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Bar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 a4b87c7fdb..87096aa9e4 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 8usize, + concat!("Size of: ", stringify!(foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 0a9a5d092b..72086053d9 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( nsSlots ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( nsSlots ) )); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(nsSlots)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 e177dca819..40e5859f55 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::() , 4usize , concat ! ( - "Size of: " , stringify ! ( A ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 4usize, + concat!("Size of: ", stringify!(A)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 16usize , concat ! ( - "Size of: " , stringify ! ( B ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 16usize, + concat!("Size of: ", stringify!(B)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 16usize , concat ! ( - "Size of: " , stringify ! ( C ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 16usize, + concat!("Size of: ", stringify!(C)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 40usize , concat ! ( - "Size of: " , stringify ! ( D ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( D ) )); + assert_eq!( + ::std::mem::size_of::(), + 40usize, + concat!("Size of: ", stringify!(D)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 ce9a198d62..949fb38634 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( C ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( C ) )); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(C)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 6684134287..0f35890c5f 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Base ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( Base ) )); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(Base)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Derived ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( Derived ) )); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(Derived)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 daa6407bcf..49dc9960e9 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( UnknownUnits ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( UnknownUnits ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(UnknownUnits)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 { pub y: F, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for PointTyped { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for PointTyped { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } pub type IntPoint = PointTyped; diff --git a/tests/expectations/tests/whitelist-namespaces-basic.rs b/tests/expectations/tests/whitelist-namespaces-basic.rs index bdb35589e2..316ed44d07 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::() , 1usize , concat ! - ( "Size of: " , stringify ! ( Helper ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat - ! ( "Alignment of " , stringify ! ( Helper ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Helper)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 e19bdba3e4..01dce09a0c 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::() , 1usize , concat ! - ( "Size of: " , stringify ! ( Helper ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat - ! ( "Alignment of " , stringify ! ( Helper ) )); + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Helper)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Test ) )); - assert_eq! (::std::mem::align_of::() , 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::(), + 1usize, + concat!("Size of: ", stringify!(Test)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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 af151e3e4d..7ff1160dad 100644 --- a/tests/expectations/tests/whitelist_basic.rs +++ b/tests/expectations/tests/whitelist_basic.rs @@ -17,9 +17,13 @@ pub struct WhitelistMe_Inner { pub bar: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -impl Default for WhitelistMe_Inner { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for WhitelistMe_Inner { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } -impl Default for WhitelistMe { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +impl Default for WhitelistMe { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } diff --git a/tests/headers/inherit-from-template-instantiation-with-vtable.hpp b/tests/headers/inherit-from-template-instantiation-with-vtable.hpp new file mode 100644 index 0000000000..562ca0e1b2 --- /dev/null +++ b/tests/headers/inherit-from-template-instantiation-with-vtable.hpp @@ -0,0 +1,37 @@ +// bindgen-flags: -- -std=c++14 + +// Small test that we handle virtual tables correctly when deriving from a +// template instantiation. This wasn't previously handled at all. Note that when +// inheriting from a template parameter, the type that is instantiated might or +// might not have a virtual table, and we have no way of knowing. We don't +// handle that yet, so no test for it here. + +/// This should have an explicit vtable. +template +class BaseWithVtable { + T t; + + virtual void hello(); +}; + +/// This should not have an explicit vtable. +class DerivedWithNoVirtualMethods : public BaseWithVtable {}; + +/// This should not have an explicit vtable. +class DerivedWithVirtualMethods : public BaseWithVtable { + virtual void zoidberg(); +}; + +/// This should not have any vtable. +template +class BaseWithoutVtable { + U u; +}; + +/// This should have an explicit vtable. +class DerivedWithVtable : public BaseWithoutVtable { + virtual void leela(); +}; + +/// This should not have any vtable. +class DerivedWithoutVtable : public BaseWithoutVtable {};