Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/codegen/mod.rs
Original file line number Diff line number Diff line change
@@ -1642,7 +1642,10 @@ impl CodeGenerator for CompInfo {
ctx.options().derive_copy
{
derives.push("Copy");
if used_template_params.is_some() {

if ctx.options().rust_features().builtin_clone_impls() ||
used_template_params.is_some()
{
// FIXME: This requires extra logic if you have a big array in a
// templated struct. The reason for this is that the magic:
// fn clone(&self) -> Self { *self }
11 changes: 10 additions & 1 deletion src/features.rs
Original file line number Diff line number Diff line change
@@ -90,6 +90,8 @@ macro_rules! rust_target_base {
=> Stable_1_0 => 1.0;
/// Rust stable 1.19
=> Stable_1_19 => 1.19;
/// Rust stable 1.21
=> Stable_1_21 => 1.21;
/// Nightly rust
=> Nightly => nightly;
);
@@ -100,7 +102,7 @@ rust_target_base!(rust_target_def);
rust_target_base!(rust_target_values_def);

/// Latest stable release of Rust
pub const LATEST_STABLE_RUST: RustTarget = RustTarget::Stable_1_19;
pub const LATEST_STABLE_RUST: RustTarget = RustTarget::Stable_1_21;

/// Create RustFeatures struct definition, new(), and a getter for each field
macro_rules! rust_feature_def {
@@ -142,6 +144,8 @@ rust_feature_def!(
=> const_fn;
/// `thiscall` calling convention ([Tracking issue](https://github.com/rust-lang/rust/issues/42202))
=> thiscall_abi;
/// builtin impls for `Clone` ([PR](https://github.com/rust-lang/rust/pull/43690))
=> builtin_clone_impls;
);

impl From<RustTarget> for RustFeatures {
@@ -152,6 +156,10 @@ impl From<RustTarget> for RustFeatures {
features.untagged_union = true;
}

if rust_target >= RustTarget::Stable_1_21 {
features.builtin_clone_impls = true;
}

if rust_target >= RustTarget::Nightly {
features.const_fn = true;
features.thiscall_abi = true;
@@ -183,6 +191,7 @@ mod test {
fn str_to_target() {
test_target("1.0", RustTarget::Stable_1_0);
test_target("1.19", RustTarget::Stable_1_19);
test_target("1.21", RustTarget::Stable_1_21);
test_target("nightly", RustTarget::Nightly);
}
}
49 changes: 7 additions & 42 deletions tests/expectations/tests/16-byte-alignment.rs
Original file line number Diff line number Diff line change
@@ -5,21 +5,21 @@


#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct rte_ipv4_tuple {
pub src_addr: u32,
pub dst_addr: u32,
pub __bindgen_anon_1: rte_ipv4_tuple__bindgen_ty_1,
}
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub union rte_ipv4_tuple__bindgen_ty_1 {
pub __bindgen_anon_1: rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1,
pub sctp_tag: u32,
_bindgen_union_align: u32,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 {
pub dport: u16,
pub sport: u16,
@@ -67,11 +67,6 @@ fn bindgen_test_layout_rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1() {
)
);
}
impl Clone for rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 {
fn clone(&self) -> Self {
*self
}
}
#[test]
fn bindgen_test_layout_rte_ipv4_tuple__bindgen_ty_1() {
assert_eq!(
@@ -95,11 +90,6 @@ fn bindgen_test_layout_rte_ipv4_tuple__bindgen_ty_1() {
)
);
}
impl Clone for rte_ipv4_tuple__bindgen_ty_1 {
fn clone(&self) -> Self {
*self
}
}
impl Default for rte_ipv4_tuple__bindgen_ty_1 {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
@@ -138,32 +128,27 @@ fn bindgen_test_layout_rte_ipv4_tuple() {
)
);
}
impl Clone for rte_ipv4_tuple {
fn clone(&self) -> Self {
*self
}
}
impl Default for rte_ipv4_tuple {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct rte_ipv6_tuple {
pub src_addr: [u8; 16usize],
pub dst_addr: [u8; 16usize],
pub __bindgen_anon_1: rte_ipv6_tuple__bindgen_ty_1,
}
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub union rte_ipv6_tuple__bindgen_ty_1 {
pub __bindgen_anon_1: rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1,
pub sctp_tag: u32,
_bindgen_union_align: u32,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 {
pub dport: u16,
pub sport: u16,
@@ -211,11 +196,6 @@ fn bindgen_test_layout_rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1() {
)
);
}
impl Clone for rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 {
fn clone(&self) -> Self {
*self
}
}
#[test]
fn bindgen_test_layout_rte_ipv6_tuple__bindgen_ty_1() {
assert_eq!(
@@ -239,11 +219,6 @@ fn bindgen_test_layout_rte_ipv6_tuple__bindgen_ty_1() {
)
);
}
impl Clone for rte_ipv6_tuple__bindgen_ty_1 {
fn clone(&self) -> Self {
*self
}
}
impl Default for rte_ipv6_tuple__bindgen_ty_1 {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
@@ -282,18 +257,13 @@ fn bindgen_test_layout_rte_ipv6_tuple() {
)
);
}
impl Clone for rte_ipv6_tuple {
fn clone(&self) -> Self {
*self
}
}
impl Default for rte_ipv6_tuple {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub union rte_thash_tuple {
pub v4: rte_ipv4_tuple,
pub v6: rte_ipv6_tuple,
@@ -327,11 +297,6 @@ fn bindgen_test_layout_rte_thash_tuple() {
)
);
}
impl Clone for rte_thash_tuple {
fn clone(&self) -> Self {
*self
}
}
impl Default for rte_thash_tuple {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
42 changes: 6 additions & 36 deletions tests/expectations/tests/accessors.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct SomeAccessors {
pub mNoAccessor: ::std::os::raw::c_int,
/// <div rustbindgen accessor></div>
@@ -68,11 +68,6 @@ fn bindgen_test_layout_SomeAccessors() {
)
);
}
impl Clone for SomeAccessors {
fn clone(&self) -> Self {
*self
}
}
impl SomeAccessors {
#[inline]
pub fn get_mBothAccessors(&self) -> &::std::os::raw::c_int {
@@ -97,7 +92,7 @@ impl SomeAccessors {
}
/// <div rustbindgen accessor></div>
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct AllAccessors {
pub mBothAccessors: ::std::os::raw::c_int,
pub mAlsoBothAccessors: ::std::os::raw::c_int,
@@ -135,11 +130,6 @@ fn bindgen_test_layout_AllAccessors() {
)
);
}
impl Clone for AllAccessors {
fn clone(&self) -> Self {
*self
}
}
impl AllAccessors {
#[inline]
pub fn get_mBothAccessors(&self) -> &::std::os::raw::c_int {
@@ -160,7 +150,7 @@ impl AllAccessors {
}
/// <div rustbindgen accessor="unsafe"></div>
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct AllUnsafeAccessors {
pub mBothAccessors: ::std::os::raw::c_int,
pub mAlsoBothAccessors: ::std::os::raw::c_int,
@@ -198,11 +188,6 @@ fn bindgen_test_layout_AllUnsafeAccessors() {
)
);
}
impl Clone for AllUnsafeAccessors {
fn clone(&self) -> Self {
*self
}
}
impl AllUnsafeAccessors {
#[inline]
pub unsafe fn get_mBothAccessors(&self) -> &::std::os::raw::c_int {
@@ -223,7 +208,7 @@ impl AllUnsafeAccessors {
}
/// <div rustbindgen accessor></div>
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct ContradictAccessors {
pub mBothAccessors: ::std::os::raw::c_int,
/// <div rustbindgen accessor="false"></div>
@@ -286,11 +271,6 @@ fn bindgen_test_layout_ContradictAccessors() {
)
);
}
impl Clone for ContradictAccessors {
fn clone(&self) -> Self {
*self
}
}
impl ContradictAccessors {
#[inline]
pub fn get_mBothAccessors(&self) -> &::std::os::raw::c_int {
@@ -315,7 +295,7 @@ impl ContradictAccessors {
}
/// <div rustbindgen accessor replaces="Replaced"></div>
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Replaced {
pub mAccessor: ::std::os::raw::c_int,
}
@@ -342,11 +322,6 @@ fn bindgen_test_layout_Replaced() {
)
);
}
impl Clone for Replaced {
fn clone(&self) -> Self {
*self
}
}
impl Replaced {
#[inline]
pub fn get_mAccessor(&self) -> &::std::os::raw::c_int {
@@ -359,7 +334,7 @@ impl Replaced {
}
/// <div rustbindgen accessor></div>
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Wrapper {
pub mReplaced: Replaced,
}
@@ -386,11 +361,6 @@ fn bindgen_test_layout_Wrapper() {
)
);
}
impl Clone for Wrapper {
fn clone(&self) -> Self {
*self
}
}
impl Wrapper {
#[inline]
pub fn get_mReplaced(&self) -> &Replaced {
14 changes: 2 additions & 12 deletions tests/expectations/tests/annotation_hide.rs
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@

/// <div rustbindgen opaque></div>
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct D {
pub _bindgen_opaque_blob: u32,
}
@@ -24,13 +24,8 @@ fn bindgen_test_layout_D() {
concat!("Alignment of ", stringify!(D))
);
}
impl Clone for D {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct NotAnnotated {
pub f: ::std::os::raw::c_int,
}
@@ -57,8 +52,3 @@ fn bindgen_test_layout_NotAnnotated() {
)
);
}
impl Clone for NotAnnotated {
fn clone(&self) -> Self {
*self
}
}
7 changes: 1 addition & 6 deletions tests/expectations/tests/anon_enum.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Debug, Default, Copy, PartialEq)]
#[derive(Debug, Default, Copy, Clone, PartialEq)]
pub struct Test {
pub foo: ::std::os::raw::c_int,
pub bar: f32,
@@ -49,11 +49,6 @@ fn bindgen_test_layout_Test() {
)
);
}
impl Clone for Test {
fn clone(&self) -> Self {
*self
}
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum Baz {
7 changes: 1 addition & 6 deletions tests/expectations/tests/anon_enum_trait.rs
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ pub enum DataType__bindgen_ty_1 {
generic_type = 0,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Foo {
pub _address: u8,
}
@@ -48,8 +48,3 @@ fn bindgen_test_layout_Foo() {
concat!("Alignment of ", stringify!(Foo))
);
}
impl Clone for Foo {
fn clone(&self) -> Self {
*self
}
}
21 changes: 3 additions & 18 deletions tests/expectations/tests/anon_struct_in_union.rs
Original file line number Diff line number Diff line change
@@ -5,18 +5,18 @@


#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct s {
pub u: s__bindgen_ty_1,
}
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub union s__bindgen_ty_1 {
pub field: s__bindgen_ty_1_inner,
_bindgen_union_align: u32,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct s__bindgen_ty_1_inner {
pub b: ::std::os::raw::c_int,
}
@@ -43,11 +43,6 @@ fn bindgen_test_layout_s__bindgen_ty_1_inner() {
)
);
}
impl Clone for s__bindgen_ty_1_inner {
fn clone(&self) -> Self {
*self
}
}
#[test]
fn bindgen_test_layout_s__bindgen_ty_1() {
assert_eq!(
@@ -71,11 +66,6 @@ fn bindgen_test_layout_s__bindgen_ty_1() {
)
);
}
impl Clone for s__bindgen_ty_1 {
fn clone(&self) -> Self {
*self
}
}
impl Default for s__bindgen_ty_1 {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
@@ -99,11 +89,6 @@ fn bindgen_test_layout_s() {
concat!("Alignment of field: ", stringify!(s), "::", stringify!(u))
);
}
impl Clone for s {
fn clone(&self) -> Self {
*self
}
}
impl Default for s {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
7 changes: 1 addition & 6 deletions tests/expectations/tests/base-to-derived.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct false_type {
pub _address: u8,
}
@@ -22,8 +22,3 @@ fn bindgen_test_layout_false_type() {
concat!("Alignment of ", stringify!(false_type))
);
}
impl Clone for false_type {
fn clone(&self) -> Self {
*self
}
}
7 changes: 1 addition & 6 deletions tests/expectations/tests/bitfield-32bit-overflow.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C, packed)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct MuchBitfield {
pub _bitfield_1: [u8; 5usize],
}
@@ -22,11 +22,6 @@ fn bindgen_test_layout_MuchBitfield() {
concat!("Alignment of ", stringify!(MuchBitfield))
);
}
impl Clone for MuchBitfield {
fn clone(&self) -> Self {
*self
}
}
impl MuchBitfield {
#[inline]
pub fn m0(&self) -> ::std::os::raw::c_char {
7 changes: 1 addition & 6 deletions tests/expectations/tests/bitfield-enum-basic.rs
Original file line number Diff line number Diff line change
@@ -102,7 +102,7 @@ impl ::std::ops::BitAndAssign for _bindgen_ty_1 {
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct _bindgen_ty_1(pub ::std::os::raw::c_uint);
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Dummy {
pub _address: u8,
}
@@ -150,8 +150,3 @@ fn bindgen_test_layout_Dummy() {
concat!("Alignment of ", stringify!(Dummy))
);
}
impl Clone for Dummy {
fn clone(&self) -> Self {
*self
}
}
14 changes: 2 additions & 12 deletions tests/expectations/tests/bitfield-large.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct HasBigBitfield {
pub _bitfield_1: [u8; 16usize],
}
@@ -17,13 +17,8 @@ fn bindgen_test_layout_HasBigBitfield() {
concat!("Size of: ", stringify!(HasBigBitfield))
);
}
impl Clone for HasBigBitfield {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct HasTwoBigBitfields {
pub _bitfield_1: [u8; 16usize],
}
@@ -35,8 +30,3 @@ fn bindgen_test_layout_HasTwoBigBitfields() {
concat!("Size of: ", stringify!(HasTwoBigBitfields))
);
}
impl Clone for HasTwoBigBitfields {
fn clone(&self) -> Self {
*self
}
}
7 changes: 1 addition & 6 deletions tests/expectations/tests/bitfield-method-same-name.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C, packed)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Foo {
pub _bitfield_1: u8,
}
@@ -34,11 +34,6 @@ extern "C" {
#[link_name = "\u{1}_ZN3Foo8set_typeEc"]
pub fn Foo_set_type(this: *mut Foo, c: ::std::os::raw::c_char);
}
impl Clone for Foo {
fn clone(&self) -> Self {
*self
}
}
impl Foo {
#[inline]
pub fn type__bindgen_bitfield(&self) -> ::std::os::raw::c_char {
42 changes: 6 additions & 36 deletions tests/expectations/tests/bitfield_align.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct A {
pub x: ::std::os::raw::c_uchar,
pub _bitfield_1: [u8; 2usize],
@@ -35,11 +35,6 @@ fn bindgen_test_layout_A() {
concat!("Alignment of field: ", stringify!(A), "::", stringify!(y))
);
}
impl Clone for A {
fn clone(&self) -> Self {
*self
}
}
impl A {
#[inline]
pub fn b1(&self) -> ::std::os::raw::c_uint {
@@ -427,7 +422,7 @@ impl A {
}
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct B {
pub _bitfield_1: u32,
pub __bindgen_align: [u32; 0usize],
@@ -445,11 +440,6 @@ fn bindgen_test_layout_B() {
concat!("Alignment of ", stringify!(B))
);
}
impl Clone for B {
fn clone(&self) -> Self {
*self
}
}
impl B {
#[inline]
pub fn foo(&self) -> ::std::os::raw::c_uint {
@@ -530,7 +520,7 @@ impl B {
}
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct C {
pub x: ::std::os::raw::c_uchar,
pub _bitfield_1: u8,
@@ -559,11 +549,6 @@ fn bindgen_test_layout_C() {
concat!("Alignment of field: ", stringify!(C), "::", stringify!(baz))
);
}
impl Clone for C {
fn clone(&self) -> Self {
*self
}
}
impl C {
#[inline]
pub fn b1(&self) -> ::std::os::raw::c_uint {
@@ -644,7 +629,7 @@ impl C {
}
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Date1 {
pub _bitfield_1: [u8; 3usize],
pub __bindgen_padding_0: u8,
@@ -663,11 +648,6 @@ fn bindgen_test_layout_Date1() {
concat!("Alignment of ", stringify!(Date1))
);
}
impl Clone for Date1 {
fn clone(&self) -> Self {
*self
}
}
impl Date1 {
#[inline]
pub fn nWeekDay(&self) -> ::std::os::raw::c_ushort {
@@ -827,7 +807,7 @@ impl Date1 {
}
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Date2 {
pub _bitfield_1: [u8; 4usize],
pub __bindgen_align: [u16; 0usize],
@@ -845,11 +825,6 @@ fn bindgen_test_layout_Date2() {
concat!("Alignment of ", stringify!(Date2))
);
}
impl Clone for Date2 {
fn clone(&self) -> Self {
*self
}
}
impl Date2 {
#[inline]
pub fn nWeekDay(&self) -> ::std::os::raw::c_ushort {
@@ -1047,7 +1022,7 @@ impl Date2 {
}
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Date3 {
pub _bitfield_1: [u8; 3usize],
pub byte: ::std::os::raw::c_uchar,
@@ -1076,11 +1051,6 @@ fn bindgen_test_layout_Date3() {
)
);
}
impl Clone for Date3 {
fn clone(&self) -> Self {
*self
}
}
impl Date3 {
#[inline]
pub fn nWeekDay(&self) -> ::std::os::raw::c_ushort {
7 changes: 1 addition & 6 deletions tests/expectations/tests/bitfield_align_2.rs
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ pub enum MyEnum {
FOUR = 3,
}
#[repr(C)]
#[derive(Debug, Copy)]
#[derive(Debug, Copy, Clone)]
pub struct TaggedPtr {
pub _bitfield_1: u64,
pub __bindgen_align: [u64; 0usize],
@@ -31,11 +31,6 @@ fn bindgen_test_layout_TaggedPtr() {
concat!("Alignment of ", stringify!(TaggedPtr))
);
}
impl Clone for TaggedPtr {
fn clone(&self) -> Self {
*self
}
}
impl Default for TaggedPtr {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
7 changes: 1 addition & 6 deletions tests/expectations/tests/bitfield_large_overflow.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct _bindgen_ty_1 {
pub _bindgen_opaque_blob: [u64; 10usize],
}
@@ -22,11 +22,6 @@ fn bindgen_test_layout__bindgen_ty_1() {
concat!("Alignment of ", stringify!(_bindgen_ty_1))
);
}
impl Clone for _bindgen_ty_1 {
fn clone(&self) -> Self {
*self
}
}
extern "C" {
#[link_name = "\u{1}a"]
pub static mut a: _bindgen_ty_1;
7 changes: 1 addition & 6 deletions tests/expectations/tests/bitfield_method_mangling.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct mach_msg_type_descriptor_t {
pub _bitfield_1: u32,
pub __bindgen_align: [u32; 0usize],
@@ -23,11 +23,6 @@ fn bindgen_test_layout_mach_msg_type_descriptor_t() {
concat!("Alignment of ", stringify!(mach_msg_type_descriptor_t))
);
}
impl Clone for mach_msg_type_descriptor_t {
fn clone(&self) -> Self {
*self
}
}
impl mach_msg_type_descriptor_t {
#[inline]
pub fn pad3(&self) -> ::std::os::raw::c_uint {
7 changes: 1 addition & 6 deletions tests/expectations/tests/c-empty-layout.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Foo {}
#[test]
fn bindgen_test_layout_Foo() {
@@ -20,8 +20,3 @@ fn bindgen_test_layout_Foo() {
concat!("Alignment of ", stringify!(Foo))
);
}
impl Clone for Foo {
fn clone(&self) -> Self {
*self
}
}
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Bar {
pub _address: u8,
}
@@ -22,11 +22,6 @@ fn bindgen_test_layout_Bar() {
concat!("Alignment of ", stringify!(Bar))
);
}
impl Clone for Bar {
fn clone(&self) -> Self {
*self
}
}
extern "C" {
#[link_name = "\u{1}_Z3bazPN3foo3BarE"]
pub fn baz(arg1: *mut Bar);
7 changes: 1 addition & 6 deletions tests/expectations/tests/char.rs
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ pub type Char = ::std::os::raw::c_char;
pub type SChar = ::std::os::raw::c_schar;
pub type UChar = ::std::os::raw::c_uchar;
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Test {
pub ch: ::std::os::raw::c_char,
pub u: ::std::os::raw::c_uchar,
@@ -156,8 +156,3 @@ fn bindgen_test_layout_Test() {
)
);
}
impl Clone for Test {
fn clone(&self) -> Self {
*self
}
}
28 changes: 4 additions & 24 deletions tests/expectations/tests/class.rs
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
}
impl<T> ::std::marker::Copy for __IncompleteArrayField<T> {}
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct C {
pub a: ::std::os::raw::c_int,
pub big_array: [::std::os::raw::c_char; 33usize],
@@ -75,11 +75,6 @@ fn bindgen_test_layout_C() {
)
);
}
impl Clone for C {
fn clone(&self) -> Self {
*self
}
}
impl Default for C {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
@@ -334,7 +329,7 @@ impl Default for IncompleteArrayNonCopiable {
}
}
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub union Union {
pub d: f32,
pub i: ::std::os::raw::c_int,
@@ -373,18 +368,13 @@ fn bindgen_test_layout_Union() {
)
);
}
impl Clone for Union {
fn clone(&self) -> Self {
*self
}
}
impl Default for Union {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct WithUnion {
pub data: Union,
}
@@ -411,18 +401,13 @@ fn bindgen_test_layout_WithUnion() {
)
);
}
impl Clone for WithUnion {
fn clone(&self) -> Self {
*self
}
}
impl Default for WithUnion {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialOrd, Ord, PartialEq, Eq)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct RealAbstractionWithTonsOfMethods {
pub _address: u8,
}
@@ -461,11 +446,6 @@ extern "C" {
#[link_name = "\u{1}_ZN32RealAbstractionWithTonsOfMethods3staEv"]
pub fn RealAbstractionWithTonsOfMethods_sta();
}
impl Clone for RealAbstractionWithTonsOfMethods {
fn clone(&self) -> Self {
*self
}
}
impl RealAbstractionWithTonsOfMethods {
#[inline]
pub unsafe fn bar(&self) {
28 changes: 4 additions & 24 deletions tests/expectations/tests/class_nested.rs
Original file line number Diff line number Diff line change
@@ -5,12 +5,12 @@


#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct A {
pub member_a: ::std::os::raw::c_int,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct A_B {
pub member_b: ::std::os::raw::c_int,
}
@@ -37,11 +37,6 @@ fn bindgen_test_layout_A_B() {
)
);
}
impl Clone for A_B {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct A_D<T> {
@@ -76,13 +71,8 @@ fn bindgen_test_layout_A() {
)
);
}
impl Clone for A {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct A_C {
pub baz: ::std::os::raw::c_int,
}
@@ -109,11 +99,6 @@ fn bindgen_test_layout_A_C() {
)
);
}
impl Clone for A_C {
fn clone(&self) -> Self {
*self
}
}
extern "C" {
#[link_name = "\u{1}var"]
pub static mut var: A_B;
@@ -142,7 +127,7 @@ extern "C" {
pub static mut baz: A_D<::std::os::raw::c_int>;
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct D {
pub member: A_B,
}
@@ -169,11 +154,6 @@ fn bindgen_test_layout_D() {
)
);
}
impl Clone for D {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Templated<T> {
21 changes: 3 additions & 18 deletions tests/expectations/tests/class_no_members.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct whatever {
pub _address: u8,
}
@@ -22,13 +22,8 @@ fn bindgen_test_layout_whatever() {
concat!("Alignment of ", stringify!(whatever))
);
}
impl Clone for whatever {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct whatever_child {
pub _address: u8,
}
@@ -45,13 +40,8 @@ fn bindgen_test_layout_whatever_child() {
concat!("Alignment of ", stringify!(whatever_child))
);
}
impl Clone for whatever_child {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct whatever_child_with_member {
pub m_member: ::std::os::raw::c_int,
}
@@ -78,8 +68,3 @@ fn bindgen_test_layout_whatever_child_with_member() {
)
);
}
impl Clone for whatever_child_with_member {
fn clone(&self) -> Self {
*self
}
}
7 changes: 1 addition & 6 deletions tests/expectations/tests/class_static.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct MyClass {
pub _address: u8,
}
@@ -30,11 +30,6 @@ fn bindgen_test_layout_MyClass() {
concat!("Alignment of ", stringify!(MyClass))
);
}
impl Clone for MyClass {
fn clone(&self) -> Self {
*self
}
}
extern "C" {
#[link_name = "\u{1}_ZL26example_check_no_collision"]
pub static mut example_check_no_collision: *const ::std::os::raw::c_int;
7 changes: 1 addition & 6 deletions tests/expectations/tests/class_static_const.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct A {
pub _address: u8,
}
@@ -25,8 +25,3 @@ fn bindgen_test_layout_A() {
concat!("Alignment of ", stringify!(A))
);
}
impl Clone for A {
fn clone(&self) -> Self {
*self
}
}
14 changes: 2 additions & 12 deletions tests/expectations/tests/class_use_as.rs
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@

/// <div rustbindgen="true" replaces="whatever"></div>
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct whatever {
pub replacement: ::std::os::raw::c_int,
}
@@ -34,13 +34,8 @@ fn bindgen_test_layout_whatever() {
)
);
}
impl Clone for whatever {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct container {
pub c: whatever,
}
@@ -67,8 +62,3 @@ fn bindgen_test_layout_container() {
)
);
}
impl Clone for container {
fn clone(&self) -> Self {
*self
}
}
77 changes: 11 additions & 66 deletions tests/expectations/tests/class_with_inner_struct.rs
Original file line number Diff line number Diff line change
@@ -5,14 +5,14 @@


#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct A {
pub c: ::std::os::raw::c_uint,
pub named_union: A__bindgen_ty_1,
pub __bindgen_anon_1: A__bindgen_ty_2,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct A_Segment {
pub begin: ::std::os::raw::c_int,
pub end: ::std::os::raw::c_int,
@@ -50,13 +50,8 @@ fn bindgen_test_layout_A_Segment() {
)
);
}
impl Clone for A_Segment {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub union A__bindgen_ty_1 {
pub f: ::std::os::raw::c_int,
_bindgen_union_align: u32,
@@ -84,18 +79,13 @@ fn bindgen_test_layout_A__bindgen_ty_1() {
)
);
}
impl Clone for A__bindgen_ty_1 {
fn clone(&self) -> Self {
*self
}
}
impl Default for A__bindgen_ty_1 {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub union A__bindgen_ty_2 {
pub d: ::std::os::raw::c_int,
_bindgen_union_align: u32,
@@ -123,11 +113,6 @@ fn bindgen_test_layout_A__bindgen_ty_2() {
)
);
}
impl Clone for A__bindgen_ty_2 {
fn clone(&self) -> Self {
*self
}
}
impl Default for A__bindgen_ty_2 {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
@@ -161,23 +146,18 @@ fn bindgen_test_layout_A() {
)
);
}
impl Clone for A {
fn clone(&self) -> Self {
*self
}
}
impl Default for A {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct B {
pub d: ::std::os::raw::c_uint,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct B_Segment {
pub begin: ::std::os::raw::c_int,
pub end: ::std::os::raw::c_int,
@@ -215,11 +195,6 @@ fn bindgen_test_layout_B_Segment() {
)
);
}
impl Clone for B_Segment {
fn clone(&self) -> Self {
*self
}
}
#[test]
fn bindgen_test_layout_B() {
assert_eq!(
@@ -238,11 +213,6 @@ fn bindgen_test_layout_B() {
concat!("Alignment of field: ", stringify!(B), "::", stringify!(d))
);
}
impl Clone for B {
fn clone(&self) -> Self {
*self
}
}
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum StepSyntax {
@@ -252,20 +222,20 @@ pub enum StepSyntax {
FunctionalWithEndKeyword = 3,
}
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct C {
pub d: ::std::os::raw::c_uint,
pub __bindgen_anon_1: C__bindgen_ty_1,
}
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub union C__bindgen_ty_1 {
pub mFunc: C__bindgen_ty_1__bindgen_ty_1,
pub __bindgen_anon_1: C__bindgen_ty_1__bindgen_ty_2,
_bindgen_union_align: [u32; 4usize],
}
#[repr(C)]
#[derive(Debug, Default, Copy, PartialEq)]
#[derive(Debug, Default, Copy, Clone, PartialEq)]
pub struct C__bindgen_ty_1__bindgen_ty_1 {
pub mX1: f32,
pub mY1: f32,
@@ -325,13 +295,8 @@ fn bindgen_test_layout_C__bindgen_ty_1__bindgen_ty_1() {
)
);
}
impl Clone for C__bindgen_ty_1__bindgen_ty_1 {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct C__bindgen_ty_1__bindgen_ty_2 {
pub mStepSyntax: StepSyntax,
pub mSteps: ::std::os::raw::c_uint,
@@ -369,11 +334,6 @@ fn bindgen_test_layout_C__bindgen_ty_1__bindgen_ty_2() {
)
);
}
impl Clone for C__bindgen_ty_1__bindgen_ty_2 {
fn clone(&self) -> Self {
*self
}
}
impl Default for C__bindgen_ty_1__bindgen_ty_2 {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
@@ -402,18 +362,13 @@ fn bindgen_test_layout_C__bindgen_ty_1() {
)
);
}
impl Clone for C__bindgen_ty_1 {
fn clone(&self) -> Self {
*self
}
}
impl Default for C__bindgen_ty_1 {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct C_Segment {
pub begin: ::std::os::raw::c_int,
pub end: ::std::os::raw::c_int,
@@ -451,11 +406,6 @@ fn bindgen_test_layout_C_Segment() {
)
);
}
impl Clone for C_Segment {
fn clone(&self) -> Self {
*self
}
}
#[test]
fn bindgen_test_layout_C() {
assert_eq!(
@@ -474,11 +424,6 @@ fn bindgen_test_layout_C() {
concat!("Alignment of field: ", stringify!(C), "::", stringify!(d))
);
}
impl Clone for C {
fn clone(&self) -> Self {
*self
}
}
impl Default for C {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
14 changes: 2 additions & 12 deletions tests/expectations/tests/class_with_typedef.rs
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@

pub type AnotherInt = ::std::os::raw::c_int;
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct C {
pub c: C_MyInt,
pub ptr: *mut C_MyInt,
@@ -75,11 +75,6 @@ extern "C" {
#[link_name = "\u{1}_ZN1C13anotherMethodEi"]
pub fn C_anotherMethod(this: *mut C, c: AnotherInt);
}
impl Clone for C {
fn clone(&self) -> Self {
*self
}
}
impl Default for C {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
@@ -104,7 +99,7 @@ impl C {
}
}
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct D {
pub _base: C,
pub ptr: *mut C_MyInt,
@@ -127,11 +122,6 @@ fn bindgen_test_layout_D() {
concat!("Alignment of field: ", stringify!(D), "::", stringify!(ptr))
);
}
impl Clone for D {
fn clone(&self) -> Self {
*self
}
}
impl Default for D {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
35 changes: 5 additions & 30 deletions tests/expectations/tests/comment-indent.rs
Original file line number Diff line number Diff line change
@@ -12,15 +12,15 @@ pub mod root {
///
/// This class is really really interesting, look!
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Foo {
pub _address: u8,
}
/// This nested class is also a multi-line doc comment.
///
/// This class is not so interesting, but worth a bit of docs too!
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Foo_Bar {
pub _address: u8,
}
@@ -37,11 +37,6 @@ pub mod root {
concat!("Alignment of ", stringify!(Foo_Bar))
);
}
impl Clone for Foo_Bar {
fn clone(&self) -> Self {
*self
}
}
#[test]
fn bindgen_test_layout_Foo() {
assert_eq!(
@@ -55,18 +50,13 @@ pub mod root {
concat!("Alignment of ", stringify!(Foo))
);
}
impl Clone for Foo {
fn clone(&self) -> Self {
*self
}
}
pub mod test {
#[allow(unused_imports)]
use self::super::super::root;
/// I'm in a namespace, and thus I may be on a rust module, most of the time.
/// My documentation is pretty extensive, I guess.
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Baz {
/// This member is plain awesome, just amazing.
///
@@ -100,16 +90,11 @@ pub mod root {
)
);
}
impl Clone for Baz {
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
/// comment shouldn't be misaligned.
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct InInlineNS {
pub _address: u8,
}
@@ -126,14 +111,9 @@ pub mod root {
concat!("Alignment of ", stringify!(InInlineNS))
);
}
impl Clone for InInlineNS {
fn clone(&self) -> Self {
*self
}
}

#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Bazz {
pub _address: u8,
}
@@ -150,10 +130,5 @@ pub mod root {
concat!("Alignment of ", stringify!(Bazz))
);
}
impl Clone for Bazz {
fn clone(&self) -> Self {
*self
}
}
}
}
28 changes: 4 additions & 24 deletions tests/expectations/tests/complex.rs
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ pub struct __BindgenComplex<T> {
pub im: T,
}
#[repr(C)]
#[derive(Debug, Default, Copy, PartialEq)]
#[derive(Debug, Default, Copy, Clone, PartialEq)]
pub struct TestDouble {
pub mMember: __BindgenComplex<f64>,
}
@@ -38,13 +38,8 @@ fn bindgen_test_layout_TestDouble() {
)
);
}
impl Clone for TestDouble {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct TestDoublePtr {
pub mMember: *mut __BindgenComplex<f64>,
}
@@ -71,18 +66,13 @@ fn bindgen_test_layout_TestDoublePtr() {
)
);
}
impl Clone for TestDoublePtr {
fn clone(&self) -> Self {
*self
}
}
impl Default for TestDoublePtr {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
#[repr(C)]
#[derive(Debug, Default, Copy, PartialEq)]
#[derive(Debug, Default, Copy, Clone, PartialEq)]
pub struct TestFloat {
pub mMember: __BindgenComplex<f32>,
}
@@ -109,13 +99,8 @@ fn bindgen_test_layout_TestFloat() {
)
);
}
impl Clone for TestFloat {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct TestFloatPtr {
pub mMember: *mut __BindgenComplex<f32>,
}
@@ -142,11 +127,6 @@ fn bindgen_test_layout_TestFloatPtr() {
)
);
}
impl Clone for TestFloatPtr {
fn clone(&self) -> Self {
*self
}
}
impl Default for TestFloatPtr {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
7 changes: 1 addition & 6 deletions tests/expectations/tests/const_enum_unnamed.rs
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ pub enum _bindgen_ty_1 {
FOO_BAZ = 1,
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Foo {
pub _address: u8,
}
@@ -36,8 +36,3 @@ fn bindgen_test_layout_Foo() {
concat!("Alignment of ", stringify!(Foo))
);
}
impl Clone for Foo {
fn clone(&self) -> Self {
*self
}
}
7 changes: 1 addition & 6 deletions tests/expectations/tests/constify-all-enums.rs
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ pub const foo_SHOULD_BE: foo = 1;
pub const foo_A_CONSTANT: foo = 2;
pub type foo = ::std::os::raw::c_uint;
#[repr(C)]
#[derive(Debug, Copy)]
#[derive(Debug, Copy, Clone)]
pub struct bar {
pub this_should_work: foo,
}
@@ -36,11 +36,6 @@ fn bindgen_test_layout_bar() {
)
);
}
impl Clone for bar {
fn clone(&self) -> Self {
*self
}
}
impl Default for bar {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
7 changes: 1 addition & 6 deletions tests/expectations/tests/constify-module-enums-basic.rs
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ pub mod foo {
pub use self::foo::Type as foo_alias1;
pub use self::foo_alias1 as foo_alias2;
#[repr(C)]
#[derive(Debug, Copy)]
#[derive(Debug, Copy, Clone)]
pub struct bar {
pub this_should_work: foo::Type,
}
@@ -40,11 +40,6 @@ fn bindgen_test_layout_bar() {
)
);
}
impl Clone for bar {
fn clone(&self) -> Self {
*self
}
}
impl Default for bar {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
7 changes: 1 addition & 6 deletions tests/expectations/tests/constify-module-enums-namespace.rs
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ pub mod root {
#[allow(unused_imports)]
use self::super::super::super::root;
#[repr(C)]
#[derive(Debug, Copy)]
#[derive(Debug, Copy, Clone)]
pub struct bar {
pub this_should_work: root::ns1::ns2::foo::Type,
}
@@ -52,11 +52,6 @@ pub mod root {
)
);
}
impl Clone for bar {
fn clone(&self) -> Self {
*self
}
}
impl Default for bar {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ pub mod foo {
pub const Type__: Type = 3;
}
#[repr(C)]
#[derive(Debug, Copy)]
#[derive(Debug, Copy, Clone)]
pub struct bar {
pub member: foo::Type,
}
@@ -39,11 +39,6 @@ fn bindgen_test_layout_bar() {
)
);
}
impl Clone for bar {
fn clone(&self) -> Self {
*self
}
}
impl Default for bar {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ pub use self::Foo::Type as Foo_alias1;
pub use self::Foo_alias1 as Foo_alias2;
pub use self::Foo_alias2 as Foo_alias3;
#[repr(C)]
#[derive(Debug, Copy)]
#[derive(Debug, Copy, Clone)]
pub struct Bar {
pub baz1: Foo::Type,
pub baz2: Foo_alias1,
@@ -118,11 +118,6 @@ fn bindgen_test_layout_Bar() {
)
);
}
impl Clone for Bar {
fn clone(&self) -> Self {
*self
}
}
impl Default for Bar {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ pub mod one_Foo {
pub const Variant2: Type = 1;
}
#[repr(C)]
#[derive(Debug, Copy)]
#[derive(Debug, Copy, Clone)]
pub struct Bar {
pub baz1: one_Foo::Type,
pub baz2: *mut one_Foo::Type,
@@ -48,11 +48,6 @@ fn bindgen_test_layout_Bar() {
)
);
}
impl Clone for Bar {
fn clone(&self) -> Self {
*self
}
}
impl Default for Bar {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
21 changes: 3 additions & 18 deletions tests/expectations/tests/constify-module-enums-types.rs
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ pub use self::anon_enum::Type as anon_enum_alias1;
pub use self::anon_enum_alias1 as anon_enum_alias2;
pub use self::anon_enum_alias2 as anon_enum_alias3;
#[repr(C)]
#[derive(Debug, Copy)]
#[derive(Debug, Copy, Clone)]
pub struct bar {
pub member1: foo::Type,
pub member2: foo_alias1,
@@ -163,18 +163,13 @@ fn bindgen_test_layout_bar() {
)
);
}
impl Clone for bar {
fn clone(&self) -> Self {
*self
}
}
impl Default for bar {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
#[repr(C)]
#[derive(Debug, Copy)]
#[derive(Debug, Copy, Clone)]
pub struct Baz {
pub member1: ns2_Foo::Type,
}
@@ -201,11 +196,6 @@ fn bindgen_test_layout_Baz() {
)
);
}
impl Clone for Baz {
fn clone(&self) -> Self {
*self
}
}
impl Default for Baz {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
@@ -217,7 +207,7 @@ pub mod one_Foo {
pub const Variant2: Type = 1;
}
#[repr(C)]
#[derive(Debug, Copy)]
#[derive(Debug, Copy, Clone)]
pub struct Bar {
pub baz: *mut one_Foo::Type,
}
@@ -244,11 +234,6 @@ fn bindgen_test_layout_Bar() {
)
);
}
impl Clone for Bar {
fn clone(&self) -> Self {
*self
}
}
impl Default for Bar {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
7 changes: 1 addition & 6 deletions tests/expectations/tests/constructor-tp.rs
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ pub struct Foo {
pub _address: u8,
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Bar {
pub _address: u8,
}
@@ -31,11 +31,6 @@ extern "C" {
#[link_name = "\u{1}_ZN3BarC1Ev"]
pub fn Bar_Bar(this: *mut Bar);
}
impl Clone for Bar {
fn clone(&self) -> Self {
*self
}
}
impl Bar {
#[inline]
pub unsafe fn new() -> Self {
14 changes: 2 additions & 12 deletions tests/expectations/tests/constructors.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct TestOverload {
pub _address: u8,
}
@@ -30,11 +30,6 @@ 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
}
}
impl TestOverload {
#[inline]
pub unsafe fn new(arg1: ::std::os::raw::c_int) -> Self {
@@ -50,7 +45,7 @@ impl TestOverload {
}
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct TestPublicNoArgs {
pub _address: u8,
}
@@ -71,11 +66,6 @@ extern "C" {
#[link_name = "\u{1}_ZN16TestPublicNoArgsC1Ev"]
pub fn TestPublicNoArgs_TestPublicNoArgs(this: *mut TestPublicNoArgs);
}
impl Clone for TestPublicNoArgs {
fn clone(&self) -> Self {
*self
}
}
impl TestPublicNoArgs {
#[inline]
pub unsafe fn new() -> Self {
7 changes: 1 addition & 6 deletions tests/expectations/tests/convert-cpp-comment-to-rust.rs
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
pub type mbedtls_mpi_uint = ::std::os::raw::c_uint;
/// \brief MPI structure
#[repr(C)]
#[derive(Debug, Copy)]
#[derive(Debug, Copy, Clone)]
pub struct mbedtls_mpi {
/// < integer sign
pub s: ::std::os::raw::c_int,
@@ -59,11 +59,6 @@ fn bindgen_test_layout_mbedtls_mpi() {
)
);
}
impl Clone for mbedtls_mpi {
fn clone(&self) -> Self {
*self
}
}
impl Default for mbedtls_mpi {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
7 changes: 1 addition & 6 deletions tests/expectations/tests/convert-floats.rs
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ pub struct __BindgenComplex<T> {
pub im: T,
}
#[repr(C)]
#[derive(Debug, Copy)]
#[derive(Debug, Copy, Clone)]
pub struct foo {
pub bar: ::std::os::raw::c_float,
pub baz: ::std::os::raw::c_float,
@@ -93,11 +93,6 @@ fn bindgen_test_layout_foo() {
)
);
}
impl Clone for foo {
fn clone(&self) -> Self {
*self
}
}
impl Default for foo {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
7 changes: 1 addition & 6 deletions tests/expectations/tests/cpp-empty-layout.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Foo {
pub _address: u8,
}
@@ -22,8 +22,3 @@ fn bindgen_test_layout_Foo() {
concat!("Alignment of ", stringify!(Foo))
);
}
impl Clone for Foo {
fn clone(&self) -> Self {
*self
}
}
7 changes: 1 addition & 6 deletions tests/expectations/tests/crtp.rs
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ pub struct Base {
pub _address: u8,
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Derived {
pub _address: u8,
}
@@ -27,11 +27,6 @@ fn bindgen_test_layout_Derived() {
concat!("Alignment of ", stringify!(Derived))
);
}
impl Clone for Derived {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
#[derive(Debug, Default)]
pub struct BaseWithDestructor {
7 changes: 1 addition & 6 deletions tests/expectations/tests/derive-bitfield-method-same-name.rs
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
/// and --with-derive-partialeq --impl-partialeq --impl-debug is provided,
/// this struct should manually implement `Debug` and `PartialEq`.
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct Foo {
pub large: [::std::os::raw::c_int; 33usize],
pub _bitfield_1: [u8; 2usize],
@@ -50,11 +50,6 @@ extern "C" {
#[link_name = "\u{1}_ZN3Foo8set_typeEc"]
pub fn Foo_set_type(this: *mut Foo, c: ::std::os::raw::c_char);
}
impl Clone for Foo {
fn clone(&self) -> Self {
*self
}
}
impl Default for Foo {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
41 changes: 41 additions & 0 deletions tests/expectations/tests/derive-clone.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* automatically generated by rust-bindgen */


#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]



/// This struct should derive `Clone`.
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ShouldDeriveClone {
pub large: [::std::os::raw::c_int; 33usize],
}
#[test]
fn bindgen_test_layout_ShouldDeriveClone() {
assert_eq!(
::std::mem::size_of::<ShouldDeriveClone>(),
132usize,
concat!("Size of: ", stringify!(ShouldDeriveClone))
);
assert_eq!(
::std::mem::align_of::<ShouldDeriveClone>(),
4usize,
concat!("Alignment of ", stringify!(ShouldDeriveClone))
);
assert_eq!(
unsafe { &(*(0 as *const ShouldDeriveClone)).large as *const _ as usize },
0usize,
concat!(
"Alignment of field: ",
stringify!(ShouldDeriveClone),
"::",
stringify!(large)
)
);
}
impl Default for ShouldDeriveClone {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
47 changes: 47 additions & 0 deletions tests/expectations/tests/derive-clone_1_0.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* automatically generated by rust-bindgen */


#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]



/// Since builtin `Clone` impls were introduced in Rust 1.21 this struct
/// should impl `Clone` "manually".
#[repr(C)]
#[derive(Copy)]
pub struct ShouldImplClone {
pub large: [::std::os::raw::c_int; 33usize],
}
#[test]
fn bindgen_test_layout_ShouldImplClone() {
assert_eq!(
::std::mem::size_of::<ShouldImplClone>(),
132usize,
concat!("Size of: ", stringify!(ShouldImplClone))
);
assert_eq!(
::std::mem::align_of::<ShouldImplClone>(),
4usize,
concat!("Alignment of ", stringify!(ShouldImplClone))
);
assert_eq!(
unsafe { &(*(0 as *const ShouldImplClone)).large as *const _ as usize },
0usize,
concat!(
"Alignment of field: ",
stringify!(ShouldImplClone),
"::",
stringify!(large)
)
);
}
impl Clone for ShouldImplClone {
fn clone(&self) -> Self {
*self
}
}
impl Default for ShouldImplClone {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
7 changes: 1 addition & 6 deletions tests/expectations/tests/derive-debug-bitfield.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct C {
pub _bitfield_1: u8,
pub large_array: [::std::os::raw::c_int; 50usize],
@@ -33,11 +33,6 @@ fn bindgen_test_layout_C() {
)
);
}
impl Clone for C {
fn clone(&self) -> Self {
*self
}
}
impl Default for C {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
7 changes: 1 addition & 6 deletions tests/expectations/tests/derive-debug-function-pointer.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct Nice {
pub pointer: Nice_Function,
pub large_array: [::std::os::raw::c_int; 34usize],
@@ -44,11 +44,6 @@ fn bindgen_test_layout_Nice() {
)
);
}
impl Clone for Nice {
fn clone(&self) -> Self {
*self
}
}
impl Default for Nice {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
14 changes: 2 additions & 12 deletions tests/expectations/tests/derive-fn-ptr.rs
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ pub type my_fun_t = ::std::option::Option<
),
>;
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct Foo {
pub callback: my_fun_t,
}
@@ -52,11 +52,6 @@ fn bindgen_test_layout_Foo() {
)
);
}
impl Clone for Foo {
fn clone(&self) -> Self {
*self
}
}
impl Default for Foo {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
@@ -79,7 +74,7 @@ pub type my_fun2_t = ::std::option::Option<
),
>;
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Bar {
pub callback: my_fun2_t,
}
@@ -106,11 +101,6 @@ fn bindgen_test_layout_Bar() {
)
);
}
impl Clone for Bar {
fn clone(&self) -> Self {
*self
}
}
impl Default for Bar {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
Original file line number Diff line number Diff line change
@@ -7,12 +7,12 @@

/// A struct containing a struct containing a float that cannot derive Hash/Eq/Ord but can derive PartialEq/PartialOrd
#[repr(C)]
#[derive(Debug, Default, Copy, PartialOrd, PartialEq)]
#[derive(Debug, Default, Copy, Clone, PartialOrd, PartialEq)]
pub struct foo {
pub bar: foo__bindgen_ty_1,
}
#[repr(C)]
#[derive(Debug, Default, Copy, PartialOrd, PartialEq)]
#[derive(Debug, Default, Copy, Clone, PartialOrd, PartialEq)]
pub struct foo__bindgen_ty_1 {
pub a: f32,
pub b: f32,
@@ -50,11 +50,6 @@ fn bindgen_test_layout_foo__bindgen_ty_1() {
)
);
}
impl Clone for foo__bindgen_ty_1 {
fn clone(&self) -> Self {
*self
}
}
#[test]
fn bindgen_test_layout_foo() {
assert_eq!(
@@ -78,8 +73,3 @@ fn bindgen_test_layout_foo() {
)
);
}
impl Clone for foo {
fn clone(&self) -> Self {
*self
}
}
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@

/// A struct containing an array of floats that cannot derive Hash/Eq/Ord but can derive PartialEq/PartialOrd
#[repr(C)]
#[derive(Debug, Default, Copy, PartialOrd, PartialEq)]
#[derive(Debug, Default, Copy, Clone, PartialOrd, PartialEq)]
pub struct foo {
pub bar: [f32; 3usize],
}
@@ -34,8 +34,3 @@ fn bindgen_test_layout_foo() {
)
);
}
impl Clone for foo {
fn clone(&self) -> Self {
*self
}
}
28 changes: 4 additions & 24 deletions tests/expectations/tests/derive-hash-struct-with-pointer.rs
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@

/// Pointers can derive Hash/PartialOrd/Ord/PartialEq/Eq
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialOrd, Ord, PartialEq, Eq)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct ConstPtrMutObj {
pub bar: *const ::std::os::raw::c_int,
}
@@ -34,18 +34,13 @@ fn bindgen_test_layout_ConstPtrMutObj() {
)
);
}
impl Clone for ConstPtrMutObj {
fn clone(&self) -> Self {
*self
}
}
impl Default for ConstPtrMutObj {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialOrd, Ord, PartialEq, Eq)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct MutPtrMutObj {
pub bar: *mut ::std::os::raw::c_int,
}
@@ -72,18 +67,13 @@ fn bindgen_test_layout_MutPtrMutObj() {
)
);
}
impl Clone for MutPtrMutObj {
fn clone(&self) -> Self {
*self
}
}
impl Default for MutPtrMutObj {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialOrd, Ord, PartialEq, Eq)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct MutPtrConstObj {
pub bar: *const ::std::os::raw::c_int,
}
@@ -110,18 +100,13 @@ fn bindgen_test_layout_MutPtrConstObj() {
)
);
}
impl Clone for MutPtrConstObj {
fn clone(&self) -> Self {
*self
}
}
impl Default for MutPtrConstObj {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialOrd, Ord, PartialEq, Eq)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct ConstPtrConstObj {
pub bar: *const ::std::os::raw::c_int,
}
@@ -148,11 +133,6 @@ fn bindgen_test_layout_ConstPtrConstObj() {
)
);
}
impl Clone for ConstPtrConstObj {
fn clone(&self) -> Self {
*self
}
}
impl Default for ConstPtrConstObj {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
14 changes: 2 additions & 12 deletions tests/expectations/tests/derive-hash-template-inst-float.rs
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ impl<T> Default for foo<T> {
}
/// Can derive Hash/PartialOrd/Ord/PartialEq/Eq when instantiated with int
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialOrd, Ord, PartialEq, Eq)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct IntStr {
pub a: foo<::std::os::raw::c_int>,
}
@@ -46,19 +46,14 @@ fn bindgen_test_layout_IntStr() {
)
);
}
impl Clone for IntStr {
fn clone(&self) -> Self {
*self
}
}
impl Default for IntStr {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
/// Cannot derive Hash/Eq/Ord when instantiated with float but can derive PartialEq/PartialOrd
#[repr(C)]
#[derive(Debug, Copy, PartialOrd, PartialEq)]
#[derive(Debug, Copy, Clone, PartialOrd, PartialEq)]
pub struct FloatStr {
pub a: foo<f32>,
}
@@ -85,11 +80,6 @@ fn bindgen_test_layout_FloatStr() {
)
);
}
impl Clone for FloatStr {
fn clone(&self) -> Self {
*self
}
}
impl Default for FloatStr {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
14 changes: 2 additions & 12 deletions tests/expectations/tests/derive-partialeq-anonfield.rs
Original file line number Diff line number Diff line change
@@ -5,12 +5,12 @@


#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct rte_mbuf {
pub __bindgen_anon_1: rte_mbuf__bindgen_ty_1,
}
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub union rte_mbuf__bindgen_ty_1 {
_bindgen_union_align: [u8; 0usize],
}
@@ -27,11 +27,6 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_1() {
concat!("Alignment of ", stringify!(rte_mbuf__bindgen_ty_1))
);
}
impl Clone for rte_mbuf__bindgen_ty_1 {
fn clone(&self) -> Self {
*self
}
}
impl Default for rte_mbuf__bindgen_ty_1 {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
@@ -45,11 +40,6 @@ fn bindgen_test_layout_rte_mbuf() {
concat!("Size of: ", stringify!(rte_mbuf))
);
}
impl Clone for rte_mbuf {
fn clone(&self) -> Self {
*self
}
}
impl Default for rte_mbuf {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
14 changes: 2 additions & 12 deletions tests/expectations/tests/derive-partialeq-base.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct Base {
pub large: [::std::os::raw::c_int; 33usize],
}
@@ -32,11 +32,6 @@ fn bindgen_test_layout_Base() {
)
);
}
impl Clone for Base {
fn clone(&self) -> Self {
*self
}
}
impl Default for Base {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
@@ -48,7 +43,7 @@ impl ::std::cmp::PartialEq for Base {
}
}
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct ShouldDerivePartialEq {
pub _base: Base,
}
@@ -65,11 +60,6 @@ fn bindgen_test_layout_ShouldDerivePartialEq() {
concat!("Alignment of ", stringify!(ShouldDerivePartialEq))
);
}
impl Clone for ShouldDerivePartialEq {
fn clone(&self) -> Self {
*self
}
}
impl Default for ShouldDerivePartialEq {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
7 changes: 1 addition & 6 deletions tests/expectations/tests/derive-partialeq-bitfield.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct C {
pub _bitfield_1: u8,
pub large_array: [::std::os::raw::c_int; 50usize],
@@ -33,11 +33,6 @@ fn bindgen_test_layout_C() {
)
);
}
impl Clone for C {
fn clone(&self) -> Self {
*self
}
}
impl Default for C {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
7 changes: 1 addition & 6 deletions tests/expectations/tests/derive-partialeq-core.rs
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
extern crate core;

#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct C {
pub large_array: [::std::os::raw::c_int; 420usize],
}
@@ -33,11 +33,6 @@ fn bindgen_test_layout_C() {
)
);
}
impl Clone for C {
fn clone(&self) -> Self {
*self
}
}
impl Default for C {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
28 changes: 4 additions & 24 deletions tests/expectations/tests/derive-partialeq-pointer.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Bar {
pub b: *mut a,
}
@@ -27,23 +27,18 @@ fn bindgen_test_layout_Bar() {
concat!("Alignment of field: ", stringify!(Bar), "::", stringify!(b))
);
}
impl Clone for Bar {
fn clone(&self) -> Self {
*self
}
}
impl Default for Bar {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct c {
pub __bindgen_anon_1: c__bindgen_ty_1,
}
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub union c__bindgen_ty_1 {
_bindgen_union_align: u8,
pub _address: u8,
@@ -61,11 +56,6 @@ fn bindgen_test_layout_c__bindgen_ty_1() {
concat!("Alignment of ", stringify!(c__bindgen_ty_1))
);
}
impl Clone for c__bindgen_ty_1 {
fn clone(&self) -> Self {
*self
}
}
impl Default for c__bindgen_ty_1 {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
@@ -84,18 +74,13 @@ fn bindgen_test_layout_c() {
concat!("Alignment of ", stringify!(c))
);
}
impl Clone for c {
fn clone(&self) -> Self {
*self
}
}
impl Default for c {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct a {
pub d: c,
}
@@ -117,11 +102,6 @@ fn bindgen_test_layout_a() {
concat!("Alignment of field: ", stringify!(a), "::", stringify!(d))
);
}
impl Clone for a {
fn clone(&self) -> Self {
*self
}
}
impl Default for a {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
7 changes: 1 addition & 6 deletions tests/expectations/tests/derive-partialeq-union.rs
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@

/// Deriving PartialEq for rust unions is not supported.
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub union ShouldNotDerivePartialEq {
pub a: ::std::os::raw::c_char,
pub b: ::std::os::raw::c_int,
@@ -46,11 +46,6 @@ fn bindgen_test_layout_ShouldNotDerivePartialEq() {
)
);
}
impl Clone for ShouldNotDerivePartialEq {
fn clone(&self) -> Self {
*self
}
}
impl Default for ShouldNotDerivePartialEq {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
21 changes: 3 additions & 18 deletions tests/expectations/tests/doggo-or-null.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)]
pub struct Doggo {
pub x: ::std::os::raw::c_int,
}
@@ -32,13 +32,8 @@ fn bindgen_test_layout_Doggo() {
)
);
}
impl Clone for Doggo {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)]
pub struct Null {
pub _address: u8,
}
@@ -55,19 +50,14 @@ fn bindgen_test_layout_Null() {
concat!("Alignment of ", stringify!(Null))
);
}
impl Clone for Null {
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
/// which variant is in use. Opaque unions still end up as a `union` in the Rust
/// bindings, but they just have one variant. Even so, can't derive. We should
/// probably emit an opaque struct for opaque unions... but until then, we have
/// this test to make sure that opaque unions don't derive and still compile.
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub union DoggoOrNull {
pub _bindgen_opaque_blob: u32,
}
@@ -84,11 +74,6 @@ fn bindgen_test_layout_DoggoOrNull() {
concat!("Alignment of ", stringify!(DoggoOrNull))
);
}
impl Clone for DoggoOrNull {
fn clone(&self) -> Self {
*self
}
}
impl Default for DoggoOrNull {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
14 changes: 2 additions & 12 deletions tests/expectations/tests/duplicated-namespaces-definitions.rs
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ pub mod root {
#[allow(unused_imports)]
use self::super::super::root;
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Bar {
pub foo: ::std::os::raw::c_int,
pub baz: bool,
@@ -50,17 +50,12 @@ pub mod root {
)
);
}
impl Clone for Bar {
fn clone(&self) -> Self {
*self
}
}
}
pub mod bar {
#[allow(unused_imports)]
use self::super::super::root;
#[repr(C)]
#[derive(Debug, Copy)]
#[derive(Debug, Copy, Clone)]
pub struct Foo {
pub ptr: *mut root::foo::Bar,
}
@@ -87,11 +82,6 @@ pub mod root {
)
);
}
impl Clone for Foo {
fn clone(&self) -> Self {
*self
}
}
impl Default for Foo {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
7 changes: 1 addition & 6 deletions tests/expectations/tests/enum_and_vtable_mangling.rs
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ pub enum _bindgen_ty_1 {
#[repr(C)]
pub struct C__bindgen_vtable(::std::os::raw::c_void);
#[repr(C)]
#[derive(Debug, Copy)]
#[derive(Debug, Copy, Clone)]
pub struct C {
pub vtable_: *const C__bindgen_vtable,
pub i: ::std::os::raw::c_int,
@@ -38,11 +38,6 @@ fn bindgen_test_layout_C() {
concat!("Alignment of field: ", stringify!(C), "::", stringify!(i))
);
}
impl Clone for C {
fn clone(&self) -> Self {
*self
}
}
impl Default for C {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
7 changes: 1 addition & 6 deletions tests/expectations/tests/forward-declaration-autoptr.rs
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ impl<T> Default for RefPtr<T> {
}
}
#[repr(C)]
#[derive(Debug, Copy)]
#[derive(Debug, Copy, Clone)]
pub struct Bar {
pub m_member: RefPtr<Foo>,
}
@@ -48,11 +48,6 @@ fn bindgen_test_layout_Bar() {
)
);
}
impl Clone for Bar {
fn clone(&self) -> Self {
*self
}
}
impl Default for Bar {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
14 changes: 2 additions & 12 deletions tests/expectations/tests/forward_declared_complex_types.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Foo_empty {
pub _address: u8,
}
@@ -22,18 +22,13 @@ fn bindgen_test_layout_Foo_empty() {
concat!("Alignment of ", stringify!(Foo_empty))
);
}
impl Clone for Foo_empty {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Foo {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy)]
#[derive(Debug, Copy, Clone)]
pub struct Bar {
pub f: *mut Foo,
}
@@ -55,11 +50,6 @@ fn bindgen_test_layout_Bar() {
concat!("Alignment of field: ", stringify!(Bar), "::", stringify!(f))
);
}
impl Clone for Bar {
fn clone(&self) -> Self {
*self
}
}
impl Default for Bar {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
14 changes: 2 additions & 12 deletions tests/expectations/tests/forward_declared_struct.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct a {
pub b: ::std::os::raw::c_int,
}
@@ -27,13 +27,8 @@ fn bindgen_test_layout_a() {
concat!("Alignment of field: ", stringify!(a), "::", stringify!(b))
);
}
impl Clone for a {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct c {
pub d: ::std::os::raw::c_int,
}
@@ -55,8 +50,3 @@ fn bindgen_test_layout_c() {
concat!("Alignment of field: ", stringify!(c), "::", stringify!(d))
);
}
impl Clone for c {
fn clone(&self) -> Self {
*self
}
}
7 changes: 1 addition & 6 deletions tests/expectations/tests/func_ptr_in_struct.rs
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum baz {}
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Foo {
pub bar: ::std::option::Option<
unsafe extern "C" fn(x: ::std::os::raw::c_int, y: ::std::os::raw::c_int) -> baz,
@@ -36,11 +36,6 @@ fn bindgen_test_layout_Foo() {
)
);
}
impl Clone for Foo {
fn clone(&self) -> Self {
*self
}
}
impl Default for Foo {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
7 changes: 1 addition & 6 deletions tests/expectations/tests/gen-constructors-neg.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Foo {
pub _address: u8,
}
@@ -22,8 +22,3 @@ fn bindgen_test_layout_Foo() {
concat!("Alignment of ", stringify!(Foo))
);
}
impl Clone for Foo {
fn clone(&self) -> Self {
*self
}
}
7 changes: 1 addition & 6 deletions tests/expectations/tests/gen-constructors.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Foo {
pub _address: u8,
}
@@ -26,11 +26,6 @@ extern "C" {
#[link_name = "\u{1}_ZN3FooC1Ei"]
pub fn Foo_Foo(this: *mut Foo, a: ::std::os::raw::c_int);
}
impl Clone for Foo {
fn clone(&self) -> Self {
*self
}
}
impl Foo {
#[inline]
pub unsafe fn new(a: ::std::os::raw::c_int) -> Self {
7 changes: 1 addition & 6 deletions tests/expectations/tests/generate-inline.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Foo {
pub _address: u8,
}
@@ -26,11 +26,6 @@ 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
}
}
impl Foo {
#[inline]
pub unsafe fn bar() -> ::std::os::raw::c_int {
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ impl<T> Default for BaseWithVtable<T> {
}
/// This should not have an explicit vtable.
#[repr(C)]
#[derive(Debug, Copy)]
#[derive(Debug, Copy, Clone)]
pub struct DerivedWithNoVirtualMethods {
pub _base: BaseWithVtable<*mut ::std::os::raw::c_char>,
}
@@ -38,19 +38,14 @@ fn bindgen_test_layout_DerivedWithNoVirtualMethods() {
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)]
#[derive(Debug, Copy, Clone)]
pub struct DerivedWithVirtualMethods {
pub _base: BaseWithVtable<*mut ::std::os::raw::c_char>,
}
@@ -67,11 +62,6 @@ fn bindgen_test_layout_DerivedWithVirtualMethods() {
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() }
@@ -93,7 +83,7 @@ impl<U> Default for BaseWithoutVtable<U> {
pub struct DerivedWithVtable__bindgen_vtable(::std::os::raw::c_void);
/// This should have an explicit vtable.
#[repr(C)]
#[derive(Debug, Copy)]
#[derive(Debug, Copy, Clone)]
pub struct DerivedWithVtable {
pub vtable_: *const DerivedWithVtable__bindgen_vtable,
pub _base: BaseWithoutVtable<*mut ::std::os::raw::c_char>,
@@ -111,19 +101,14 @@ fn bindgen_test_layout_DerivedWithVtable() {
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)]
#[derive(Debug, Copy, Clone)]
pub struct DerivedWithoutVtable {
pub _base: BaseWithoutVtable<*mut ::std::os::raw::c_char>,
}
@@ -140,11 +125,6 @@ fn bindgen_test_layout_DerivedWithoutVtable() {
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() }
14 changes: 2 additions & 12 deletions tests/expectations/tests/inherit_typedef.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Foo {
pub _address: u8,
}
@@ -22,14 +22,9 @@ fn bindgen_test_layout_Foo() {
concat!("Alignment of ", stringify!(Foo))
);
}
impl Clone for Foo {
fn clone(&self) -> Self {
*self
}
}
pub type TypedefedFoo = Foo;
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Bar {
pub _address: u8,
}
@@ -46,8 +41,3 @@ fn bindgen_test_layout_Bar() {
concat!("Alignment of ", stringify!(Bar))
);
}
impl Clone for Bar {
fn clone(&self) -> Self {
*self
}
}
7 changes: 1 addition & 6 deletions tests/expectations/tests/inline_namespace.rs
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ pub mod root {
pub type Ty = ::std::os::raw::c_int;
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Bar {
pub baz: root::foo::Ty,
}
@@ -41,9 +41,4 @@ pub mod root {
)
);
}
impl Clone for Bar {
fn clone(&self) -> Self {
*self
}
}
}
7 changes: 1 addition & 6 deletions tests/expectations/tests/inline_namespace_conservative.rs
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ pub mod root {
pub type Ty = ::std::os::raw::c_longlong;
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Bar {
pub baz: root::foo::bar::Ty,
}
@@ -46,9 +46,4 @@ pub mod root {
)
);
}
impl Clone for Bar {
fn clone(&self) -> Self {
*self
}
}
}
7 changes: 1 addition & 6 deletions tests/expectations/tests/inner_const.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Foo {
pub bar: ::std::os::raw::c_int,
}
@@ -40,8 +40,3 @@ fn bindgen_test_layout_Foo() {
)
);
}
impl Clone for Foo {
fn clone(&self) -> Self {
*self
}
}
7 changes: 1 addition & 6 deletions tests/expectations/tests/inner_template_self.rs
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ impl Default for LinkedList {
}
}
#[repr(C)]
#[derive(Debug, Copy)]
#[derive(Debug, Copy, Clone)]
pub struct InstantiateIt {
pub m_list: LinkedList,
}
@@ -43,11 +43,6 @@ fn bindgen_test_layout_InstantiateIt() {
)
);
}
impl Clone for InstantiateIt {
fn clone(&self) -> Self {
*self
}
}
impl Default for InstantiateIt {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
7 changes: 1 addition & 6 deletions tests/expectations/tests/issue-1034.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@


#[repr(C, packed)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct S2 {
pub _bitfield_1: u16,
}
@@ -22,11 +22,6 @@ fn bindgen_test_layout_S2() {
concat!("Alignment of ", stringify!(S2))
);
}
impl Clone for S2 {
fn clone(&self) -> Self {
*self
}
}
impl S2 {
#[inline]
pub fn new_bitfield_1() -> u16 {
14 changes: 2 additions & 12 deletions tests/expectations/tests/issue-372.rs
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ pub mod root {
#[allow(unused_imports)]
use self::super::root;
#[repr(C)]
#[derive(Debug, Copy)]
#[derive(Debug, Copy, Clone)]
pub struct i {
pub j: *mut root::i,
pub k: *mut root::i,
@@ -43,18 +43,13 @@ pub mod root {
concat!("Alignment of field: ", stringify!(i), "::", stringify!(l))
);
}
impl Clone for i {
fn clone(&self) -> Self {
*self
}
}
impl Default for i {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
#[repr(C)]
#[derive(Debug, Copy)]
#[derive(Debug, Copy, Clone)]
pub struct d {
pub m: root::i,
}
@@ -76,11 +71,6 @@ pub mod root {
concat!("Alignment of field: ", stringify!(d), "::", stringify!(m))
);
}
impl Clone for d {
fn clone(&self) -> Self {
*self
}
}
impl Default for d {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
7 changes: 1 addition & 6 deletions tests/expectations/tests/issue-410.rs
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ pub mod root {
#[allow(unused_imports)]
use self::super::super::root;
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Value {
pub _address: u8,
}
@@ -33,11 +33,6 @@ pub mod root {
#[link_name = "\u{1}_ZN2JS5Value1aE10JSWhyMagic"]
pub fn Value_a(this: *mut root::JS::Value, arg1: root::JSWhyMagic);
}
impl Clone for Value {
fn clone(&self) -> Self {
*self
}
}
impl Value {
#[inline]
pub unsafe fn a(&mut self, arg1: root::JSWhyMagic) {
14 changes: 2 additions & 12 deletions tests/expectations/tests/issue-447.rs
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ pub mod root {
#[allow(unused_imports)]
use self::super::super::super::root;
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct GuardObjectNotifier {
pub _address: u8,
}
@@ -32,15 +32,10 @@ pub mod root {
concat!("Alignment of ", stringify!(GuardObjectNotifier))
);
}
impl Clone for GuardObjectNotifier {
fn clone(&self) -> Self {
*self
}
}
}
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct JSAutoCompartment {
pub _address: u8,
}
@@ -64,11 +59,6 @@ pub mod root {
arg1: root::mozilla::detail::GuardObjectNotifier,
);
}
impl Clone for JSAutoCompartment {
fn clone(&self) -> Self {
*self
}
}
impl JSAutoCompartment {
#[inline]
pub unsafe fn new(arg1: root::mozilla::detail::GuardObjectNotifier) -> Self {
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ impl Default for JS_Base {
}
}
#[repr(C)]
#[derive(Debug, Copy)]
#[derive(Debug, Copy, Clone)]
pub struct JS_AutoIdVector {
pub _base: JS_Base,
}
@@ -41,11 +41,6 @@ fn bindgen_test_layout_JS_AutoIdVector() {
concat!("Alignment of ", stringify!(JS_AutoIdVector))
);
}
impl Clone for JS_AutoIdVector {
fn clone(&self) -> Self {
*self
}
}
impl Default for JS_AutoIdVector {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
7 changes: 1 addition & 6 deletions tests/expectations/tests/issue-573-layout-test-failures.rs
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ pub struct Outer {
pub i: u8,
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct AutoIdVector {
pub ar: Outer,
}
@@ -37,11 +37,6 @@ fn bindgen_test_layout_AutoIdVector() {
)
);
}
impl Clone for AutoIdVector {
fn clone(&self) -> Self {
*self
}
}
#[test]
fn __bindgen_test_layout_Outer_open0_int_close0_instantiation() {
assert_eq!(
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ pub struct a {
pub _address: u8,
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct _bindgen_ty_1 {
pub ar: a,
}
@@ -37,11 +37,6 @@ fn bindgen_test_layout__bindgen_ty_1() {
)
);
}
impl Clone for _bindgen_ty_1 {
fn clone(&self) -> Self {
*self
}
}
extern "C" {
#[link_name = "\u{1}AutoIdVector"]
pub static mut AutoIdVector: _bindgen_ty_1;
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
pub type RefPtr<T> = T;

#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct A {
pub _address: u8,
}
@@ -24,11 +24,6 @@ fn bindgen_test_layout_A() {
concat!("Alignment of ", stringify!(A))
);
}
impl Clone for A {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
pub struct e<c> {
pub d: RefPtr<c>,
28 changes: 4 additions & 24 deletions tests/expectations/tests/issue-639-typedef-anon-field.rs
Original file line number Diff line number Diff line change
@@ -5,12 +5,12 @@


#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Foo {
pub bar: Foo_Bar,
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Foo_Bar {
pub abc: ::std::os::raw::c_int,
}
@@ -37,11 +37,6 @@ fn bindgen_test_layout_Foo_Bar() {
)
);
}
impl Clone for Foo_Bar {
fn clone(&self) -> Self {
*self
}
}
#[test]
fn bindgen_test_layout_Foo() {
assert_eq!(
@@ -65,18 +60,13 @@ fn bindgen_test_layout_Foo() {
)
);
}
impl Clone for Foo {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Baz {
pub _address: u8,
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Baz_Bar {
pub abc: ::std::os::raw::c_int,
}
@@ -103,11 +93,6 @@ fn bindgen_test_layout_Baz_Bar() {
)
);
}
impl Clone for Baz_Bar {
fn clone(&self) -> Self {
*self
}
}
#[test]
fn bindgen_test_layout_Baz() {
assert_eq!(
@@ -121,8 +106,3 @@ fn bindgen_test_layout_Baz() {
concat!("Alignment of ", stringify!(Baz))
);
}
impl Clone for Baz {
fn clone(&self) -> Self {
*self
}
}
21 changes: 3 additions & 18 deletions tests/expectations/tests/issue-643-inner-struct.rs
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ pub struct rte_ring {
pub ring: __IncompleteArrayField<*mut ::std::os::raw::c_void>,
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct rte_ring_prod {
pub watermark: ::std::os::raw::c_uint,
}
@@ -77,13 +77,8 @@ fn bindgen_test_layout_rte_ring_prod() {
)
);
}
impl Clone for rte_ring_prod {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct rte_ring_cons {
pub sc_dequeue: ::std::os::raw::c_uint,
}
@@ -110,11 +105,6 @@ fn bindgen_test_layout_rte_ring_cons() {
)
);
}
impl Clone for rte_ring_cons {
fn clone(&self) -> Self {
*self
}
}
#[test]
fn bindgen_test_layout_rte_ring() {
assert_eq!(
@@ -134,12 +124,7 @@ impl Default for rte_ring {
}
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct rte_memzone {
pub _address: u8,
}
impl Clone for rte_memzone {
fn clone(&self) -> Self {
*self
}
}
14 changes: 2 additions & 12 deletions tests/expectations/tests/issue-648-derive-debug-with-padding.rs
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
/// up with the reight alignment, we're waiting on `#[repr(align="N")]` to land
/// in rustc).
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct NoDebug {
pub c: ::std::os::raw::c_char,
pub __bindgen_padding_0: [u8; 63usize],
@@ -33,11 +33,6 @@ fn bindgen_test_layout_NoDebug() {
)
);
}
impl Clone for NoDebug {
fn clone(&self) -> Self {
*self
}
}
impl Default for NoDebug {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
@@ -53,7 +48,7 @@ impl ::std::cmp::PartialEq for NoDebug {
/// we determine Debug derive-ability before we compute padding, which happens at
/// codegen. (Again, we expect to get the alignment wrong for similar reasons.)
#[repr(C)]
#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct ShouldDeriveDebugButDoesNot {
pub c: [::std::os::raw::c_char; 32usize],
pub d: ::std::os::raw::c_char,
@@ -87,11 +82,6 @@ fn bindgen_test_layout_ShouldDeriveDebugButDoesNot() {
)
);
}
impl Clone for ShouldDeriveDebugButDoesNot {
fn clone(&self) -> Self {
*self
}
}
impl Default for ShouldDeriveDebugButDoesNot {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
7 changes: 1 addition & 6 deletions tests/expectations/tests/issue-674-1.rs
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ pub mod root {
pub type Maybe_ValueType<T> = T;
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct CapturingContentInfo {
pub a: u8,
}
@@ -46,9 +46,4 @@ pub mod root {
)
);
}
impl Clone for CapturingContentInfo {
fn clone(&self) -> Self {
*self
}
}
}
14 changes: 2 additions & 12 deletions tests/expectations/tests/issue-674-2.rs
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ pub mod root {
pub type Rooted_ElementType<T> = T;
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct c {
pub b: u8,
}
@@ -41,13 +41,8 @@ pub mod root {
concat!("Alignment of field: ", stringify!(c), "::", stringify!(b))
);
}
impl Clone for c {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct B {
pub a: root::c,
}
@@ -69,11 +64,6 @@ pub mod root {
concat!("Alignment of field: ", stringify!(B), "::", stringify!(a))
);
}
impl Clone for B {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct StaticRefPtr {
14 changes: 2 additions & 12 deletions tests/expectations/tests/issue-674-3.rs
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ pub mod root {
}
pub type nsRefPtrHashtable_UserDataType<PtrType> = *mut PtrType;
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct a {
pub b: u8,
}
@@ -37,13 +37,8 @@ pub mod root {
concat!("Alignment of field: ", stringify!(a), "::", stringify!(b))
);
}
impl Clone for a {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
#[derive(Debug, Default, Copy, Clone)]
pub struct nsCSSValue {
pub c: root::a,
}
@@ -70,9 +65,4 @@ pub mod root {
)
);
}
impl Clone for nsCSSValue {
fn clone(&self) -> Self {
*self
}
}
}
Loading