diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 4fe2bdf7ba..4dbd2fc692 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -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 } diff --git a/src/features.rs b/src/features.rs index b89185fd9b..0954d87b84 100644 --- a/src/features.rs +++ b/src/features.rs @@ -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 for RustFeatures { @@ -152,6 +156,10 @@ impl From 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); } } diff --git a/tests/expectations/tests/16-byte-alignment.rs b/tests/expectations/tests/16-byte-alignment.rs index 4b764daa80..57bc753da3 100644 --- a/tests/expectations/tests/16-byte-alignment.rs +++ b/tests/expectations/tests/16-byte-alignment.rs @@ -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() } diff --git a/tests/expectations/tests/accessors.rs b/tests/expectations/tests/accessors.rs index 3c8953e624..ac2fb74719 100644 --- a/tests/expectations/tests/accessors.rs +++ b/tests/expectations/tests/accessors.rs @@ -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, ///
@@ -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 { } ///
#[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 { } ///
#[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 { } ///
#[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct ContradictAccessors { pub mBothAccessors: ::std::os::raw::c_int, ///
@@ -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 { } ///
#[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 { } ///
#[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 { diff --git a/tests/expectations/tests/annotation_hide.rs b/tests/expectations/tests/annotation_hide.rs index 0cd443a7db..7f68d115cb 100644 --- a/tests/expectations/tests/annotation_hide.rs +++ b/tests/expectations/tests/annotation_hide.rs @@ -7,7 +7,7 @@ ///
#[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 - } -} diff --git a/tests/expectations/tests/anon_enum.rs b/tests/expectations/tests/anon_enum.rs index b185aae5c7..3dfd5ad34f 100644 --- a/tests/expectations/tests/anon_enum.rs +++ b/tests/expectations/tests/anon_enum.rs @@ -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 { diff --git a/tests/expectations/tests/anon_enum_trait.rs b/tests/expectations/tests/anon_enum_trait.rs index c037a08bc4..9f5a6c56f1 100644 --- a/tests/expectations/tests/anon_enum_trait.rs +++ b/tests/expectations/tests/anon_enum_trait.rs @@ -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 - } -} diff --git a/tests/expectations/tests/anon_struct_in_union.rs b/tests/expectations/tests/anon_struct_in_union.rs index 87329d1af3..4a5054f609 100644 --- a/tests/expectations/tests/anon_struct_in_union.rs +++ b/tests/expectations/tests/anon_struct_in_union.rs @@ -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() } diff --git a/tests/expectations/tests/base-to-derived.rs b/tests/expectations/tests/base-to-derived.rs index 7042226cbf..9df54d982e 100644 --- a/tests/expectations/tests/base-to-derived.rs +++ b/tests/expectations/tests/base-to-derived.rs @@ -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 - } -} diff --git a/tests/expectations/tests/bitfield-32bit-overflow.rs b/tests/expectations/tests/bitfield-32bit-overflow.rs index c90513717a..dfd5384775 100644 --- a/tests/expectations/tests/bitfield-32bit-overflow.rs +++ b/tests/expectations/tests/bitfield-32bit-overflow.rs @@ -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 { diff --git a/tests/expectations/tests/bitfield-enum-basic.rs b/tests/expectations/tests/bitfield-enum-basic.rs index b7c24fb2a1..84362d1232 100644 --- a/tests/expectations/tests/bitfield-enum-basic.rs +++ b/tests/expectations/tests/bitfield-enum-basic.rs @@ -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 - } -} diff --git a/tests/expectations/tests/bitfield-large.rs b/tests/expectations/tests/bitfield-large.rs index facc7338b0..c3209ea5e4 100644 --- a/tests/expectations/tests/bitfield-large.rs +++ b/tests/expectations/tests/bitfield-large.rs @@ -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 - } -} diff --git a/tests/expectations/tests/bitfield-method-same-name.rs b/tests/expectations/tests/bitfield-method-same-name.rs index 9829e4b990..d202893f34 100644 --- a/tests/expectations/tests/bitfield-method-same-name.rs +++ b/tests/expectations/tests/bitfield-method-same-name.rs @@ -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 { diff --git a/tests/expectations/tests/bitfield_align.rs b/tests/expectations/tests/bitfield_align.rs index 559f5a38a2..aa718a741d 100644 --- a/tests/expectations/tests/bitfield_align.rs +++ b/tests/expectations/tests/bitfield_align.rs @@ -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 { diff --git a/tests/expectations/tests/bitfield_align_2.rs b/tests/expectations/tests/bitfield_align_2.rs index d6df314c3b..b10e126f23 100644 --- a/tests/expectations/tests/bitfield_align_2.rs +++ b/tests/expectations/tests/bitfield_align_2.rs @@ -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() } diff --git a/tests/expectations/tests/bitfield_large_overflow.rs b/tests/expectations/tests/bitfield_large_overflow.rs index ee8a4449cd..e5b254cf76 100644 --- a/tests/expectations/tests/bitfield_large_overflow.rs +++ b/tests/expectations/tests/bitfield_large_overflow.rs @@ -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; diff --git a/tests/expectations/tests/bitfield_method_mangling.rs b/tests/expectations/tests/bitfield_method_mangling.rs index a56e57f00c..32e61e67f3 100644 --- a/tests/expectations/tests/bitfield_method_mangling.rs +++ b/tests/expectations/tests/bitfield_method_mangling.rs @@ -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 { diff --git a/tests/expectations/tests/c-empty-layout.rs b/tests/expectations/tests/c-empty-layout.rs index 6542081093..a14022f54f 100644 --- a/tests/expectations/tests/c-empty-layout.rs +++ b/tests/expectations/tests/c-empty-layout.rs @@ -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 - } -} diff --git a/tests/expectations/tests/canonical_path_without_namespacing.rs b/tests/expectations/tests/canonical_path_without_namespacing.rs index cf14bf20de..02955e4414 100644 --- a/tests/expectations/tests/canonical_path_without_namespacing.rs +++ b/tests/expectations/tests/canonical_path_without_namespacing.rs @@ -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); diff --git a/tests/expectations/tests/char.rs b/tests/expectations/tests/char.rs index daad07b417..9f7834ae9b 100644 --- a/tests/expectations/tests/char.rs +++ b/tests/expectations/tests/char.rs @@ -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 - } -} diff --git a/tests/expectations/tests/class.rs b/tests/expectations/tests/class.rs index eb09d75303..784a42d32f 100644 --- a/tests/expectations/tests/class.rs +++ b/tests/expectations/tests/class.rs @@ -42,7 +42,7 @@ impl ::std::clone::Clone for __IncompleteArrayField { } impl ::std::marker::Copy for __IncompleteArrayField {} #[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) { diff --git a/tests/expectations/tests/class_nested.rs b/tests/expectations/tests/class_nested.rs index 32b01f86ff..e9d02479fb 100644 --- a/tests/expectations/tests/class_nested.rs +++ b/tests/expectations/tests/class_nested.rs @@ -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 { @@ -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 { diff --git a/tests/expectations/tests/class_no_members.rs b/tests/expectations/tests/class_no_members.rs index c41f0b0433..01ae947423 100644 --- a/tests/expectations/tests/class_no_members.rs +++ b/tests/expectations/tests/class_no_members.rs @@ -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 - } -} diff --git a/tests/expectations/tests/class_static.rs b/tests/expectations/tests/class_static.rs index e03938a033..c28366c134 100644 --- a/tests/expectations/tests/class_static.rs +++ b/tests/expectations/tests/class_static.rs @@ -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; diff --git a/tests/expectations/tests/class_static_const.rs b/tests/expectations/tests/class_static_const.rs index 945236de81..c0945c4337 100644 --- a/tests/expectations/tests/class_static_const.rs +++ b/tests/expectations/tests/class_static_const.rs @@ -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 - } -} diff --git a/tests/expectations/tests/class_use_as.rs b/tests/expectations/tests/class_use_as.rs index af73ae3b2a..95b2a7fde0 100644 --- a/tests/expectations/tests/class_use_as.rs +++ b/tests/expectations/tests/class_use_as.rs @@ -7,7 +7,7 @@ ///
#[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 - } -} diff --git a/tests/expectations/tests/class_with_inner_struct.rs b/tests/expectations/tests/class_with_inner_struct.rs index f471a75710..4848bc1766 100644 --- a/tests/expectations/tests/class_with_inner_struct.rs +++ b/tests/expectations/tests/class_with_inner_struct.rs @@ -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() } diff --git a/tests/expectations/tests/class_with_typedef.rs b/tests/expectations/tests/class_with_typedef.rs index 90648fcc46..459d580c47 100644 --- a/tests/expectations/tests/class_with_typedef.rs +++ b/tests/expectations/tests/class_with_typedef.rs @@ -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() } diff --git a/tests/expectations/tests/comment-indent.rs b/tests/expectations/tests/comment-indent.rs index 3563da26db..4fe2b5eb50 100644 --- a/tests/expectations/tests/comment-indent.rs +++ b/tests/expectations/tests/comment-indent.rs @@ -12,7 +12,7 @@ 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, } @@ -20,7 +20,7 @@ pub mod root { /// /// 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 - } - } } } diff --git a/tests/expectations/tests/complex.rs b/tests/expectations/tests/complex.rs index 67721d06fc..02c8714c5a 100644 --- a/tests/expectations/tests/complex.rs +++ b/tests/expectations/tests/complex.rs @@ -11,7 +11,7 @@ pub struct __BindgenComplex { pub im: T, } #[repr(C)] -#[derive(Debug, Default, Copy, PartialEq)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] pub struct TestDouble { pub mMember: __BindgenComplex, } @@ -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, } @@ -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, } @@ -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, } @@ -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() } diff --git a/tests/expectations/tests/const_enum_unnamed.rs b/tests/expectations/tests/const_enum_unnamed.rs index 2749321f59..539c8916c6 100644 --- a/tests/expectations/tests/const_enum_unnamed.rs +++ b/tests/expectations/tests/const_enum_unnamed.rs @@ -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 - } -} diff --git a/tests/expectations/tests/constify-all-enums.rs b/tests/expectations/tests/constify-all-enums.rs index af13e079d8..3b37daf301 100644 --- a/tests/expectations/tests/constify-all-enums.rs +++ b/tests/expectations/tests/constify-all-enums.rs @@ -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() } diff --git a/tests/expectations/tests/constify-module-enums-basic.rs b/tests/expectations/tests/constify-module-enums-basic.rs index bfe33c6b56..6c56e2ec52 100644 --- a/tests/expectations/tests/constify-module-enums-basic.rs +++ b/tests/expectations/tests/constify-module-enums-basic.rs @@ -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() } diff --git a/tests/expectations/tests/constify-module-enums-namespace.rs b/tests/expectations/tests/constify-module-enums-namespace.rs index 0a44963f12..b09f837dd7 100644 --- a/tests/expectations/tests/constify-module-enums-namespace.rs +++ b/tests/expectations/tests/constify-module-enums-namespace.rs @@ -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() } diff --git a/tests/expectations/tests/constify-module-enums-shadow-name.rs b/tests/expectations/tests/constify-module-enums-shadow-name.rs index 58debcc682..1f2b4b2ffa 100644 --- a/tests/expectations/tests/constify-module-enums-shadow-name.rs +++ b/tests/expectations/tests/constify-module-enums-shadow-name.rs @@ -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() } diff --git a/tests/expectations/tests/constify-module-enums-simple-alias.rs b/tests/expectations/tests/constify-module-enums-simple-alias.rs index 75c952d7d2..0387ddd06d 100644 --- a/tests/expectations/tests/constify-module-enums-simple-alias.rs +++ b/tests/expectations/tests/constify-module-enums-simple-alias.rs @@ -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() } diff --git a/tests/expectations/tests/constify-module-enums-simple-nonamespace.rs b/tests/expectations/tests/constify-module-enums-simple-nonamespace.rs index 32c173ef64..7fb4606f20 100644 --- a/tests/expectations/tests/constify-module-enums-simple-nonamespace.rs +++ b/tests/expectations/tests/constify-module-enums-simple-nonamespace.rs @@ -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() } diff --git a/tests/expectations/tests/constify-module-enums-types.rs b/tests/expectations/tests/constify-module-enums-types.rs index 2d516fe4d2..cc1f3d4cd6 100644 --- a/tests/expectations/tests/constify-module-enums-types.rs +++ b/tests/expectations/tests/constify-module-enums-types.rs @@ -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() } diff --git a/tests/expectations/tests/constructor-tp.rs b/tests/expectations/tests/constructor-tp.rs index 081abf8955..7336024850 100644 --- a/tests/expectations/tests/constructor-tp.rs +++ b/tests/expectations/tests/constructor-tp.rs @@ -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 { diff --git a/tests/expectations/tests/constructors.rs b/tests/expectations/tests/constructors.rs index 8d0c8c2dcf..b20e3f44d5 100644 --- a/tests/expectations/tests/constructors.rs +++ b/tests/expectations/tests/constructors.rs @@ -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 { diff --git a/tests/expectations/tests/convert-cpp-comment-to-rust.rs b/tests/expectations/tests/convert-cpp-comment-to-rust.rs index 325682d11e..b471386a92 100644 --- a/tests/expectations/tests/convert-cpp-comment-to-rust.rs +++ b/tests/expectations/tests/convert-cpp-comment-to-rust.rs @@ -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() } diff --git a/tests/expectations/tests/convert-floats.rs b/tests/expectations/tests/convert-floats.rs index 8d6f3b9255..87554a2c1a 100644 --- a/tests/expectations/tests/convert-floats.rs +++ b/tests/expectations/tests/convert-floats.rs @@ -11,7 +11,7 @@ pub struct __BindgenComplex { 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() } diff --git a/tests/expectations/tests/cpp-empty-layout.rs b/tests/expectations/tests/cpp-empty-layout.rs index f84a70055b..36cae7222f 100644 --- a/tests/expectations/tests/cpp-empty-layout.rs +++ b/tests/expectations/tests/cpp-empty-layout.rs @@ -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 - } -} diff --git a/tests/expectations/tests/crtp.rs b/tests/expectations/tests/crtp.rs index eb560b3b77..c56cceb2e8 100644 --- a/tests/expectations/tests/crtp.rs +++ b/tests/expectations/tests/crtp.rs @@ -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 { diff --git a/tests/expectations/tests/derive-bitfield-method-same-name.rs b/tests/expectations/tests/derive-bitfield-method-same-name.rs index 143a6ce40a..620508866c 100644 --- a/tests/expectations/tests/derive-bitfield-method-same-name.rs +++ b/tests/expectations/tests/derive-bitfield-method-same-name.rs @@ -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() } diff --git a/tests/expectations/tests/derive-clone.rs b/tests/expectations/tests/derive-clone.rs new file mode 100644 index 0000000000..356d93e336 --- /dev/null +++ b/tests/expectations/tests/derive-clone.rs @@ -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::(), + 132usize, + concat!("Size of: ", stringify!(ShouldDeriveClone)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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() } + } +} diff --git a/tests/expectations/tests/derive-clone_1_0.rs b/tests/expectations/tests/derive-clone_1_0.rs new file mode 100644 index 0000000000..2ead68ee1d --- /dev/null +++ b/tests/expectations/tests/derive-clone_1_0.rs @@ -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::(), + 132usize, + concat!("Size of: ", stringify!(ShouldImplClone)) + ); + assert_eq!( + ::std::mem::align_of::(), + 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() } + } +} diff --git a/tests/expectations/tests/derive-debug-bitfield.rs b/tests/expectations/tests/derive-debug-bitfield.rs index 53fcf716a3..d664a4bafe 100644 --- a/tests/expectations/tests/derive-debug-bitfield.rs +++ b/tests/expectations/tests/derive-debug-bitfield.rs @@ -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() } diff --git a/tests/expectations/tests/derive-debug-function-pointer.rs b/tests/expectations/tests/derive-debug-function-pointer.rs index 5c929909c5..01ffe206ac 100644 --- a/tests/expectations/tests/derive-debug-function-pointer.rs +++ b/tests/expectations/tests/derive-debug-function-pointer.rs @@ -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() } diff --git a/tests/expectations/tests/derive-fn-ptr.rs b/tests/expectations/tests/derive-fn-ptr.rs index 096a67d510..382d906359 100644 --- a/tests/expectations/tests/derive-fn-ptr.rs +++ b/tests/expectations/tests/derive-fn-ptr.rs @@ -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() } diff --git a/tests/expectations/tests/derive-hash-struct-with-anon-struct-float.rs b/tests/expectations/tests/derive-hash-struct-with-anon-struct-float.rs index 6436b69a93..b4f93f73ee 100644 --- a/tests/expectations/tests/derive-hash-struct-with-anon-struct-float.rs +++ b/tests/expectations/tests/derive-hash-struct-with-anon-struct-float.rs @@ -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 - } -} diff --git a/tests/expectations/tests/derive-hash-struct-with-float-array.rs b/tests/expectations/tests/derive-hash-struct-with-float-array.rs index dd9acc6a1f..d736c11426 100644 --- a/tests/expectations/tests/derive-hash-struct-with-float-array.rs +++ b/tests/expectations/tests/derive-hash-struct-with-float-array.rs @@ -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 - } -} diff --git a/tests/expectations/tests/derive-hash-struct-with-pointer.rs b/tests/expectations/tests/derive-hash-struct-with-pointer.rs index b2ae7ab223..7ff50fcf5b 100644 --- a/tests/expectations/tests/derive-hash-struct-with-pointer.rs +++ b/tests/expectations/tests/derive-hash-struct-with-pointer.rs @@ -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() } diff --git a/tests/expectations/tests/derive-hash-template-inst-float.rs b/tests/expectations/tests/derive-hash-template-inst-float.rs index 6473bebaab..4fd935aa71 100644 --- a/tests/expectations/tests/derive-hash-template-inst-float.rs +++ b/tests/expectations/tests/derive-hash-template-inst-float.rs @@ -19,7 +19,7 @@ impl Default for foo { } /// 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,11 +46,6 @@ 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() } @@ -58,7 +53,7 @@ impl Default for IntStr { } /// 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, } @@ -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() } diff --git a/tests/expectations/tests/derive-partialeq-anonfield.rs b/tests/expectations/tests/derive-partialeq-anonfield.rs index 6e3446d52f..73972d70d7 100644 --- a/tests/expectations/tests/derive-partialeq-anonfield.rs +++ b/tests/expectations/tests/derive-partialeq-anonfield.rs @@ -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() } diff --git a/tests/expectations/tests/derive-partialeq-base.rs b/tests/expectations/tests/derive-partialeq-base.rs index 1235665522..cb86ebe68d 100644 --- a/tests/expectations/tests/derive-partialeq-base.rs +++ b/tests/expectations/tests/derive-partialeq-base.rs @@ -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() } diff --git a/tests/expectations/tests/derive-partialeq-bitfield.rs b/tests/expectations/tests/derive-partialeq-bitfield.rs index bc7e750ea5..b9e2db2917 100644 --- a/tests/expectations/tests/derive-partialeq-bitfield.rs +++ b/tests/expectations/tests/derive-partialeq-bitfield.rs @@ -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() } diff --git a/tests/expectations/tests/derive-partialeq-core.rs b/tests/expectations/tests/derive-partialeq-core.rs index 1660f17877..7b925fba7b 100644 --- a/tests/expectations/tests/derive-partialeq-core.rs +++ b/tests/expectations/tests/derive-partialeq-core.rs @@ -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() } diff --git a/tests/expectations/tests/derive-partialeq-pointer.rs b/tests/expectations/tests/derive-partialeq-pointer.rs index b1d3f04c6d..52a4bf7149 100644 --- a/tests/expectations/tests/derive-partialeq-pointer.rs +++ b/tests/expectations/tests/derive-partialeq-pointer.rs @@ -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() } diff --git a/tests/expectations/tests/derive-partialeq-union.rs b/tests/expectations/tests/derive-partialeq-union.rs index 975dee3670..c264206287 100644 --- a/tests/expectations/tests/derive-partialeq-union.rs +++ b/tests/expectations/tests/derive-partialeq-union.rs @@ -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() } diff --git a/tests/expectations/tests/doggo-or-null.rs b/tests/expectations/tests/doggo-or-null.rs index 002e44750f..2da07dedb0 100644 --- a/tests/expectations/tests/doggo-or-null.rs +++ b/tests/expectations/tests/doggo-or-null.rs @@ -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,11 +50,6 @@ 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 @@ -67,7 +57,7 @@ impl Clone for Null { /// 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() } diff --git a/tests/expectations/tests/duplicated-namespaces-definitions.rs b/tests/expectations/tests/duplicated-namespaces-definitions.rs index d907a19cc0..9732849c81 100644 --- a/tests/expectations/tests/duplicated-namespaces-definitions.rs +++ b/tests/expectations/tests/duplicated-namespaces-definitions.rs @@ -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() } diff --git a/tests/expectations/tests/enum_and_vtable_mangling.rs b/tests/expectations/tests/enum_and_vtable_mangling.rs index d6b41610d1..ffdcedd5e6 100644 --- a/tests/expectations/tests/enum_and_vtable_mangling.rs +++ b/tests/expectations/tests/enum_and_vtable_mangling.rs @@ -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() } diff --git a/tests/expectations/tests/forward-declaration-autoptr.rs b/tests/expectations/tests/forward-declaration-autoptr.rs index c5eeb88e8d..8ad45f10e9 100644 --- a/tests/expectations/tests/forward-declaration-autoptr.rs +++ b/tests/expectations/tests/forward-declaration-autoptr.rs @@ -21,7 +21,7 @@ impl Default for RefPtr { } } #[repr(C)] -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Clone)] pub struct Bar { pub m_member: RefPtr, } @@ -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() } diff --git a/tests/expectations/tests/forward_declared_complex_types.rs b/tests/expectations/tests/forward_declared_complex_types.rs index a4eaa17c8f..ceab52d744 100644 --- a/tests/expectations/tests/forward_declared_complex_types.rs +++ b/tests/expectations/tests/forward_declared_complex_types.rs @@ -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() } diff --git a/tests/expectations/tests/forward_declared_struct.rs b/tests/expectations/tests/forward_declared_struct.rs index 4450e65d59..001d6df096 100644 --- a/tests/expectations/tests/forward_declared_struct.rs +++ b/tests/expectations/tests/forward_declared_struct.rs @@ -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 - } -} diff --git a/tests/expectations/tests/func_ptr_in_struct.rs b/tests/expectations/tests/func_ptr_in_struct.rs index 55c75ff14e..5a2c00c73f 100644 --- a/tests/expectations/tests/func_ptr_in_struct.rs +++ b/tests/expectations/tests/func_ptr_in_struct.rs @@ -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() } diff --git a/tests/expectations/tests/gen-constructors-neg.rs b/tests/expectations/tests/gen-constructors-neg.rs index f84a70055b..36cae7222f 100644 --- a/tests/expectations/tests/gen-constructors-neg.rs +++ b/tests/expectations/tests/gen-constructors-neg.rs @@ -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 - } -} diff --git a/tests/expectations/tests/gen-constructors.rs b/tests/expectations/tests/gen-constructors.rs index 07fded03c2..cb2024a16b 100644 --- a/tests/expectations/tests/gen-constructors.rs +++ b/tests/expectations/tests/gen-constructors.rs @@ -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 { diff --git a/tests/expectations/tests/generate-inline.rs b/tests/expectations/tests/generate-inline.rs index f4dafb45ac..48d8f4f898 100644 --- a/tests/expectations/tests/generate-inline.rs +++ b/tests/expectations/tests/generate-inline.rs @@ -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 { diff --git a/tests/expectations/tests/inherit-from-template-instantiation-with-vtable.rs b/tests/expectations/tests/inherit-from-template-instantiation-with-vtable.rs index 365114ba86..cf8b283c4b 100644 --- a/tests/expectations/tests/inherit-from-template-instantiation-with-vtable.rs +++ b/tests/expectations/tests/inherit-from-template-instantiation-with-vtable.rs @@ -21,7 +21,7 @@ impl Default for BaseWithVtable { } /// 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,11 +38,6 @@ 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() } @@ -50,7 +45,7 @@ impl Default for DerivedWithNoVirtualMethods { } /// 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 Default for BaseWithoutVtable { 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,11 +101,6 @@ 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() } @@ -123,7 +108,7 @@ impl Default for DerivedWithVtable { } /// 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() } diff --git a/tests/expectations/tests/inherit_typedef.rs b/tests/expectations/tests/inherit_typedef.rs index 1c07e1df4c..49e842d7c6 100644 --- a/tests/expectations/tests/inherit_typedef.rs +++ b/tests/expectations/tests/inherit_typedef.rs @@ -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 - } -} diff --git a/tests/expectations/tests/inline_namespace.rs b/tests/expectations/tests/inline_namespace.rs index b31bbe04b2..ade3ce3bb6 100644 --- a/tests/expectations/tests/inline_namespace.rs +++ b/tests/expectations/tests/inline_namespace.rs @@ -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 - } - } } diff --git a/tests/expectations/tests/inline_namespace_conservative.rs b/tests/expectations/tests/inline_namespace_conservative.rs index 39e156116e..7895a19f5f 100644 --- a/tests/expectations/tests/inline_namespace_conservative.rs +++ b/tests/expectations/tests/inline_namespace_conservative.rs @@ -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 - } - } } diff --git a/tests/expectations/tests/inner_const.rs b/tests/expectations/tests/inner_const.rs index 0a49c3f2ef..3ea87edb33 100644 --- a/tests/expectations/tests/inner_const.rs +++ b/tests/expectations/tests/inner_const.rs @@ -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 - } -} diff --git a/tests/expectations/tests/inner_template_self.rs b/tests/expectations/tests/inner_template_self.rs index e58226595b..bf39e06514 100644 --- a/tests/expectations/tests/inner_template_self.rs +++ b/tests/expectations/tests/inner_template_self.rs @@ -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() } diff --git a/tests/expectations/tests/issue-1034.rs b/tests/expectations/tests/issue-1034.rs index 9073d928f2..b0c4b52959 100644 --- a/tests/expectations/tests/issue-1034.rs +++ b/tests/expectations/tests/issue-1034.rs @@ -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 { diff --git a/tests/expectations/tests/issue-372.rs b/tests/expectations/tests/issue-372.rs index c2516bdacd..84a33cb9a7 100644 --- a/tests/expectations/tests/issue-372.rs +++ b/tests/expectations/tests/issue-372.rs @@ -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() } diff --git a/tests/expectations/tests/issue-410.rs b/tests/expectations/tests/issue-410.rs index 938cd5979d..928701ef18 100644 --- a/tests/expectations/tests/issue-410.rs +++ b/tests/expectations/tests/issue-410.rs @@ -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) { diff --git a/tests/expectations/tests/issue-447.rs b/tests/expectations/tests/issue-447.rs index 323da81eb3..11a99ad142 100644 --- a/tests/expectations/tests/issue-447.rs +++ b/tests/expectations/tests/issue-447.rs @@ -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 { 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 d3814fba69..b2ddf7138c 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 @@ -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() } diff --git a/tests/expectations/tests/issue-573-layout-test-failures.rs b/tests/expectations/tests/issue-573-layout-test-failures.rs index fba41d1a51..ba2ef976b3 100644 --- a/tests/expectations/tests/issue-573-layout-test-failures.rs +++ b/tests/expectations/tests/issue-573-layout-test-failures.rs @@ -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!( 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 e0554090ab..69a59d5a85 100644 --- a/tests/expectations/tests/issue-574-assertion-failure-in-codegen.rs +++ b/tests/expectations/tests/issue-574-assertion-failure-in-codegen.rs @@ -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; 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 433c0baddd..b6640998d7 100644 --- a/tests/expectations/tests/issue-584-stylo-template-analysis-panic.rs +++ b/tests/expectations/tests/issue-584-stylo-template-analysis-panic.rs @@ -6,7 +6,7 @@ pub type RefPtr = 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 { pub d: RefPtr, diff --git a/tests/expectations/tests/issue-639-typedef-anon-field.rs b/tests/expectations/tests/issue-639-typedef-anon-field.rs index 2a48641f70..91f76531e8 100644 --- a/tests/expectations/tests/issue-639-typedef-anon-field.rs +++ b/tests/expectations/tests/issue-639-typedef-anon-field.rs @@ -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 - } -} diff --git a/tests/expectations/tests/issue-643-inner-struct.rs b/tests/expectations/tests/issue-643-inner-struct.rs index f0375cc8b4..ee5416e09f 100644 --- a/tests/expectations/tests/issue-643-inner-struct.rs +++ b/tests/expectations/tests/issue-643-inner-struct.rs @@ -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 - } -} diff --git a/tests/expectations/tests/issue-648-derive-debug-with-padding.rs b/tests/expectations/tests/issue-648-derive-debug-with-padding.rs index 11c318a213..a3d594e0ee 100644 --- a/tests/expectations/tests/issue-648-derive-debug-with-padding.rs +++ b/tests/expectations/tests/issue-648-derive-debug-with-padding.rs @@ -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() } diff --git a/tests/expectations/tests/issue-674-1.rs b/tests/expectations/tests/issue-674-1.rs index ee71cc554d..fc9ebc11e2 100644 --- a/tests/expectations/tests/issue-674-1.rs +++ b/tests/expectations/tests/issue-674-1.rs @@ -19,7 +19,7 @@ pub mod root { pub type Maybe_ValueType = 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 - } - } } diff --git a/tests/expectations/tests/issue-674-2.rs b/tests/expectations/tests/issue-674-2.rs index 299909788e..07c9cc4a5c 100644 --- a/tests/expectations/tests/issue-674-2.rs +++ b/tests/expectations/tests/issue-674-2.rs @@ -19,7 +19,7 @@ pub mod root { pub type Rooted_ElementType = 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 { diff --git a/tests/expectations/tests/issue-674-3.rs b/tests/expectations/tests/issue-674-3.rs index f98720aaee..1750cc0b24 100644 --- a/tests/expectations/tests/issue-674-3.rs +++ b/tests/expectations/tests/issue-674-3.rs @@ -15,7 +15,7 @@ pub mod root { } pub type nsRefPtrHashtable_UserDataType = *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 - } - } } diff --git a/tests/expectations/tests/issue-691-template-parameter-virtual.rs b/tests/expectations/tests/issue-691-template-parameter-virtual.rs index aef7ed4a72..4878c1fadf 100644 --- a/tests/expectations/tests/issue-691-template-parameter-virtual.rs +++ b/tests/expectations/tests/issue-691-template-parameter-virtual.rs @@ -7,7 +7,7 @@ #[repr(C)] pub struct VirtualMethods__bindgen_vtable(::std::os::raw::c_void); #[repr(C)] -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Clone)] pub struct VirtualMethods { pub vtable_: *const VirtualMethods__bindgen_vtable, } @@ -24,11 +24,6 @@ fn bindgen_test_layout_VirtualMethods() { concat!("Alignment of ", stringify!(VirtualMethods)) ); } -impl Clone for VirtualMethods { - fn clone(&self) -> Self { - *self - } -} impl Default for VirtualMethods { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -40,7 +35,7 @@ pub struct Set { pub bar: ::std::os::raw::c_int, } #[repr(C)] -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Clone)] pub struct ServoElementSnapshotTable { pub _base: Set, } @@ -57,11 +52,6 @@ fn bindgen_test_layout_ServoElementSnapshotTable() { concat!("Alignment of ", stringify!(ServoElementSnapshotTable)) ); } -impl Clone for ServoElementSnapshotTable { - fn clone(&self) -> Self { - *self - } -} impl Default for ServoElementSnapshotTable { fn default() -> Self { unsafe { ::std::mem::zeroed() } diff --git a/tests/expectations/tests/issue-739-pointer-wide-bitfield.rs b/tests/expectations/tests/issue-739-pointer-wide-bitfield.rs index 30d59ab702..96963ba553 100644 --- a/tests/expectations/tests/issue-739-pointer-wide-bitfield.rs +++ b/tests/expectations/tests/issue-739-pointer-wide-bitfield.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Foo { pub _bitfield_1: [u64; 4usize], pub __bindgen_align: [u64; 0usize], @@ -23,8 +23,3 @@ fn bindgen_test_layout_Foo() { concat!("Alignment of ", stringify!(Foo)) ); } -impl Clone for Foo { - 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 896a9a6ca5..3dde6e7302 100644 --- a/tests/expectations/tests/issue-801-opaque-sloppiness.rs +++ b/tests/expectations/tests/issue-801-opaque-sloppiness.rs @@ -10,7 +10,7 @@ pub struct A { _unused: [u8; 0], } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct B { pub _bindgen_opaque_blob: u8, } @@ -27,17 +27,12 @@ fn bindgen_test_layout_B() { concat!("Alignment of ", stringify!(B)) ); } -impl Clone for B { - fn clone(&self) -> Self { - *self - } -} extern "C" { #[link_name = "\u{1}_ZN1B1aE"] pub static mut B_a: A; } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct C { pub b: B, } @@ -59,8 +54,3 @@ fn bindgen_test_layout_C() { concat!("Alignment of field: ", stringify!(C), "::", stringify!(b)) ); } -impl Clone for C { - 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 63ec6982b9..0807873b59 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 @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct Pupper { pub _address: u8, } @@ -22,13 +22,8 @@ fn bindgen_test_layout_Pupper() { concat!("Alignment of ", stringify!(Pupper)) ); } -impl Clone for Pupper { - fn clone(&self) -> Self { - *self - } -} #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct Doggo { pub _address: u8, } @@ -45,13 +40,8 @@ fn bindgen_test_layout_Doggo() { concat!("Alignment of ", stringify!(Doggo)) ); } -impl Clone for Doggo { - fn clone(&self) -> Self { - *self - } -} #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct SuchWow { pub _address: u8, } @@ -68,13 +58,8 @@ fn bindgen_test_layout_SuchWow() { concat!("Alignment of ", stringify!(SuchWow)) ); } -impl Clone for SuchWow { - fn clone(&self) -> Self { - *self - } -} #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct Opaque { pub _bindgen_opaque_blob: u8, } @@ -99,11 +84,6 @@ extern "C" { #[link_name = "\u{1}_ZN6OpaqueC1E6Pupper"] pub fn Opaque_Opaque(this: *mut Opaque, pup: Pupper); } -impl Clone for Opaque { - fn clone(&self) -> Self { - *self - } -} impl Opaque { #[inline] pub unsafe fn eleven_out_of_ten(&mut self) -> SuchWow { @@ -121,7 +101,7 @@ extern "C" { pub static mut Opaque_MAJESTIC_AF: Doggo; } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct Whitelisted { pub some_member: Opaque, } @@ -148,8 +128,3 @@ fn bindgen_test_layout_Whitelisted() { ) ); } -impl Clone for Whitelisted { - 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 f84a70055b..36cae7222f 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 @@ -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 - } -} diff --git a/tests/expectations/tests/issue-834.rs b/tests/expectations/tests/issue-834.rs index 35f0c13fc2..a8014fb92e 100644 --- a/tests/expectations/tests/issue-834.rs +++ b/tests/expectations/tests/issue-834.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct U { pub _address: u8, } @@ -22,8 +22,3 @@ fn bindgen_test_layout_U() { concat!("Alignment of ", stringify!(U)) ); } -impl Clone for U { - 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 6d2b0c5e32..61cbfc3a48 100644 --- a/tests/expectations/tests/issue-888-enum-var-decl-jump.rs +++ b/tests/expectations/tests/issue-888-enum-var-decl-jump.rs @@ -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 Type { pub _address: u8, } @@ -33,11 +33,6 @@ pub mod root { concat!("Alignment of ", stringify!(Type)) ); } - impl Clone for Type { - fn clone(&self) -> Self { - *self - } - } } #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum a {} diff --git a/tests/expectations/tests/issue_311.rs b/tests/expectations/tests/issue_311.rs index a464442e45..b857537895 100644 --- a/tests/expectations/tests/issue_311.rs +++ b/tests/expectations/tests/issue_311.rs @@ -9,12 +9,12 @@ pub mod root { #[allow(unused_imports)] use self::super::root; #[repr(C)] - #[derive(Debug, Default, Copy)] + #[derive(Debug, Default, Copy, Clone)] pub struct jsval_layout { pub __bindgen_anon_1: root::jsval_layout__bindgen_ty_1, } #[repr(C)] - #[derive(Debug, Default, Copy)] + #[derive(Debug, Default, Copy, Clone)] pub struct jsval_layout__bindgen_ty_1 { pub _address: u8, } @@ -31,11 +31,6 @@ pub mod root { concat!("Alignment of ", stringify!(jsval_layout__bindgen_ty_1)) ); } - impl Clone for jsval_layout__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } - } #[test] fn bindgen_test_layout_jsval_layout() { assert_eq!( @@ -49,9 +44,4 @@ pub mod root { concat!("Alignment of ", stringify!(jsval_layout)) ); } - impl Clone for jsval_layout { - fn clone(&self) -> Self { - *self - } - } } diff --git a/tests/expectations/tests/jsval_layout_opaque.rs b/tests/expectations/tests/jsval_layout_opaque.rs index c8e01a0c61..a422ffc052 100644 --- a/tests/expectations/tests/jsval_layout_opaque.rs +++ b/tests/expectations/tests/jsval_layout_opaque.rs @@ -72,7 +72,7 @@ pub enum JSWhyMagic { JS_WHY_MAGIC_COUNT = 18, } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union jsval_layout { pub asBits: u64, pub debugView: jsval_layout__bindgen_ty_1, @@ -84,7 +84,7 @@ pub union jsval_layout { _bindgen_union_align: u64, } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct jsval_layout__bindgen_ty_1 { pub _bitfield_1: u64, pub __bindgen_align: [u64; 0usize], @@ -102,11 +102,6 @@ fn bindgen_test_layout_jsval_layout__bindgen_ty_1() { concat!("Alignment of ", stringify!(jsval_layout__bindgen_ty_1)) ); } -impl Clone for jsval_layout__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} impl Default for jsval_layout__bindgen_ty_1 { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -192,12 +187,12 @@ impl jsval_layout__bindgen_ty_1 { } } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct jsval_layout__bindgen_ty_2 { pub payload: jsval_layout__bindgen_ty_2__bindgen_ty_1, } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union jsval_layout__bindgen_ty_2__bindgen_ty_1 { pub i32: i32, pub u32: u32, @@ -259,11 +254,6 @@ fn bindgen_test_layout_jsval_layout__bindgen_ty_2__bindgen_ty_1() { ) ); } -impl Clone for jsval_layout__bindgen_ty_2__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} impl Default for jsval_layout__bindgen_ty_2__bindgen_ty_1 { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -292,11 +282,6 @@ fn bindgen_test_layout_jsval_layout__bindgen_ty_2() { ) ); } -impl Clone for jsval_layout__bindgen_ty_2 { - fn clone(&self) -> Self { - *self - } -} impl Default for jsval_layout__bindgen_ty_2 { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -385,18 +370,13 @@ fn bindgen_test_layout_jsval_layout() { ) ); } -impl Clone for jsval_layout { - fn clone(&self) -> Self { - *self - } -} impl Default for jsval_layout { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct Value { pub data: jsval_layout, } @@ -423,11 +403,6 @@ fn bindgen_test_layout_Value() { ) ); } -impl Clone for Value { - fn clone(&self) -> Self { - *self - } -} impl Default for Value { fn default() -> Self { unsafe { ::std::mem::zeroed() } diff --git a/tests/expectations/tests/layout_align.rs b/tests/expectations/tests/layout_align.rs index 9d883e3792..859416d76f 100644 --- a/tests/expectations/tests/layout_align.rs +++ b/tests/expectations/tests/layout_align.rs @@ -75,7 +75,7 @@ impl Default for rte_kni_fifo { } } #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct rte_eth_link { /// < ETH_SPEED_NUM_ pub link_speed: u32, @@ -106,11 +106,6 @@ fn bindgen_test_layout_rte_eth_link() { ) ); } -impl Clone for rte_eth_link { - fn clone(&self) -> Self { - *self - } -} impl rte_eth_link { #[inline] pub fn link_duplex(&self) -> u16 { diff --git a/tests/expectations/tests/layout_arp.rs b/tests/expectations/tests/layout_arp.rs index 4f9145b6a8..d49a870b55 100644 --- a/tests/expectations/tests/layout_arp.rs +++ b/tests/expectations/tests/layout_arp.rs @@ -22,7 +22,7 @@ pub const ARP_OP_INVREPLY: ::std::os::raw::c_uint = 9; /// administrator and does not contain OUIs. /// See http://standards.ieee.org/regauth/groupmac/tutorial.html #[repr(C, packed)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct ether_addr { /// < Addr bytes in tx order pub addr_bytes: [u8; 6usize], @@ -50,14 +50,9 @@ fn bindgen_test_layout_ether_addr() { ) ); } -impl Clone for ether_addr { - fn clone(&self) -> Self { - *self - } -} /// ARP header IPv4 payload. #[repr(C, packed)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct arp_ipv4 { /// < sender hardware address pub arp_sha: ether_addr, @@ -121,14 +116,9 @@ fn bindgen_test_layout_arp_ipv4() { ) ); } -impl Clone for arp_ipv4 { - fn clone(&self) -> Self { - *self - } -} /// ARP header. #[repr(C, packed)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct arp_hdr { pub arp_hrd: u16, pub arp_pro: u16, @@ -210,8 +200,3 @@ fn bindgen_test_layout_arp_hdr() { ) ); } -impl Clone for arp_hdr { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/layout_array.rs b/tests/expectations/tests/layout_array.rs index c1a1518799..7dcd507a5b 100644 --- a/tests/expectations/tests/layout_array.rs +++ b/tests/expectations/tests/layout_array.rs @@ -49,7 +49,7 @@ pub type rte_mempool_get_count = ::std::option::Option< >; /// Structure defining mempool operations structure #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct rte_mempool_ops { /// < Name of mempool ops struct. pub name: [::std::os::raw::c_char; 32usize], @@ -133,11 +133,6 @@ fn bindgen_test_layout_rte_mempool_ops() { ) ); } -impl Clone for rte_mempool_ops { - fn clone(&self) -> Self { - *self - } -} impl Default for rte_mempool_ops { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -152,7 +147,7 @@ impl ::std::cmp::PartialEq for rte_mempool_ops { } /// The rte_spinlock_t type. #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_spinlock_t { /// < lock status 0 = unlocked, 1 = locked pub locked: ::std::os::raw::c_int, @@ -180,11 +175,6 @@ fn bindgen_test_layout_rte_spinlock_t() { ) ); } -impl Clone for rte_spinlock_t { - fn clone(&self) -> Self { - *self - } -} /// Structure storing the table of registered ops structs, each of which contain /// the function pointers for the mempool ops functions. /// Each process has its own storage for this ops struct array so that @@ -193,7 +183,7 @@ impl Clone for rte_spinlock_t { /// any function pointers stored directly in the mempool struct would not be. /// This results in us simply having "ops_index" in the mempool struct. #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct rte_mempool_ops_table { /// < Spinlock for add/delete. pub sl: rte_spinlock_t, @@ -241,11 +231,6 @@ fn bindgen_test_layout_rte_mempool_ops_table() { ) ); } -impl Clone for rte_mempool_ops_table { - fn clone(&self) -> Self { - *self - } -} impl Default for rte_mempool_ops_table { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -253,7 +238,7 @@ impl Default for rte_mempool_ops_table { } /// Structure to hold malloc heap #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct malloc_heap { pub lock: rte_spinlock_t, pub free_head: [malloc_heap__bindgen_ty_1; 13usize], @@ -261,7 +246,7 @@ pub struct malloc_heap { pub total_size: usize, } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct malloc_heap__bindgen_ty_1 { pub lh_first: *mut malloc_elem, } @@ -288,11 +273,6 @@ fn bindgen_test_layout_malloc_heap__bindgen_ty_1() { ) ); } -impl Clone for malloc_heap__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} impl Default for malloc_heap__bindgen_ty_1 { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -346,11 +326,6 @@ fn bindgen_test_layout_malloc_heap() { ) ); } -impl Clone for malloc_heap { - fn clone(&self) -> Self { - *self - } -} impl Default for malloc_heap { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -363,12 +338,7 @@ impl ::std::cmp::PartialEq for malloc_heap { } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct malloc_elem { pub _address: u8, } -impl Clone for malloc_elem { - 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 53c6d8c39a..6c8ec85083 100644 --- a/tests/expectations/tests/layout_array_too_long.rs +++ b/tests/expectations/tests/layout_array_too_long.rs @@ -20,7 +20,7 @@ pub enum _bindgen_ty_1 { } /// @internal fragmented mbuf #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct ip_frag { /// < offset into the packet pub ofs: u16, @@ -72,11 +72,6 @@ fn bindgen_test_layout_ip_frag() { ) ); } -impl Clone for ip_frag { - fn clone(&self) -> Self { - *self - } -} impl Default for ip_frag { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -84,7 +79,7 @@ impl Default for ip_frag { } /// @internal to uniquely indetify fragmented datagram. #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct ip_frag_key { /// < src address, first 8 bytes used for IPv4 pub src_dst: [u64; 4usize], @@ -136,15 +131,10 @@ fn bindgen_test_layout_ip_frag_key() { ) ); } -impl Clone for ip_frag_key { - fn clone(&self) -> Self { - *self - } -} /// @internal Fragmented packet to reassemble. /// First two entries in the frags[] array are for the last and first fragments. #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct ip_frag_pkt { /// < LRU list pub lru: ip_frag_pkt__bindgen_ty_1, @@ -163,7 +153,7 @@ pub struct ip_frag_pkt { pub __bindgen_padding_0: [u64; 6usize], } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct ip_frag_pkt__bindgen_ty_1 { pub tqe_next: *mut ip_frag_pkt, pub tqe_prev: *mut *mut ip_frag_pkt, @@ -201,11 +191,6 @@ fn bindgen_test_layout_ip_frag_pkt__bindgen_ty_1() { ) ); } -impl Clone for ip_frag_pkt__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} impl Default for ip_frag_pkt__bindgen_ty_1 { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -289,11 +274,6 @@ fn bindgen_test_layout_ip_frag_pkt() { ) ); } -impl Clone for ip_frag_pkt { - fn clone(&self) -> Self { - *self - } -} impl Default for ip_frag_pkt { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -308,12 +288,7 @@ impl ::std::cmp::PartialEq for ip_frag_pkt { } /// < fragment mbuf #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_mbuf { pub _address: u8, } -impl Clone for rte_mbuf { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/layout_cmdline_token.rs b/tests/expectations/tests/layout_cmdline_token.rs index be8414325e..ca4147f013 100644 --- a/tests/expectations/tests/layout_cmdline_token.rs +++ b/tests/expectations/tests/layout_cmdline_token.rs @@ -8,7 +8,7 @@ /// Stores a pointer to the ops struct, and the offset: the place to /// write the parsed result in the destination structure. #[repr(C)] -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Clone)] pub struct cmdline_token_hdr { pub ops: *mut cmdline_token_ops, pub offset: ::std::os::raw::c_uint, @@ -46,11 +46,6 @@ fn bindgen_test_layout_cmdline_token_hdr() { ) ); } -impl Clone for cmdline_token_hdr { - fn clone(&self) -> Self { - *self - } -} impl Default for cmdline_token_hdr { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -75,7 +70,7 @@ pub type cmdline_parse_token_hdr_t = cmdline_token_hdr; /// get_help() fills the dstbuf with the help for the token. It returns /// -1 on error and 0 on success. #[repr(C)] -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Clone)] pub struct cmdline_token_ops { /// parse(token ptr, buf, res pts, buf len) pub parse: ::std::option::Option< @@ -162,11 +157,6 @@ fn bindgen_test_layout_cmdline_token_ops() { ) ); } -impl Clone for cmdline_token_ops { - fn clone(&self) -> Self { - *self - } -} impl Default for cmdline_token_ops { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -185,7 +175,7 @@ pub enum cmdline_numtype { INT64 = 7, } #[repr(C)] -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Clone)] pub struct cmdline_token_num_data { pub type_: cmdline_numtype, } @@ -212,18 +202,13 @@ fn bindgen_test_layout_cmdline_token_num_data() { ) ); } -impl Clone for cmdline_token_num_data { - fn clone(&self) -> Self { - *self - } -} impl Default for cmdline_token_num_data { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Clone)] pub struct cmdline_token_num { pub hdr: cmdline_token_hdr, pub num_data: cmdline_token_num_data, @@ -261,11 +246,6 @@ fn bindgen_test_layout_cmdline_token_num() { ) ); } -impl Clone for cmdline_token_num { - fn clone(&self) -> Self { - *self - } -} impl Default for cmdline_token_num { fn default() -> Self { unsafe { ::std::mem::zeroed() } diff --git a/tests/expectations/tests/layout_eth_conf.rs b/tests/expectations/tests/layout_eth_conf.rs index 5e17ec2a79..d5f1f1a540 100644 --- a/tests/expectations/tests/layout_eth_conf.rs +++ b/tests/expectations/tests/layout_eth_conf.rs @@ -52,7 +52,7 @@ pub enum rte_eth_rx_mq_mode { } /// A structure used to configure the RX features of an Ethernet port. #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_rxmode { /// The multi-queue packet distribution mode to be used, e.g. RSS. pub mq_mode: rte_eth_rx_mq_mode, @@ -105,11 +105,6 @@ fn bindgen_test_layout_rte_eth_rxmode() { ) ); } -impl Clone for rte_eth_rxmode { - fn clone(&self) -> Self { - *self - } -} impl Default for rte_eth_rxmode { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -475,7 +470,7 @@ pub enum rte_eth_tx_mq_mode { } /// A structure used to configure the TX features of an Ethernet port. #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_txmode { /// < TX multi-queues mode. pub mq_mode: rte_eth_tx_mq_mode, @@ -516,11 +511,6 @@ fn bindgen_test_layout_rte_eth_txmode() { ) ); } -impl Clone for rte_eth_txmode { - fn clone(&self) -> Self { - *self - } -} impl Default for rte_eth_txmode { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -662,7 +652,7 @@ impl rte_eth_txmode { /// types of IPv4/IPv6 packets to which the RSS hashing must be applied. /// Supplying an *rss_hf* equal to zero disables the RSS feature. #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_rss_conf { /// < If not NULL, 40-byte hash key. pub rss_key: *mut u8, @@ -714,11 +704,6 @@ fn bindgen_test_layout_rte_eth_rss_conf() { ) ); } -impl Clone for rte_eth_rss_conf { - fn clone(&self) -> Self { - *self - } -} impl Default for rte_eth_rss_conf { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -752,7 +737,7 @@ pub enum rte_eth_nb_pools { /// A default pool may be used, if desired, to route all traffic which /// does not match the vlan filter rules. #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct rte_eth_vmdq_dcb_conf { /// < With DCB, 16 or 32 pools pub nb_queue_pools: rte_eth_nb_pools, @@ -767,7 +752,7 @@ pub struct rte_eth_vmdq_dcb_conf { pub dcb_tc: [u8; 8usize], } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_dcb_conf__bindgen_ty_1 { /// < The vlan id of the received frame pub vlan_id: u16, @@ -812,11 +797,6 @@ fn bindgen_test_layout_rte_eth_vmdq_dcb_conf__bindgen_ty_1() { ) ); } -impl Clone for rte_eth_vmdq_dcb_conf__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} #[test] fn bindgen_test_layout_rte_eth_vmdq_dcb_conf() { assert_eq!( @@ -890,18 +870,13 @@ fn bindgen_test_layout_rte_eth_vmdq_dcb_conf() { ) ); } -impl Clone for rte_eth_vmdq_dcb_conf { - fn clone(&self) -> Self { - *self - } -} impl Default for rte_eth_vmdq_dcb_conf { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_dcb_rx_conf { /// < Possible DCB TCs, 4 or 8 TCs pub nb_tcs: rte_eth_nb_tcs, @@ -941,18 +916,13 @@ fn bindgen_test_layout_rte_eth_dcb_rx_conf() { ) ); } -impl Clone for rte_eth_dcb_rx_conf { - fn clone(&self) -> Self { - *self - } -} impl Default for rte_eth_dcb_rx_conf { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_dcb_tx_conf { /// < With DCB, 16 or 32 pools. pub nb_queue_pools: rte_eth_nb_pools, @@ -992,18 +962,13 @@ fn bindgen_test_layout_rte_eth_vmdq_dcb_tx_conf() { ) ); } -impl Clone for rte_eth_vmdq_dcb_tx_conf { - fn clone(&self) -> Self { - *self - } -} impl Default for rte_eth_vmdq_dcb_tx_conf { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_dcb_tx_conf { /// < Possible DCB TCs, 4 or 8 TCs. pub nb_tcs: rte_eth_nb_tcs, @@ -1043,18 +1008,13 @@ fn bindgen_test_layout_rte_eth_dcb_tx_conf() { ) ); } -impl Clone for rte_eth_dcb_tx_conf { - fn clone(&self) -> Self { - *self - } -} impl Default for rte_eth_dcb_tx_conf { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_tx_conf { /// < VMDq mode, 64 pools. pub nb_queue_pools: rte_eth_nb_pools, @@ -1082,18 +1042,13 @@ fn bindgen_test_layout_rte_eth_vmdq_tx_conf() { ) ); } -impl Clone for rte_eth_vmdq_tx_conf { - fn clone(&self) -> Self { - *self - } -} impl Default for rte_eth_vmdq_tx_conf { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct rte_eth_vmdq_rx_conf { /// < VMDq only mode, 8 or 64 pools pub nb_queue_pools: rte_eth_nb_pools, @@ -1111,7 +1066,7 @@ pub struct rte_eth_vmdq_rx_conf { pub pool_map: [rte_eth_vmdq_rx_conf__bindgen_ty_1; 64usize], } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_rx_conf__bindgen_ty_1 { /// < The vlan id of the received frame pub vlan_id: u16, @@ -1156,11 +1111,6 @@ fn bindgen_test_layout_rte_eth_vmdq_rx_conf__bindgen_ty_1() { ) ); } -impl Clone for rte_eth_vmdq_rx_conf__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} #[test] fn bindgen_test_layout_rte_eth_vmdq_rx_conf() { assert_eq!( @@ -1244,11 +1194,6 @@ fn bindgen_test_layout_rte_eth_vmdq_rx_conf() { ) ); } -impl Clone for rte_eth_vmdq_rx_conf { - fn clone(&self) -> Self { - *self - } -} impl Default for rte_eth_vmdq_rx_conf { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -1283,7 +1228,7 @@ pub enum rte_fdir_status_mode { } /// A structure used to define the input for IPV4 flow #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_ipv4_flow { /// < IPv4 source address in big endian. pub src_ip: u32, @@ -1359,14 +1304,9 @@ fn bindgen_test_layout_rte_eth_ipv4_flow() { ) ); } -impl Clone for rte_eth_ipv4_flow { - fn clone(&self) -> Self { - *self - } -} /// A structure used to define the input for IPV6 flow #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_ipv6_flow { /// < IPv6 source address in big endian. pub src_ip: [u32; 4usize], @@ -1442,15 +1382,10 @@ fn bindgen_test_layout_rte_eth_ipv6_flow() { ) ); } -impl Clone for rte_eth_ipv6_flow { - fn clone(&self) -> Self { - *self - } -} /// A structure used to configure FDIR masks that are used by the device /// to match the various fields of RX packet headers. #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_fdir_masks { /// < Bit mask for vlan_tci in big endian pub vlan_tci_mask: u16, @@ -1564,11 +1499,6 @@ fn bindgen_test_layout_rte_eth_fdir_masks() { ) ); } -impl Clone for rte_eth_fdir_masks { - fn clone(&self) -> Self { - *self - } -} #[repr(u32)] /// Payload type #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] @@ -1583,7 +1513,7 @@ pub enum rte_eth_payload_type { /// A structure used to select bytes extracted from the protocol layers to /// flexible payload for filter #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_flex_payload_cfg { /// < Payload type pub type_: rte_eth_payload_type, @@ -1622,11 +1552,6 @@ fn bindgen_test_layout_rte_eth_flex_payload_cfg() { ) ); } -impl Clone for rte_eth_flex_payload_cfg { - fn clone(&self) -> Self { - *self - } -} impl Default for rte_eth_flex_payload_cfg { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -1635,7 +1560,7 @@ impl Default for rte_eth_flex_payload_cfg { /// A structure used to define FDIR masks for flexible payload /// for each flow type #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_fdir_flex_mask { pub flow_type: u16, pub mask: [u8; 16usize], @@ -1673,15 +1598,10 @@ fn bindgen_test_layout_rte_eth_fdir_flex_mask() { ) ); } -impl Clone for rte_eth_fdir_flex_mask { - fn clone(&self) -> Self { - *self - } -} /// A structure used to define all flexible payload related setting /// include flex payload and flex mask #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_fdir_flex_conf { /// < The number of following payload cfg pub nb_payloads: u16, @@ -1743,11 +1663,6 @@ fn bindgen_test_layout_rte_eth_fdir_flex_conf() { ) ); } -impl Clone for rte_eth_fdir_flex_conf { - fn clone(&self) -> Self { - *self - } -} impl Default for rte_eth_fdir_flex_conf { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -1758,7 +1673,7 @@ impl Default for rte_eth_fdir_flex_conf { /// /// If mode is RTE_FDIR_DISABLE, the pballoc value is ignored. #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_fdir_conf { /// < Flow Director mode. pub mode: rte_fdir_mode, @@ -1844,11 +1759,6 @@ fn bindgen_test_layout_rte_fdir_conf() { ) ); } -impl Clone for rte_fdir_conf { - fn clone(&self) -> Self { - *self - } -} impl Default for rte_fdir_conf { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -1856,7 +1766,7 @@ impl Default for rte_fdir_conf { } /// A structure used to enable/disable specific device interrupts. #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_intr_conf { /// enable/disable lsc interrupt. 0 (default) - disable, 1 enable pub lsc: u16, @@ -1896,16 +1806,11 @@ fn bindgen_test_layout_rte_intr_conf() { ) ); } -impl Clone for rte_intr_conf { - fn clone(&self) -> Self { - *self - } -} /// A structure used to configure an Ethernet port. /// Depending upon the RX multi-queue mode, extra advanced /// configuration settings may be needed. #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct rte_eth_conf { /// < bitmap of ETH_LINK_SPEED_XXX of speeds to be /// used. ETH_LINK_SPEED_FIXED disables link @@ -1938,7 +1843,7 @@ pub struct rte_eth_conf { pub intr_conf: rte_intr_conf, } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct rte_eth_conf__bindgen_ty_1 { /// < Port RSS configuration pub rss_conf: rte_eth_rss_conf, @@ -1999,18 +1904,13 @@ fn bindgen_test_layout_rte_eth_conf__bindgen_ty_1() { ) ); } -impl Clone for rte_eth_conf__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} impl Default for rte_eth_conf__bindgen_ty_1 { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union rte_eth_conf__bindgen_ty_2 { pub vmdq_dcb_tx_conf: rte_eth_vmdq_dcb_tx_conf, pub dcb_tx_conf: rte_eth_dcb_tx_conf, @@ -2062,11 +1962,6 @@ fn bindgen_test_layout_rte_eth_conf__bindgen_ty_2() { ) ); } -impl Clone for rte_eth_conf__bindgen_ty_2 { - fn clone(&self) -> Self { - *self - } -} impl Default for rte_eth_conf__bindgen_ty_2 { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -2175,11 +2070,6 @@ fn bindgen_test_layout_rte_eth_conf() { ) ); } -impl Clone for rte_eth_conf { - fn clone(&self) -> Self { - *self - } -} impl Default for rte_eth_conf { fn default() -> Self { unsafe { ::std::mem::zeroed() } diff --git a/tests/expectations/tests/layout_kni_mbuf.rs b/tests/expectations/tests/layout_kni_mbuf.rs index facc85b244..e848c52e06 100644 --- a/tests/expectations/tests/layout_kni_mbuf.rs +++ b/tests/expectations/tests/layout_kni_mbuf.rs @@ -7,7 +7,7 @@ pub const RTE_CACHE_LINE_MIN_SIZE: ::std::os::raw::c_uint = 64; pub const RTE_CACHE_LINE_SIZE: ::std::os::raw::c_uint = 64; #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct rte_kni_mbuf { pub buf_addr: *mut ::std::os::raw::c_void, pub buf_physaddr: u64, @@ -179,11 +179,6 @@ fn bindgen_test_layout_rte_kni_mbuf() { ) ); } -impl Clone for rte_kni_mbuf { - fn clone(&self) -> Self { - *self - } -} impl Default for rte_kni_mbuf { 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 7c8ab86580..24034d9270 100644 --- a/tests/expectations/tests/layout_large_align_field.rs +++ b/tests/expectations/tests/layout_large_align_field.rs @@ -57,7 +57,7 @@ pub enum _bindgen_ty_1 { } /// @internal fragmented mbuf #[repr(C)] -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Clone)] pub struct ip_frag { /// < offset into the packet pub ofs: u16, @@ -109,11 +109,6 @@ fn bindgen_test_layout_ip_frag() { ) ); } -impl Clone for ip_frag { - fn clone(&self) -> Self { - *self - } -} impl Default for ip_frag { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -121,7 +116,7 @@ impl Default for ip_frag { } /// @internal to uniquely indetify fragmented datagram. #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct ip_frag_key { /// < src address, first 8 bytes used for IPv4 pub src_dst: [u64; 4usize], @@ -173,15 +168,10 @@ fn bindgen_test_layout_ip_frag_key() { ) ); } -impl Clone for ip_frag_key { - fn clone(&self) -> Self { - *self - } -} /// @internal Fragmented packet to reassemble. /// First two entries in the frags[] array are for the last and first fragments. #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct ip_frag_pkt { /// < LRU list pub lru: ip_frag_pkt__bindgen_ty_1, @@ -200,7 +190,7 @@ pub struct ip_frag_pkt { pub __bindgen_padding_0: [u64; 6usize], } #[repr(C)] -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Clone)] pub struct ip_frag_pkt__bindgen_ty_1 { pub tqe_next: *mut ip_frag_pkt, pub tqe_prev: *mut *mut ip_frag_pkt, @@ -238,11 +228,6 @@ fn bindgen_test_layout_ip_frag_pkt__bindgen_ty_1() { ) ); } -impl Clone for ip_frag_pkt__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} impl Default for ip_frag_pkt__bindgen_ty_1 { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -326,18 +311,13 @@ fn bindgen_test_layout_ip_frag_pkt() { ) ); } -impl Clone for ip_frag_pkt { - fn clone(&self) -> Self { - *self - } -} impl Default for ip_frag_pkt { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Clone)] pub struct ip_pkt_list { pub tqh_first: *mut ip_frag_pkt, pub tqh_last: *mut *mut ip_frag_pkt, @@ -375,11 +355,6 @@ fn bindgen_test_layout_ip_pkt_list() { ) ); } -impl Clone for ip_pkt_list { - fn clone(&self) -> Self { - *self - } -} impl Default for ip_pkt_list { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -387,7 +362,7 @@ impl Default for ip_pkt_list { } /// fragmentation table statistics #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct ip_frag_tbl_stat { /// < total # of find/insert attempts. pub find_num: u64, @@ -471,11 +446,6 @@ fn bindgen_test_layout_ip_frag_tbl_stat() { ) ); } -impl Clone for ip_frag_tbl_stat { - fn clone(&self) -> Self { - *self - } -} impl Default for ip_frag_tbl_stat { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -633,12 +603,7 @@ impl Default for rte_ip_frag_tbl { } /// < fragment mbuf #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct rte_mbuf { pub _address: u8, } -impl Clone for rte_mbuf { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/layout_mbuf.rs b/tests/expectations/tests/layout_mbuf.rs index 90a367c6c7..1db17172dc 100644 --- a/tests/expectations/tests/layout_mbuf.rs +++ b/tests/expectations/tests/layout_mbuf.rs @@ -12,7 +12,7 @@ pub type MARKER8 = [u8; 0usize]; pub type MARKER64 = [u64; 0usize]; /// The atomic counter structure. #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_atomic16_t { /// < An internal counter value. pub cnt: i16, @@ -40,11 +40,6 @@ fn bindgen_test_layout_rte_atomic16_t() { ) ); } -impl Clone for rte_atomic16_t { - fn clone(&self) -> Self { - *self - } -} /// The generic rte_mbuf, containing a packet mbuf. #[repr(C)] pub struct rte_mbuf { @@ -99,7 +94,7 @@ pub struct rte_mbuf { /// or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC /// config option. #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_1 { /// < Atomically accessed refcnt pub refcnt_atomic: rte_atomic16_t, @@ -140,18 +135,13 @@ fn bindgen_test_layout_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() } } } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_2 { /// < L2/L3/L4 and tunnel information. pub packet_type: u32, @@ -159,7 +149,7 @@ pub union rte_mbuf__bindgen_ty_2 { _bindgen_union_align: u32, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_2__bindgen_ty_1 { pub _bitfield_1: [u8; 4usize], pub __bindgen_align: [u32; 0usize], @@ -183,11 +173,6 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_2__bindgen_ty_1() { ) ); } -impl Clone for rte_mbuf__bindgen_ty_2__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 { #[inline] pub fn l2_type(&self) -> u32 { @@ -483,18 +468,13 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_2() { ) ); } -impl Clone for rte_mbuf__bindgen_ty_2 { - fn clone(&self) -> Self { - *self - } -} impl Default for rte_mbuf__bindgen_ty_2 { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_3 { /// < RSS hash result if RSS enabled pub rss: u32, @@ -507,20 +487,20 @@ pub union rte_mbuf__bindgen_ty_3 { _bindgen_union_align: [u32; 2usize], } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_1 { pub __bindgen_anon_1: rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1, pub hi: u32, } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 { pub __bindgen_anon_1: rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1, pub lo: 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_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 { pub hash: u16, pub id: u16, @@ -570,11 +550,6 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindg ) ); } -impl Clone for rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} #[test] fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1() { assert_eq!( @@ -607,11 +582,6 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1() { ) ); } -impl Clone for rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} impl Default for rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -646,18 +616,13 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1() { ) ); } -impl Clone for rte_mbuf__bindgen_ty_3__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} impl Default for rte_mbuf__bindgen_ty_3__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 rte_mbuf__bindgen_ty_3__bindgen_ty_2 { pub lo: u32, pub hi: u32, @@ -701,11 +666,6 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_2() { ) ); } -impl Clone for rte_mbuf__bindgen_ty_3__bindgen_ty_2 { - fn clone(&self) -> Self { - *self - } -} #[test] fn bindgen_test_layout_rte_mbuf__bindgen_ty_3() { assert_eq!( @@ -759,18 +719,13 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_3() { ) ); } -impl Clone for rte_mbuf__bindgen_ty_3 { - fn clone(&self) -> Self { - *self - } -} impl Default for rte_mbuf__bindgen_ty_3 { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_4 { /// < Can be used for external metadata pub userdata: *mut ::std::os::raw::c_void, @@ -811,18 +766,13 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_4() { ) ); } -impl Clone for rte_mbuf__bindgen_ty_4 { - fn clone(&self) -> Self { - *self - } -} impl Default for rte_mbuf__bindgen_ty_4 { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_5 { /// < combined for easy fetch pub tx_offload: u64, @@ -830,7 +780,7 @@ pub union rte_mbuf__bindgen_ty_5 { _bindgen_union_align: u64, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_5__bindgen_ty_1 { pub _bitfield_1: [u16; 4usize], pub __bindgen_align: [u64; 0usize], @@ -854,11 +804,6 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_5__bindgen_ty_1() { ) ); } -impl Clone for rte_mbuf__bindgen_ty_5__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} impl rte_mbuf__bindgen_ty_5__bindgen_ty_1 { #[inline] pub fn l2_len(&self) -> u64 { @@ -1116,11 +1061,6 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_5() { ) ); } -impl Clone for rte_mbuf__bindgen_ty_5 { - fn clone(&self) -> Self { - *self - } -} impl Default for rte_mbuf__bindgen_ty_5 { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -1351,12 +1291,7 @@ impl Default for rte_mbuf { } /// < Pool from which mbuf was allocated. #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_mempool { pub _address: u8, } -impl Clone for rte_mempool { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/libclang-3.8/auto.rs b/tests/expectations/tests/libclang-3.8/auto.rs index b86a5c9e07..8db72d0fa8 100644 --- a/tests/expectations/tests/libclang-3.8/auto.rs +++ b/tests/expectations/tests/libclang-3.8/auto.rs @@ -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 @@ fn bindgen_test_layout_Foo() { concat!("Alignment of ", stringify!(Foo)) ); } -impl Clone for Foo { - fn clone(&self) -> Self { - *self - } -} #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Bar { diff --git a/tests/expectations/tests/libclang-3.8/call-conv-field.rs b/tests/expectations/tests/libclang-3.8/call-conv-field.rs index 6bbffa1ace..b7d5128303 100644 --- a/tests/expectations/tests/libclang-3.8/call-conv-field.rs +++ b/tests/expectations/tests/libclang-3.8/call-conv-field.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct JNINativeInterface_ { pub GetVersion: ::std::option::Option< unsafe extern "stdcall" fn(env: *mut ::std::os::raw::c_void) @@ -46,11 +46,6 @@ fn bindgen_test_layout_JNINativeInterface_() { ) ); } -impl Clone for JNINativeInterface_ { - fn clone(&self) -> Self { - *self - } -} impl Default for JNINativeInterface_ { fn default() -> Self { unsafe { ::std::mem::zeroed() } diff --git a/tests/expectations/tests/libclang-3.8/const_bool.rs b/tests/expectations/tests/libclang-3.8/const_bool.rs index 1f5fcf6398..356368426b 100644 --- a/tests/expectations/tests/libclang-3.8/const_bool.rs +++ b/tests/expectations/tests/libclang-3.8/const_bool.rs @@ -9,7 +9,7 @@ extern "C" { pub static mut k: bool; } #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct A { pub _address: u8, } @@ -30,11 +30,6 @@ fn bindgen_test_layout_A() { concat!("Alignment of ", stringify!(A)) ); } -impl Clone for A { - fn clone(&self) -> Self { - *self - } -} pub type foo = bool; extern "C" { #[link_name = "\u{1}_ZL2k2"] diff --git a/tests/expectations/tests/libclang-3.8/partial-specialization-and-inheritance.rs b/tests/expectations/tests/libclang-3.8/partial-specialization-and-inheritance.rs index 960b5522f9..797d5f45ed 100644 --- a/tests/expectations/tests/libclang-3.8/partial-specialization-and-inheritance.rs +++ b/tests/expectations/tests/libclang-3.8/partial-specialization-and-inheritance.rs @@ -15,7 +15,7 @@ pub struct Derived { pub b: bool, } #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Usage { pub _address: u8, } @@ -40,11 +40,6 @@ extern "C" { #[link_name = "\u{1}_ZN5UsageC1Ev"] pub fn Usage_Usage(this: *mut Usage); } -impl Clone for Usage { - fn clone(&self) -> Self { - *self - } -} impl Usage { #[inline] pub unsafe fn new() -> Self { diff --git a/tests/expectations/tests/libclang-3.8/type_alias_template_specialized.rs b/tests/expectations/tests/libclang-3.8/type_alias_template_specialized.rs index 590f491ab1..7b13bb7c33 100644 --- a/tests/expectations/tests/libclang-3.8/type_alias_template_specialized.rs +++ b/tests/expectations/tests/libclang-3.8/type_alias_template_specialized.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Rooted { pub ptr: ::std::os::raw::c_int, } @@ -32,10 +32,5 @@ fn bindgen_test_layout_Rooted() { ) ); } -impl Clone for Rooted { - fn clone(&self) -> Self { - *self - } -} ///
pub type MaybeWrapped = a; diff --git a/tests/expectations/tests/libclang-3.9/auto.rs b/tests/expectations/tests/libclang-3.9/auto.rs index 50acff2e93..2d7dfa3a85 100644 --- a/tests/expectations/tests/libclang-3.9/auto.rs +++ b/tests/expectations/tests/libclang-3.9/auto.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Foo { pub _address: u8, } @@ -23,11 +23,6 @@ fn bindgen_test_layout_Foo() { concat!("Alignment of ", stringify!(Foo)) ); } -impl Clone for Foo { - fn clone(&self) -> Self { - *self - } -} #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Bar { diff --git a/tests/expectations/tests/libclang-3.9/call-conv-field.rs b/tests/expectations/tests/libclang-3.9/call-conv-field.rs index 8896946e1f..a3c6fe6214 100644 --- a/tests/expectations/tests/libclang-3.9/call-conv-field.rs +++ b/tests/expectations/tests/libclang-3.9/call-conv-field.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct JNINativeInterface_ { pub GetVersion: ::std::option::Option< unsafe extern "stdcall" fn(env: *mut ::std::os::raw::c_void) @@ -46,11 +46,6 @@ fn bindgen_test_layout_JNINativeInterface_() { ) ); } -impl Clone for JNINativeInterface_ { - fn clone(&self) -> Self { - *self - } -} impl Default for JNINativeInterface_ { fn default() -> Self { unsafe { ::std::mem::zeroed() } diff --git a/tests/expectations/tests/libclang-3.9/const_bool.rs b/tests/expectations/tests/libclang-3.9/const_bool.rs index 7106e0ab8d..14f5139400 100644 --- a/tests/expectations/tests/libclang-3.9/const_bool.rs +++ b/tests/expectations/tests/libclang-3.9/const_bool.rs @@ -6,7 +6,7 @@ pub const k: bool = true; #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct A { pub _address: u8, } @@ -24,10 +24,5 @@ fn bindgen_test_layout_A() { concat!("Alignment of ", stringify!(A)) ); } -impl Clone for A { - fn clone(&self) -> Self { - *self - } -} pub type foo = bool; pub const k2: foo = true; diff --git a/tests/expectations/tests/libclang-3.9/partial-specialization-and-inheritance.rs b/tests/expectations/tests/libclang-3.9/partial-specialization-and-inheritance.rs index 416711ad4a..97d2eabe41 100644 --- a/tests/expectations/tests/libclang-3.9/partial-specialization-and-inheritance.rs +++ b/tests/expectations/tests/libclang-3.9/partial-specialization-and-inheritance.rs @@ -15,7 +15,7 @@ pub struct Derived { pub b: bool, } #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Usage { pub _address: u8, } @@ -36,8 +36,3 @@ fn bindgen_test_layout_Usage() { concat!("Alignment of ", stringify!(Usage)) ); } -impl Clone for Usage { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/libclang-3.9/type_alias_template_specialized.rs b/tests/expectations/tests/libclang-3.9/type_alias_template_specialized.rs index 590f491ab1..7b13bb7c33 100644 --- a/tests/expectations/tests/libclang-3.9/type_alias_template_specialized.rs +++ b/tests/expectations/tests/libclang-3.9/type_alias_template_specialized.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Rooted { pub ptr: ::std::os::raw::c_int, } @@ -32,10 +32,5 @@ fn bindgen_test_layout_Rooted() { ) ); } -impl Clone for Rooted { - fn clone(&self) -> Self { - *self - } -} ///
pub type MaybeWrapped
= a; diff --git a/tests/expectations/tests/libclang-4/auto.rs b/tests/expectations/tests/libclang-4/auto.rs index 1575d05129..2d7dfa3a85 100644 --- a/tests/expectations/tests/libclang-4/auto.rs +++ b/tests/expectations/tests/libclang-4/auto.rs @@ -5,20 +5,23 @@ #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Foo { pub _address: u8, } pub const Foo_kFoo: bool = true; #[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 ) )); -} -impl Clone for Foo { - fn clone(&self) -> Self { *self } + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Foo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(Foo)) + ); } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] diff --git a/tests/expectations/tests/libclang-4/call-conv-field.rs b/tests/expectations/tests/libclang-4/call-conv-field.rs index 648560cf56..a3c6fe6214 100644 --- a/tests/expectations/tests/libclang-4/call-conv-field.rs +++ b/tests/expectations/tests/libclang-4/call-conv-field.rs @@ -5,36 +5,51 @@ #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct JNINativeInterface_ { - pub GetVersion: ::std::option::Option ::std::os::raw::c_int>, + pub GetVersion: ::std::option::Option< + unsafe extern "stdcall" fn(env: *mut ::std::os::raw::c_void) + -> ::std::os::raw::c_int, + >, pub __hack: ::std::os::raw::c_ulonglong, } #[test] fn bindgen_test_layout_JNINativeInterface_() { - assert_eq!(::std::mem::size_of::() , 16usize , concat - ! ( "Size of: " , stringify ! ( JNINativeInterface_ ) )); - assert_eq! (::std::mem::align_of::() , 8usize , - concat ! ( - "Alignment of " , stringify ! ( JNINativeInterface_ ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const JNINativeInterface_ ) ) . GetVersion as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( JNINativeInterface_ ) , - "::" , stringify ! ( GetVersion ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const JNINativeInterface_ ) ) . __hack as * - const _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( JNINativeInterface_ ) , - "::" , stringify ! ( __hack ) )); -} -impl Clone for JNINativeInterface_ { - fn clone(&self) -> Self { *self } + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(JNINativeInterface_)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(JNINativeInterface_)) + ); + assert_eq!( + unsafe { &(*(0 as *const JNINativeInterface_)).GetVersion as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(JNINativeInterface_), + "::", + stringify!(GetVersion) + ) + ); + assert_eq!( + unsafe { &(*(0 as *const JNINativeInterface_)).__hack as *const _ as usize }, + 8usize, + concat!( + "Alignment of field: ", + stringify!(JNINativeInterface_), + "::", + stringify!(__hack) + ) + ); } impl Default for JNINativeInterface_ { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } } extern "stdcall" { #[link_name = "\u{1}_bar@0"] diff --git a/tests/expectations/tests/libclang-4/const_bool.rs b/tests/expectations/tests/libclang-4/const_bool.rs index fd0273aa70..14f5139400 100644 --- a/tests/expectations/tests/libclang-4/const_bool.rs +++ b/tests/expectations/tests/libclang-4/const_bool.rs @@ -6,20 +6,23 @@ pub const k: bool = true; #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct A { pub _address: u8, } pub const A_k: bool = false; #[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 ) )); -} -impl Clone for A { - fn clone(&self) -> Self { *self } + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(A)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(A)) + ); } pub type foo = bool; pub const k2: foo = true; diff --git a/tests/expectations/tests/libclang-4/partial-specialization-and-inheritance.rs b/tests/expectations/tests/libclang-4/partial-specialization-and-inheritance.rs index 1cb28c1429..97d2eabe41 100644 --- a/tests/expectations/tests/libclang-4/partial-specialization-and-inheritance.rs +++ b/tests/expectations/tests/libclang-4/partial-specialization-and-inheritance.rs @@ -15,7 +15,7 @@ pub struct Derived { pub b: bool, } #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Usage { pub _address: u8, } @@ -25,11 +25,14 @@ extern "C" { } #[test] fn bindgen_test_layout_Usage() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Usage ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Usage ) )); -} -impl Clone for Usage { - fn clone(&self) -> Self { *self } + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Usage)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(Usage)) + ); } diff --git a/tests/expectations/tests/libclang-4/type_alias_template_specialized.rs b/tests/expectations/tests/libclang-4/type_alias_template_specialized.rs index b8d4fbecf1..e0b8616d89 100644 --- a/tests/expectations/tests/libclang-4/type_alias_template_specialized.rs +++ b/tests/expectations/tests/libclang-4/type_alias_template_specialized.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Clone)] pub struct Rooted { pub ptr: MaybeWrapped<::std::os::raw::c_int>, } @@ -32,11 +32,6 @@ fn bindgen_test_layout_Rooted() { ) ); } -impl Clone for Rooted { - fn clone(&self) -> Self { - *self - } -} impl Default for Rooted { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -51,8 +46,15 @@ fn __bindgen_test_layout_MaybeWrapped_open0_int_close0_instantiation() { 4usize, concat!( "Size of template specialization: ", - stringify ! ( MaybeWrapped < :: std :: os :: raw :: c_int > ) + stringify!(MaybeWrapped<::std::os::raw::c_int>) + ) + ); + assert_eq!( + ::std::mem::align_of::>(), + 4usize, + concat!( + "Alignment of template specialization: ", + stringify!(MaybeWrapped<::std::os::raw::c_int>) ) ); - assert_eq ! ( :: std :: mem :: align_of :: < MaybeWrapped < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( MaybeWrapped < :: std :: os :: raw :: c_int > ) ) ); } diff --git a/tests/expectations/tests/mangling-linux32.rs b/tests/expectations/tests/mangling-linux32.rs index e237eeef19..7fe8f33a7f 100644 --- a/tests/expectations/tests/mangling-linux32.rs +++ b/tests/expectations/tests/mangling-linux32.rs @@ -8,7 +8,7 @@ extern "C" { pub fn foo(); } #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Foo { pub _address: u8, } @@ -29,8 +29,3 @@ fn bindgen_test_layout_Foo() { concat!("Alignment of ", stringify!(Foo)) ); } -impl Clone for Foo { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/mangling-linux64.rs b/tests/expectations/tests/mangling-linux64.rs index e237eeef19..7fe8f33a7f 100644 --- a/tests/expectations/tests/mangling-linux64.rs +++ b/tests/expectations/tests/mangling-linux64.rs @@ -8,7 +8,7 @@ extern "C" { pub fn foo(); } #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Foo { pub _address: u8, } @@ -29,8 +29,3 @@ fn bindgen_test_layout_Foo() { concat!("Alignment of ", stringify!(Foo)) ); } -impl Clone for Foo { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/mangling-macos.rs b/tests/expectations/tests/mangling-macos.rs index 39a020ad76..7835dd928c 100644 --- a/tests/expectations/tests/mangling-macos.rs +++ b/tests/expectations/tests/mangling-macos.rs @@ -9,7 +9,7 @@ extern "C" { pub fn foo(); } #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Foo { pub _address: u8, } @@ -30,8 +30,3 @@ fn bindgen_test_layout_Foo() { concat!("Alignment of ", stringify!(Foo)) ); } -impl Clone for Foo { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/mangling-win32.rs b/tests/expectations/tests/mangling-win32.rs index e21228a1e6..2d2d7fcdbd 100644 --- a/tests/expectations/tests/mangling-win32.rs +++ b/tests/expectations/tests/mangling-win32.rs @@ -9,7 +9,7 @@ extern "C" { pub fn foo(); } #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Foo { pub _address: u8, } @@ -30,8 +30,3 @@ fn bindgen_test_layout_Foo() { concat!("Alignment of ", stringify!(Foo)) ); } -impl Clone for Foo { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/mangling-win64.rs b/tests/expectations/tests/mangling-win64.rs index 747ccbf58f..0d9c49faf7 100644 --- a/tests/expectations/tests/mangling-win64.rs +++ b/tests/expectations/tests/mangling-win64.rs @@ -8,7 +8,7 @@ extern "C" { pub fn foo(); } #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Foo { pub _address: u8, } @@ -29,8 +29,3 @@ fn bindgen_test_layout_Foo() { concat!("Alignment of ", stringify!(Foo)) ); } -impl Clone for Foo { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/method-mangling.rs b/tests/expectations/tests/method-mangling.rs index eada760b5b..f2eb6f9802 100644 --- a/tests/expectations/tests/method-mangling.rs +++ b/tests/expectations/tests/method-mangling.rs @@ -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}_ZN3Foo4typeEv"] pub fn Foo_type(this: *mut Foo) -> ::std::os::raw::c_int; } -impl Clone for Foo { - fn clone(&self) -> Self { - *self - } -} impl Foo { #[inline] pub unsafe fn type_(&mut self) -> ::std::os::raw::c_int { diff --git a/tests/expectations/tests/module-whitelisted.rs b/tests/expectations/tests/module-whitelisted.rs index 0e1d5641e4..3f2d304e82 100644 --- a/tests/expectations/tests/module-whitelisted.rs +++ b/tests/expectations/tests/module-whitelisted.rs @@ -9,7 +9,7 @@ pub mod root { #[allow(unused_imports)] use self::super::root; #[repr(C)] - #[derive(Debug, Default, Copy)] + #[derive(Debug, Default, Copy, Clone)] pub struct Test { pub _address: u8, } @@ -26,9 +26,4 @@ pub mod root { concat!("Alignment of ", stringify!(Test)) ); } - impl Clone for Test { - fn clone(&self) -> Self { - *self - } - } } diff --git a/tests/expectations/tests/msvc-no-usr.rs b/tests/expectations/tests/msvc-no-usr.rs index 848c656f6a..dfa378248e 100644 --- a/tests/expectations/tests/msvc-no-usr.rs +++ b/tests/expectations/tests/msvc-no-usr.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct A { pub foo: usize, } @@ -27,8 +27,3 @@ fn bindgen_test_layout_A() { concat!("Alignment of field: ", stringify!(A), "::", stringify!(foo)) ); } -impl Clone for A { - 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 2af91b4c0d..86147bdd10 100644 --- a/tests/expectations/tests/multiple-inherit-empty-correct-layout.rs +++ b/tests/expectations/tests/multiple-inherit-empty-correct-layout.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Foo { pub _address: u8, } @@ -22,13 +22,8 @@ fn bindgen_test_layout_Foo() { concat!("Alignment of ", stringify!(Foo)) ); } -impl Clone for Foo { - fn clone(&self) -> Self { - *self - } -} #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Bar { pub _address: u8, } @@ -45,13 +40,8 @@ fn bindgen_test_layout_Bar() { concat!("Alignment of ", stringify!(Bar)) ); } -impl Clone for Bar { - fn clone(&self) -> Self { - *self - } -} #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Baz { pub _address: u8, } @@ -68,8 +58,3 @@ fn bindgen_test_layout_Baz() { concat!("Alignment of ", stringify!(Baz)) ); } -impl Clone for Baz { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/mutable.rs b/tests/expectations/tests/mutable.rs index f7f580b2cb..7e841f7bd3 100644 --- a/tests/expectations/tests/mutable.rs +++ b/tests/expectations/tests/mutable.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct C { pub m_member: ::std::os::raw::c_int, pub m_other: ::std::os::raw::c_int, @@ -43,11 +43,6 @@ fn bindgen_test_layout_C() { ) ); } -impl Clone for C { - fn clone(&self) -> Self { - *self - } -} #[repr(C)] #[derive(Debug, Default)] pub struct NonCopiable { diff --git a/tests/expectations/tests/namespace.rs b/tests/expectations/tests/namespace.rs index e6077152ff..13a9df0e78 100644 --- a/tests/expectations/tests/namespace.rs +++ b/tests/expectations/tests/namespace.rs @@ -29,7 +29,7 @@ pub mod root { pub fn foo(); } #[repr(C)] - #[derive(Debug, Default, Copy)] + #[derive(Debug, Default, Copy, Clone)] pub struct A { pub b: root::whatever::whatever_int_t, } @@ -57,11 +57,6 @@ pub mod root { this: *mut root::_bindgen_mod_id_13::A, ) -> ::std::os::raw::c_int; } - impl Clone for A { - fn clone(&self) -> Self { - *self - } - } impl A { #[inline] pub unsafe fn lets_hope_this_works(&mut self) -> ::std::os::raw::c_int { diff --git a/tests/expectations/tests/nested.rs b/tests/expectations/tests/nested.rs index a8c7775c5f..336723bbf0 100644 --- a/tests/expectations/tests/nested.rs +++ b/tests/expectations/tests/nested.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Calc { pub w: ::std::os::raw::c_int, } @@ -32,24 +32,19 @@ fn bindgen_test_layout_Calc() { ) ); } -impl Clone for Calc { - fn clone(&self) -> Self { - *self - } -} #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Test { pub _address: u8, } #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Test_Size { pub mWidth: Test_Size_Dimension, pub mHeight: Test_Size_Dimension, } #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Test_Size_Dimension { pub _base: Calc, } @@ -66,11 +61,6 @@ fn bindgen_test_layout_Test_Size_Dimension() { concat!("Alignment of ", stringify!(Test_Size_Dimension)) ); } -impl Clone for Test_Size_Dimension { - fn clone(&self) -> Self { - *self - } -} #[test] fn bindgen_test_layout_Test_Size() { assert_eq!( @@ -104,11 +94,6 @@ fn bindgen_test_layout_Test_Size() { ) ); } -impl Clone for Test_Size { - fn clone(&self) -> Self { - *self - } -} #[test] fn bindgen_test_layout_Test() { assert_eq!( @@ -122,8 +107,3 @@ fn bindgen_test_layout_Test() { concat!("Alignment of ", stringify!(Test)) ); } -impl Clone for Test { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/nested_vtable.rs b/tests/expectations/tests/nested_vtable.rs index 0da5289ed0..4082610644 100644 --- a/tests/expectations/tests/nested_vtable.rs +++ b/tests/expectations/tests/nested_vtable.rs @@ -7,7 +7,7 @@ #[repr(C)] pub struct nsISupports__bindgen_vtable(::std::os::raw::c_void); #[repr(C)] -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Clone)] pub struct nsISupports { pub vtable_: *const nsISupports__bindgen_vtable, } @@ -24,11 +24,6 @@ fn bindgen_test_layout_nsISupports() { concat!("Alignment of ", stringify!(nsISupports)) ); } -impl Clone for nsISupports { - fn clone(&self) -> Self { - *self - } -} impl Default for nsISupports { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -39,7 +34,7 @@ extern "C" { pub fn nsISupports_QueryInterface(this: *mut ::std::os::raw::c_void) -> *mut nsISupports; } #[repr(C)] -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Clone)] pub struct nsIRunnable { pub _base: nsISupports, } @@ -56,18 +51,13 @@ fn bindgen_test_layout_nsIRunnable() { concat!("Alignment of ", stringify!(nsIRunnable)) ); } -impl Clone for nsIRunnable { - fn clone(&self) -> Self { - *self - } -} impl Default for nsIRunnable { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Clone)] pub struct Runnable { pub _base: nsIRunnable, } @@ -84,11 +74,6 @@ fn bindgen_test_layout_Runnable() { concat!("Alignment of ", stringify!(Runnable)) ); } -impl Clone for Runnable { - fn clone(&self) -> Self { - *self - } -} impl Default for Runnable { 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 d291a53738..0a494ba2e7 100644 --- a/tests/expectations/tests/nested_within_namespace.rs +++ b/tests/expectations/tests/nested_within_namespace.rs @@ -12,12 +12,12 @@ 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, } #[repr(C)] - #[derive(Debug, Default, Copy)] + #[derive(Debug, Default, Copy, Clone)] pub struct Bar_Baz { pub foo: ::std::os::raw::c_int, } @@ -44,11 +44,6 @@ pub mod root { ) ); } - impl Clone for Bar_Baz { - fn clone(&self) -> Self { - *self - } - } #[test] fn bindgen_test_layout_Bar() { assert_eq!( @@ -72,13 +67,8 @@ pub mod root { ) ); } - impl Clone for Bar { - fn clone(&self) -> Self { - *self - } - } #[repr(C)] - #[derive(Debug, Default, Copy)] + #[derive(Debug, Default, Copy, Clone)] pub struct Baz { pub baz: ::std::os::raw::c_int, } @@ -105,10 +95,5 @@ pub mod root { ) ); } - impl Clone for Baz { - fn clone(&self) -> Self { - *self - } - } } } diff --git a/tests/expectations/tests/no-comments.rs b/tests/expectations/tests/no-comments.rs index b097acd62d..0260e54861 100644 --- a/tests/expectations/tests/no-comments.rs +++ b/tests/expectations/tests/no-comments.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Foo { pub s: ::std::os::raw::c_int, } @@ -27,8 +27,3 @@ fn bindgen_test_layout_Foo() { concat!("Alignment of field: ", stringify!(Foo), "::", stringify!(s)) ); } -impl Clone for Foo { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/no-partialeq-opaque.rs b/tests/expectations/tests/no-partialeq-opaque.rs index 8fd5451fb3..1a7941623d 100644 --- a/tests/expectations/tests/no-partialeq-opaque.rs +++ b/tests/expectations/tests/no-partialeq-opaque.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct NoPartialEq { pub _bindgen_opaque_blob: u32, } @@ -22,8 +22,3 @@ fn bindgen_test_layout_NoPartialEq() { concat!("Alignment of ", stringify!(NoPartialEq)) ); } -impl Clone for NoPartialEq { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/no-partialeq-whitelisted.rs b/tests/expectations/tests/no-partialeq-whitelisted.rs index f07864cea8..fb1437f1fe 100644 --- a/tests/expectations/tests/no-partialeq-whitelisted.rs +++ b/tests/expectations/tests/no-partialeq-whitelisted.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct NoPartialEq { pub i: ::std::os::raw::c_int, } @@ -32,8 +32,3 @@ fn bindgen_test_layout_NoPartialEq() { ) ); } -impl Clone for NoPartialEq { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/no-std.rs b/tests/expectations/tests/no-std.rs index 252b51ff44..2708b21cfa 100644 --- a/tests/expectations/tests/no-std.rs +++ b/tests/expectations/tests/no-std.rs @@ -9,7 +9,7 @@ mod libc { } #[repr(C)] -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Clone)] pub struct foo { pub a: libc::c_int, pub b: libc::c_int, @@ -48,11 +48,6 @@ fn bindgen_test_layout_foo() { ) ); } -impl Clone for foo { - fn clone(&self) -> Self { - *self - } -} impl Default for foo { 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 4a6626a095..c20876dcd1 100644 --- a/tests/expectations/tests/non-type-params.rs +++ b/tests/expectations/tests/non-type-params.rs @@ -7,7 +7,7 @@ pub type Array16 = u8; pub type ArrayInt4 = [u32; 4usize]; #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct UsesArray { pub array_char_16: [u8; 16usize], pub array_bool_8: [u8; 8usize], @@ -56,8 +56,3 @@ fn bindgen_test_layout_UsesArray() { ) ); } -impl Clone for UsesArray { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/objc_interface_type.rs b/tests/expectations/tests/objc_interface_type.rs index 446e638450..52cad57d53 100644 --- a/tests/expectations/tests/objc_interface_type.rs +++ b/tests/expectations/tests/objc_interface_type.rs @@ -11,7 +11,7 @@ pub type id = *mut objc::runtime::Object; pub trait Foo {} impl Foo for id {} #[repr(C)] -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Clone)] pub struct FooStruct { pub foo: *mut id, } @@ -38,11 +38,6 @@ fn bindgen_test_layout_FooStruct() { ) ); } -impl Clone for FooStruct { - fn clone(&self) -> Self { - *self - } -} impl Default for FooStruct { fn default() -> Self { unsafe { ::std::mem::zeroed() } diff --git a/tests/expectations/tests/only_bitfields.rs b/tests/expectations/tests/only_bitfields.rs index 4bc21afb67..5ac15b3859 100644 --- a/tests/expectations/tests/only_bitfields.rs +++ b/tests/expectations/tests/only_bitfields.rs @@ -5,7 +5,7 @@ #[repr(C, packed)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct C { pub _bitfield_1: u8, } @@ -22,11 +22,6 @@ fn bindgen_test_layout_C() { concat!("Alignment of ", stringify!(C)) ); } -impl Clone for C { - fn clone(&self) -> Self { - *self - } -} impl C { #[inline] pub fn a(&self) -> bool { diff --git a/tests/expectations/tests/opaque-template-inst-member-2.rs b/tests/expectations/tests/opaque-template-inst-member-2.rs index 20b44d7e76..6cac967e7d 100644 --- a/tests/expectations/tests/opaque-template-inst-member-2.rs +++ b/tests/expectations/tests/opaque-template-inst-member-2.rs @@ -12,7 +12,7 @@ pub struct OpaqueTemplate {} /// Should derive Debug/Hash/PartialEq. #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct ContainsOpaqueTemplate { pub mBlah: u32, pub mBaz: ::std::os::raw::c_int, @@ -50,14 +50,9 @@ fn bindgen_test_layout_ContainsOpaqueTemplate() { ) ); } -impl Clone for ContainsOpaqueTemplate { - fn clone(&self) -> Self { - *self - } -} /// Should also derive Debug/Hash/PartialEq. #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct InheritsOpaqueTemplate { pub _base: u8, pub wow: *mut ::std::os::raw::c_char, @@ -85,11 +80,6 @@ fn bindgen_test_layout_InheritsOpaqueTemplate() { ) ); } -impl Clone for InheritsOpaqueTemplate { - fn clone(&self) -> Self { - *self - } -} impl Default for InheritsOpaqueTemplate { fn default() -> Self { unsafe { ::std::mem::zeroed() } diff --git a/tests/expectations/tests/opaque-template-instantiation-namespaced.rs b/tests/expectations/tests/opaque-template-instantiation-namespaced.rs index e541e64839..45d8a7d826 100644 --- a/tests/expectations/tests/opaque-template-instantiation-namespaced.rs +++ b/tests/expectations/tests/opaque-template-instantiation-namespaced.rs @@ -23,7 +23,7 @@ pub mod root { } } #[repr(C)] - #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] + #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct Foo { pub c: ::std::os::raw::c_char, } @@ -45,13 +45,8 @@ pub mod root { concat!("Alignment of field: ", stringify!(Foo), "::", stringify!(c)) ); } - impl Clone for Foo { - fn clone(&self) -> Self { - *self - } - } #[repr(C)] - #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] + #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct Bar { pub i: ::std::os::raw::c_int, } @@ -73,13 +68,8 @@ pub mod root { concat!("Alignment of field: ", stringify!(Bar), "::", stringify!(i)) ); } - impl Clone for Bar { - fn clone(&self) -> Self { - *self - } - } #[repr(C)] - #[derive(Debug, Copy, Hash, PartialEq, Eq)] + #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct ContainsInstantiation { pub not_opaque: root::zoidberg::Template, } @@ -106,18 +96,13 @@ pub mod root { ) ); } - impl Clone for ContainsInstantiation { - fn clone(&self) -> Self { - *self - } - } impl Default for ContainsInstantiation { 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 ContainsOpaqueInstantiation { pub opaque: u32, } @@ -146,11 +131,6 @@ pub mod root { ) ); } - impl Clone for ContainsOpaqueInstantiation { - fn clone(&self) -> Self { - *self - } - } } #[test] fn __bindgen_test_layout_Template_open0_Foo_close0_instantiation() { diff --git a/tests/expectations/tests/opaque-template-instantiation.rs b/tests/expectations/tests/opaque-template-instantiation.rs index 779c32a60e..02788d769c 100644 --- a/tests/expectations/tests/opaque-template-instantiation.rs +++ b/tests/expectations/tests/opaque-template-instantiation.rs @@ -16,7 +16,7 @@ impl Default for Template { } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct ContainsInstantiation { pub not_opaque: Template<::std::os::raw::c_char>, } @@ -43,18 +43,13 @@ fn bindgen_test_layout_ContainsInstantiation() { ) ); } -impl Clone for ContainsInstantiation { - fn clone(&self) -> Self { - *self - } -} impl Default for ContainsInstantiation { 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 ContainsOpaqueInstantiation { pub opaque: u32, } @@ -81,11 +76,6 @@ fn bindgen_test_layout_ContainsOpaqueInstantiation() { ) ); } -impl Clone for ContainsOpaqueInstantiation { - fn clone(&self) -> Self { - *self - } -} #[test] fn __bindgen_test_layout_Template_open0_char_close0_instantiation() { assert_eq!( diff --git a/tests/expectations/tests/opaque-tracing.rs b/tests/expectations/tests/opaque-tracing.rs index 62f63c4298..87d91f3c4e 100644 --- a/tests/expectations/tests/opaque-tracing.rs +++ b/tests/expectations/tests/opaque-tracing.rs @@ -9,7 +9,7 @@ extern "C" { pub fn foo(c: *mut Container); } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct Container { pub _bindgen_opaque_blob: [u32; 2usize], } @@ -26,8 +26,3 @@ fn bindgen_test_layout_Container() { concat!("Alignment of ", stringify!(Container)) ); } -impl Clone for Container { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/opaque_in_struct.rs b/tests/expectations/tests/opaque_in_struct.rs index 49cfc5fc10..92d28e4d03 100644 --- a/tests/expectations/tests/opaque_in_struct.rs +++ b/tests/expectations/tests/opaque_in_struct.rs @@ -7,7 +7,7 @@ ///
#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct opaque { pub _bindgen_opaque_blob: u32, } @@ -24,13 +24,8 @@ fn bindgen_test_layout_opaque() { concat!("Alignment of ", stringify!(opaque)) ); } -impl Clone for opaque { - 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 contained: opaque, } @@ -57,8 +52,3 @@ fn bindgen_test_layout_container() { ) ); } -impl Clone for container { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/opaque_pointer.rs b/tests/expectations/tests/opaque_pointer.rs index 6eb7b67235..cc8e247fc4 100644 --- a/tests/expectations/tests/opaque_pointer.rs +++ b/tests/expectations/tests/opaque_pointer.rs @@ -7,7 +7,7 @@ ///
#[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct OtherOpaque { pub _bindgen_opaque_blob: u32, } @@ -24,17 +24,12 @@ fn bindgen_test_layout_OtherOpaque() { concat!("Alignment of ", stringify!(OtherOpaque)) ); } -impl Clone for OtherOpaque { - fn clone(&self) -> Self { - *self - } -} ///
#[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct Opaque {} #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq)] pub struct WithOpaquePtr { pub whatever: *mut u8, pub other: u32, @@ -83,11 +78,6 @@ fn bindgen_test_layout_WithOpaquePtr() { ) ); } -impl Clone for WithOpaquePtr { - fn clone(&self) -> Self { - *self - } -} impl Default for WithOpaquePtr { fn default() -> Self { unsafe { ::std::mem::zeroed() } diff --git a/tests/expectations/tests/private.rs b/tests/expectations/tests/private.rs index 73f6377d4c..400373f885 100644 --- a/tests/expectations/tests/private.rs +++ b/tests/expectations/tests/private.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct HasPrivate { pub mNotPrivate: ::std::os::raw::c_int, ///
@@ -44,14 +44,9 @@ fn bindgen_test_layout_HasPrivate() { ) ); } -impl Clone for HasPrivate { - fn clone(&self) -> Self { - *self - } -} ///
#[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct VeryPrivate { mIsPrivate: ::std::os::raw::c_int, mIsAlsoPrivate: ::std::os::raw::c_int, @@ -89,14 +84,9 @@ fn bindgen_test_layout_VeryPrivate() { ) ); } -impl Clone for VeryPrivate { - fn clone(&self) -> Self { - *self - } -} ///
#[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct ContradictPrivate { ///
pub mNotPrivate: ::std::os::raw::c_int, @@ -135,8 +125,3 @@ fn bindgen_test_layout_ContradictPrivate() { ) ); } -impl Clone for ContradictPrivate { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/ref_argument_array.rs b/tests/expectations/tests/ref_argument_array.rs index fd57dd5732..14675a677f 100644 --- a/tests/expectations/tests/ref_argument_array.rs +++ b/tests/expectations/tests/ref_argument_array.rs @@ -8,7 +8,7 @@ pub const NSID_LENGTH: ::std::os::raw::c_uint = 10; #[repr(C)] pub struct nsID__bindgen_vtable(::std::os::raw::c_void); #[repr(C)] -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Clone)] pub struct nsID { pub vtable_: *const nsID__bindgen_vtable, } @@ -25,11 +25,6 @@ fn bindgen_test_layout_nsID() { concat!("Alignment of ", stringify!(nsID)) ); } -impl Clone for nsID { - fn clone(&self) -> Self { - *self - } -} impl Default for nsID { fn default() -> Self { unsafe { ::std::mem::zeroed() } diff --git a/tests/expectations/tests/reparented_replacement.rs b/tests/expectations/tests/reparented_replacement.rs index 0402c95c44..57a1187116 100644 --- a/tests/expectations/tests/reparented_replacement.rs +++ b/tests/expectations/tests/reparented_replacement.rs @@ -13,7 +13,7 @@ pub mod root { use self::super::super::root; ///
#[repr(C)] - #[derive(Debug, Default, Copy)] + #[derive(Debug, Default, Copy, Clone)] pub struct Bar { pub bazz: ::std::os::raw::c_int, } @@ -40,11 +40,6 @@ pub mod root { ) ); } - impl Clone for Bar { - fn clone(&self) -> Self { - *self - } - } } pub type ReferencesBar = root::foo::Bar; } diff --git a/tests/expectations/tests/replace_use.rs b/tests/expectations/tests/replace_use.rs index 49185e32be..5f85dc323f 100644 --- a/tests/expectations/tests/replace_use.rs +++ b/tests/expectations/tests/replace_use.rs @@ -12,7 +12,7 @@ pub struct nsTArray { pub y: ::std::os::raw::c_uint, } #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Test { pub a: nsTArray, } @@ -39,11 +39,6 @@ fn bindgen_test_layout_Test() { ) ); } -impl Clone for Test { - fn clone(&self) -> Self { - *self - } -} #[test] fn __bindgen_test_layout_nsTArray_open0_long_close0_instantiation() { assert_eq!( 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 3575a581aa..b89568ecb6 100644 --- a/tests/expectations/tests/same_struct_name_in_different_namespaces.rs +++ b/tests/expectations/tests/same_struct_name_in_different_namespaces.rs @@ -10,7 +10,7 @@ pub struct JS_Zone { _unused: [u8; 0], } #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct JS_shadow_Zone { pub x: ::std::os::raw::c_int, pub y: ::std::os::raw::c_int, @@ -48,8 +48,3 @@ fn bindgen_test_layout_JS_shadow_Zone() { ) ); } -impl Clone for JS_shadow_Zone { - 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 61d35e25d3..96ad812977 100644 --- a/tests/expectations/tests/sentry-defined-multiple-times.rs +++ b/tests/expectations/tests/sentry-defined-multiple-times.rs @@ -22,7 +22,7 @@ pub mod root { pub i_am_wrapper_sentry: ::std::os::raw::c_int, } #[repr(C)] - #[derive(Debug, Default, Copy)] + #[derive(Debug, Default, Copy, Clone)] pub struct sentry { pub i_am_plain_sentry: bool, } @@ -49,13 +49,8 @@ pub mod root { ) ); } - impl Clone for sentry { - fn clone(&self) -> Self { - *self - } - } #[repr(C)] - #[derive(Debug, Default, Copy)] + #[derive(Debug, Default, Copy, Clone)] pub struct NotTemplateWrapper { pub _address: u8, } @@ -72,13 +67,8 @@ pub mod root { concat!("Alignment of ", stringify!(NotTemplateWrapper)) ); } - impl Clone for NotTemplateWrapper { - fn clone(&self) -> Self { - *self - } - } #[repr(C)] - #[derive(Debug, Default, Copy)] + #[derive(Debug, Default, Copy, Clone)] pub struct NotTemplateWrapper_sentry { pub i_am_not_template_wrapper_sentry: ::std::os::raw::c_char, } @@ -108,18 +98,13 @@ pub mod root { ) ); } - impl Clone for NotTemplateWrapper_sentry { - fn clone(&self) -> Self { - *self - } - } #[repr(C)] - #[derive(Debug, Default, Copy)] + #[derive(Debug, Default, Copy, Clone)] pub struct InlineNotTemplateWrapper { pub _address: u8, } #[repr(C)] - #[derive(Debug, Default, Copy)] + #[derive(Debug, Default, Copy, Clone)] pub struct InlineNotTemplateWrapper_sentry { pub i_am_inline_not_template_wrapper_sentry: bool, } @@ -150,11 +135,6 @@ pub mod root { ) ); } - impl Clone for InlineNotTemplateWrapper_sentry { - fn clone(&self) -> Self { - *self - } - } #[test] fn bindgen_test_layout_InlineNotTemplateWrapper() { assert_eq!( @@ -168,11 +148,6 @@ pub mod root { concat!("Alignment of ", stringify!(InlineNotTemplateWrapper)) ); } - impl Clone for InlineNotTemplateWrapper { - fn clone(&self) -> Self { - *self - } - } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct InlineTemplateWrapper { @@ -184,12 +159,12 @@ pub mod root { pub i_am_inline_template_wrapper_sentry: ::std::os::raw::c_int, } #[repr(C)] - #[derive(Debug, Default, Copy)] + #[derive(Debug, Default, Copy, Clone)] pub struct OuterDoubleWrapper { pub _address: u8, } #[repr(C)] - #[derive(Debug, Default, Copy)] + #[derive(Debug, Default, Copy, Clone)] pub struct OuterDoubleWrapper_InnerDoubleWrapper { pub _address: u8, } @@ -212,11 +187,6 @@ pub mod root { ) ); } - impl Clone for OuterDoubleWrapper_InnerDoubleWrapper { - fn clone(&self) -> Self { - *self - } - } #[test] fn bindgen_test_layout_OuterDoubleWrapper() { assert_eq!( @@ -230,13 +200,8 @@ pub mod root { concat!("Alignment of ", stringify!(OuterDoubleWrapper)) ); } - impl Clone for OuterDoubleWrapper { - fn clone(&self) -> Self { - *self - } - } #[repr(C)] - #[derive(Debug, Default, Copy)] + #[derive(Debug, Default, Copy, Clone)] pub struct OuterDoubleWrapper_InnerDoubleWrapper_sentry { pub i_am_double_wrapper_sentry: ::std::os::raw::c_int, } @@ -272,23 +237,18 @@ pub mod root { ) ); } - impl Clone for OuterDoubleWrapper_InnerDoubleWrapper_sentry { - fn clone(&self) -> Self { - *self - } - } #[repr(C)] - #[derive(Debug, Default, Copy)] + #[derive(Debug, Default, Copy, Clone)] pub struct OuterDoubleInlineWrapper { pub _address: u8, } #[repr(C)] - #[derive(Debug, Default, Copy)] + #[derive(Debug, Default, Copy, Clone)] pub struct OuterDoubleInlineWrapper_InnerDoubleInlineWrapper { pub _address: u8, } #[repr(C)] - #[derive(Debug, Default, Copy)] + #[derive(Debug, Default, Copy, Clone)] pub struct OuterDoubleInlineWrapper_InnerDoubleInlineWrapper_sentry { pub i_am_double_wrapper_inline_sentry: ::std::os::raw::c_int, } @@ -324,11 +284,6 @@ pub mod root { ) ); } - impl Clone for OuterDoubleInlineWrapper_InnerDoubleInlineWrapper_sentry { - fn clone(&self) -> Self { - *self - } - } #[test] fn bindgen_test_layout_OuterDoubleInlineWrapper_InnerDoubleInlineWrapper() { assert_eq!( @@ -348,11 +303,6 @@ pub mod root { ) ); } - impl Clone for OuterDoubleInlineWrapper_InnerDoubleInlineWrapper { - fn clone(&self) -> Self { - *self - } - } #[test] fn bindgen_test_layout_OuterDoubleInlineWrapper() { assert_eq!( @@ -366,11 +316,6 @@ pub mod root { concat!("Alignment of ", stringify!(OuterDoubleInlineWrapper)) ); } - impl Clone for OuterDoubleInlineWrapper { - fn clone(&self) -> Self { - *self - } - } } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] @@ -383,7 +328,7 @@ pub mod root { pub i_am_outside_namespace_wrapper_sentry: ::std::os::raw::c_int, } #[repr(C)] - #[derive(Debug, Default, Copy)] + #[derive(Debug, Default, Copy, Clone)] pub struct sentry { pub i_am_outside_namespace_sentry: ::std::os::raw::c_int, } @@ -410,9 +355,4 @@ pub mod root { ) ); } - impl Clone for sentry { - fn clone(&self) -> Self { - *self - } - } } diff --git a/tests/expectations/tests/size_t_template.rs b/tests/expectations/tests/size_t_template.rs index 16a72e25b7..9fa6c3ad77 100644 --- a/tests/expectations/tests/size_t_template.rs +++ b/tests/expectations/tests/size_t_template.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct C { pub arr: [u32; 3usize], } @@ -27,8 +27,3 @@ fn bindgen_test_layout_C() { concat!("Alignment of field: ", stringify!(C), "::", stringify!(arr)) ); } -impl Clone for C { - 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 12e13dc8cf..f20b9b3a7c 100644 --- a/tests/expectations/tests/struct_containing_forward_declared_struct.rs +++ b/tests/expectations/tests/struct_containing_forward_declared_struct.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct a { pub val_a: *mut b, } @@ -32,18 +32,13 @@ 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 val_b: ::std::os::raw::c_int, } @@ -70,8 +65,3 @@ fn bindgen_test_layout_b() { ) ); } -impl Clone for b { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/struct_typedef.rs b/tests/expectations/tests/struct_typedef.rs index f1e195fdf1..1079bb3fa9 100644 --- a/tests/expectations/tests/struct_typedef.rs +++ b/tests/expectations/tests/struct_typedef.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct typedef_named_struct { pub has_name: bool, } @@ -32,13 +32,8 @@ fn bindgen_test_layout_typedef_named_struct() { ) ); } -impl Clone for typedef_named_struct { - fn clone(&self) -> Self { - *self - } -} #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct _bindgen_ty_1 { pub no_name: *mut ::std::os::raw::c_void, } @@ -65,11 +60,6 @@ fn bindgen_test_layout__bindgen_ty_1() { ) ); } -impl Clone for _bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} impl Default for _bindgen_ty_1 { fn default() -> Self { unsafe { ::std::mem::zeroed() } diff --git a/tests/expectations/tests/struct_typedef_ns.rs b/tests/expectations/tests/struct_typedef_ns.rs index e0dfe41d34..b40c1733d0 100644 --- a/tests/expectations/tests/struct_typedef_ns.rs +++ b/tests/expectations/tests/struct_typedef_ns.rs @@ -12,7 +12,7 @@ pub mod root { #[allow(unused_imports)] use self::super::super::root; #[repr(C)] - #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] + #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct typedef_struct { pub foo: ::std::os::raw::c_int, } @@ -39,11 +39,6 @@ pub mod root { ) ); } - impl Clone for typedef_struct { - fn clone(&self) -> Self { - *self - } - } #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum typedef_enum { @@ -54,7 +49,7 @@ pub mod root { #[allow(unused_imports)] use self::super::super::root; #[repr(C)] - #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] + #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct _bindgen_ty_1 { pub foo: ::std::os::raw::c_int, } @@ -81,11 +76,6 @@ pub mod root { ) ); } - impl Clone for _bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } - } pub type typedef_struct = root::_bindgen_mod_id_12::_bindgen_ty_1; pub const _bindgen_mod_id_12_BAR: root::_bindgen_mod_id_12::_bindgen_ty_2 = _bindgen_ty_2::BAR; diff --git a/tests/expectations/tests/struct_with_anon_struct.rs b/tests/expectations/tests/struct_with_anon_struct.rs index d386c79b8f..b8726df08f 100644 --- a/tests/expectations/tests/struct_with_anon_struct.rs +++ b/tests/expectations/tests/struct_with_anon_struct.rs @@ -5,12 +5,12 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct foo { pub bar: foo__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1 { pub a: ::std::os::raw::c_int, pub b: ::std::os::raw::c_int, @@ -48,11 +48,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!( @@ -76,8 +71,3 @@ fn bindgen_test_layout_foo() { ) ); } -impl Clone for foo { - 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 2826c36e57..8616ba5d75 100644 --- a/tests/expectations/tests/struct_with_anon_struct_array.rs +++ b/tests/expectations/tests/struct_with_anon_struct_array.rs @@ -5,13 +5,13 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct foo { pub bar: [foo__bindgen_ty_1; 2usize], pub baz: [[[foo__bindgen_ty_2; 4usize]; 3usize]; 2usize], } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1 { pub a: ::std::os::raw::c_int, pub b: ::std::os::raw::c_int, @@ -49,13 +49,8 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { ) ); } -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_2 { pub a: ::std::os::raw::c_int, pub b: ::std::os::raw::c_int, @@ -93,11 +88,6 @@ fn bindgen_test_layout_foo__bindgen_ty_2() { ) ); } -impl Clone for foo__bindgen_ty_2 { - fn clone(&self) -> Self { - *self - } -} #[test] fn bindgen_test_layout_foo() { assert_eq!( @@ -131,8 +121,3 @@ fn bindgen_test_layout_foo() { ) ); } -impl Clone for foo { - 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 bf3ad0499d..733721be38 100644 --- a/tests/expectations/tests/struct_with_anon_struct_pointer.rs +++ b/tests/expectations/tests/struct_with_anon_struct_pointer.rs @@ -5,12 +5,12 @@ #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct foo { pub bar: *mut foo__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1 { pub a: ::std::os::raw::c_int, pub b: ::std::os::raw::c_int, @@ -48,11 +48,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!( @@ -76,11 +71,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() } diff --git a/tests/expectations/tests/struct_with_anon_union.rs b/tests/expectations/tests/struct_with_anon_union.rs index 665ec30867..716461ea51 100644 --- a/tests/expectations/tests/struct_with_anon_union.rs +++ b/tests/expectations/tests/struct_with_anon_union.rs @@ -5,12 +5,12 @@ #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct foo { pub bar: foo__bindgen_ty_1, } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union foo__bindgen_ty_1 { pub a: ::std::os::raw::c_uint, pub b: ::std::os::raw::c_ushort, @@ -49,11 +49,6 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { ) ); } -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} impl Default for foo__bindgen_ty_1 { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -82,11 +77,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() } diff --git a/tests/expectations/tests/struct_with_anon_unnamed_struct.rs b/tests/expectations/tests/struct_with_anon_unnamed_struct.rs index ba596f334e..839023ecbb 100644 --- a/tests/expectations/tests/struct_with_anon_unnamed_struct.rs +++ b/tests/expectations/tests/struct_with_anon_unnamed_struct.rs @@ -5,12 +5,12 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct foo { pub __bindgen_anon_1: foo__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1 { pub a: ::std::os::raw::c_uint, pub b: ::std::os::raw::c_uint, @@ -48,11 +48,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!( @@ -66,8 +61,3 @@ fn bindgen_test_layout_foo() { concat!("Alignment of ", stringify!(foo)) ); } -impl Clone for foo { - 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 37ba81c332..3cb92db746 100644 --- a/tests/expectations/tests/struct_with_anon_unnamed_union.rs +++ b/tests/expectations/tests/struct_with_anon_unnamed_union.rs @@ -5,12 +5,12 @@ #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct foo { pub __bindgen_anon_1: foo__bindgen_ty_1, } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union foo__bindgen_ty_1 { pub a: ::std::os::raw::c_uint, pub b: ::std::os::raw::c_ushort, @@ -49,11 +49,6 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { ) ); } -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} impl Default for foo__bindgen_ty_1 { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -72,11 +67,6 @@ fn bindgen_test_layout_foo() { concat!("Alignment of ", stringify!(foo)) ); } -impl Clone for foo { - fn clone(&self) -> Self { - *self - } -} impl Default for foo { fn default() -> Self { unsafe { ::std::mem::zeroed() } diff --git a/tests/expectations/tests/struct_with_bitfields.rs b/tests/expectations/tests/struct_with_bitfields.rs index fffb938015..9c7b30072e 100644 --- a/tests/expectations/tests/struct_with_bitfields.rs +++ b/tests/expectations/tests/struct_with_bitfields.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct bitfield { pub _bitfield_1: u8, pub e: ::std::os::raw::c_int, @@ -34,11 +34,6 @@ fn bindgen_test_layout_bitfield() { ) ); } -impl Clone for bitfield { - fn clone(&self) -> Self { - *self - } -} impl bitfield { #[inline] pub fn a(&self) -> ::std::os::raw::c_ushort { diff --git a/tests/expectations/tests/struct_with_derive_debug.rs b/tests/expectations/tests/struct_with_derive_debug.rs index f681e21e94..4a068de59e 100644 --- a/tests/expectations/tests/struct_with_derive_debug.rs +++ b/tests/expectations/tests/struct_with_derive_debug.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct LittleArray { pub a: [::std::os::raw::c_int; 32usize], } @@ -32,13 +32,8 @@ fn bindgen_test_layout_LittleArray() { ) ); } -impl Clone for LittleArray { - fn clone(&self) -> Self { - *self - } -} #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct BigArray { pub a: [::std::os::raw::c_int; 33usize], } @@ -65,18 +60,13 @@ fn bindgen_test_layout_BigArray() { ) ); } -impl Clone for BigArray { - fn clone(&self) -> Self { - *self - } -} impl Default for BigArray { 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 WithLittleArray { pub a: LittleArray, } @@ -103,13 +93,8 @@ fn bindgen_test_layout_WithLittleArray() { ) ); } -impl Clone for WithLittleArray { - fn clone(&self) -> Self { - *self - } -} #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct WithBigArray { pub a: BigArray, } @@ -136,11 +121,6 @@ fn bindgen_test_layout_WithBigArray() { ) ); } -impl Clone for WithBigArray { - fn clone(&self) -> Self { - *self - } -} impl Default for WithBigArray { 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 73b29fd90d..decc5934df 100644 --- a/tests/expectations/tests/struct_with_large_array.rs +++ b/tests/expectations/tests/struct_with_large_array.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct S { pub large_array: [::std::os::raw::c_char; 33usize], } @@ -32,11 +32,6 @@ fn bindgen_test_layout_S() { ) ); } -impl Clone for S { - fn clone(&self) -> Self { - *self - } -} impl Default for S { 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 d25fc4bc28..08fbc52c03 100644 --- a/tests/expectations/tests/struct_with_nesting.rs +++ b/tests/expectations/tests/struct_with_nesting.rs @@ -5,13 +5,13 @@ #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct foo { pub a: ::std::os::raw::c_uint, pub __bindgen_anon_1: foo__bindgen_ty_1, } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union foo__bindgen_ty_1 { pub b: ::std::os::raw::c_uint, pub __bindgen_anon_1: foo__bindgen_ty_1__bindgen_ty_1, @@ -19,7 +19,7 @@ pub union foo__bindgen_ty_1 { _bindgen_union_align: u32, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1__bindgen_ty_1 { pub c1: ::std::os::raw::c_ushort, pub c2: ::std::os::raw::c_ushort, @@ -57,13 +57,8 @@ fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_1() { ) ); } -impl Clone for foo__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1__bindgen_ty_2 { pub d1: ::std::os::raw::c_uchar, pub d2: ::std::os::raw::c_uchar, @@ -123,11 +118,6 @@ fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_2() { ) ); } -impl Clone for foo__bindgen_ty_1__bindgen_ty_2 { - fn clone(&self) -> Self { - *self - } -} #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { assert_eq!( @@ -151,11 +141,6 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { ) ); } -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} impl Default for foo__bindgen_ty_1 { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -179,11 +164,6 @@ fn bindgen_test_layout_foo() { concat!("Alignment of field: ", stringify!(foo), "::", stringify!(a)) ); } -impl Clone for foo { - fn clone(&self) -> Self { - *self - } -} impl Default for foo { fn default() -> Self { unsafe { ::std::mem::zeroed() } diff --git a/tests/expectations/tests/struct_with_packing.rs b/tests/expectations/tests/struct_with_packing.rs index acdcd9b37f..b942ebd185 100644 --- a/tests/expectations/tests/struct_with_packing.rs +++ b/tests/expectations/tests/struct_with_packing.rs @@ -5,7 +5,7 @@ #[repr(C, packed)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct a { pub b: ::std::os::raw::c_char, pub c: ::std::os::raw::c_short, @@ -33,8 +33,3 @@ fn bindgen_test_layout_a() { concat!("Alignment of field: ", stringify!(a), "::", stringify!(c)) ); } -impl Clone for a { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/struct_with_struct.rs b/tests/expectations/tests/struct_with_struct.rs index 22676961e8..1549438776 100644 --- a/tests/expectations/tests/struct_with_struct.rs +++ b/tests/expectations/tests/struct_with_struct.rs @@ -5,12 +5,12 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct foo { pub bar: foo__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1 { pub x: ::std::os::raw::c_uint, pub y: ::std::os::raw::c_uint, @@ -48,11 +48,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!( @@ -76,8 +71,3 @@ fn bindgen_test_layout_foo() { ) ); } -impl Clone for foo { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/template.rs b/tests/expectations/tests/template.rs index 46eb0a33e5..c00fb17fd8 100644 --- a/tests/expectations/tests/template.rs +++ b/tests/expectations/tests/template.rs @@ -38,7 +38,7 @@ pub struct mozilla_Foo { _unused: [u8; 0], } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct C { pub mB: B<::std::os::raw::c_uint>, pub mBConstPtr: B<*const ::std::os::raw::c_int>, @@ -214,11 +214,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() } @@ -261,7 +256,7 @@ impl Default for Rooted { } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct RootedContainer { pub root: Rooted<*mut ::std::os::raw::c_void>, } @@ -288,11 +283,6 @@ fn bindgen_test_layout_RootedContainer() { ) ); } -impl Clone for RootedContainer { - fn clone(&self) -> Self { - *self - } -} impl Default for RootedContainer { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -348,7 +338,7 @@ impl Default for PODButContainsDtor { #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct Opaque {} #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct POD { pub opaque_member: u32, } @@ -375,11 +365,6 @@ fn bindgen_test_layout_POD() { ) ); } -impl Clone for POD { - fn clone(&self) -> Self { - *self - } -} ///
#[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] @@ -428,7 +413,7 @@ impl Default for Incomplete { } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct Untemplated { pub _address: u8, } @@ -445,11 +430,6 @@ fn bindgen_test_layout_Untemplated() { concat!("Alignment of ", stringify!(Untemplated)) ); } -impl Clone for Untemplated { - fn clone(&self) -> Self { - *self - } -} #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct Templated { 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 c53d5de35c..b6ab186a3f 100644 --- a/tests/expectations/tests/test_multiple_header_calls_in_builder.rs +++ b/tests/expectations/tests/test_multiple_header_calls_in_builder.rs @@ -12,7 +12,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, Copy)] +#[derive(Debug, Copy, Clone)] pub struct Test { pub ch: ::std::os::raw::c_char, pub u: ::std::os::raw::c_uchar, @@ -160,8 +160,3 @@ fn bindgen_test_layout_Test() { ) ); } -impl Clone for Test { - 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 3334eff5a2..73902a4260 100644 --- a/tests/expectations/tests/type-referenced-by-whitelisted-function.rs +++ b/tests/expectations/tests/type-referenced-by-whitelisted-function.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct dl_phdr_info { pub x: ::std::os::raw::c_int, } @@ -32,11 +32,6 @@ fn bindgen_test_layout_dl_phdr_info() { ) ); } -impl Clone for dl_phdr_info { - 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/typeref.rs b/tests/expectations/tests/typeref.rs index f8ed525bdb..7376aa7694 100644 --- a/tests/expectations/tests/typeref.rs +++ b/tests/expectations/tests/typeref.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct mozilla_FragmentOrURL { pub mIsLocalRef: bool, } @@ -32,13 +32,8 @@ fn bindgen_test_layout_mozilla_FragmentOrURL() { ) ); } -impl Clone for mozilla_FragmentOrURL { - fn clone(&self) -> Self { - *self - } -} #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct mozilla_Position { pub _address: u8, } @@ -55,11 +50,6 @@ fn bindgen_test_layout_mozilla_Position() { concat!("Alignment of ", stringify!(mozilla_Position)) ); } -impl Clone for mozilla_Position { - fn clone(&self) -> Self { - *self - } -} #[repr(C)] pub struct mozilla_StyleShapeSource { pub __bindgen_anon_1: mozilla_StyleShapeSource__bindgen_ty_1, @@ -81,7 +71,7 @@ impl Default for mozilla_StyleShapeSource { } } #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct Bar { pub mFoo: *mut nsFoo, } @@ -108,11 +98,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() } diff --git a/tests/expectations/tests/underscore.rs b/tests/expectations/tests/underscore.rs index d1b0ccc23f..d9c61f7b6d 100644 --- a/tests/expectations/tests/underscore.rs +++ b/tests/expectations/tests/underscore.rs @@ -6,7 +6,7 @@ pub const __: ::std::os::raw::c_int = 10; #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct ptr_t { pub __: [::std::os::raw::c_uchar; 8usize], } @@ -33,8 +33,3 @@ fn bindgen_test_layout_ptr_t() { ) ); } -impl Clone for ptr_t { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/union-in-ns.rs b/tests/expectations/tests/union-in-ns.rs index a29b503835..9776626c8d 100644 --- a/tests/expectations/tests/union-in-ns.rs +++ b/tests/expectations/tests/union-in-ns.rs @@ -9,7 +9,7 @@ pub mod root { #[allow(unused_imports)] use self::super::root; #[repr(C)] - #[derive(Copy)] + #[derive(Copy, Clone)] pub union bar { pub baz: ::std::os::raw::c_int, _bindgen_union_align: u32, @@ -37,11 +37,6 @@ pub mod root { ) ); } - impl Clone for bar { - fn clone(&self) -> Self { - *self - } - } impl Default for bar { fn default() -> Self { unsafe { ::std::mem::zeroed() } diff --git a/tests/expectations/tests/union_bitfield.rs b/tests/expectations/tests/union_bitfield.rs index ad41435d39..ee82188c36 100644 --- a/tests/expectations/tests/union_bitfield.rs +++ b/tests/expectations/tests/union_bitfield.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union U4 { pub _bitfield_1: u8, _bindgen_union_align: u32, @@ -23,11 +23,6 @@ fn bindgen_test_layout_U4() { concat!("Alignment of ", stringify!(U4)) ); } -impl Clone for U4 { - fn clone(&self) -> Self { - *self - } -} impl Default for U4 { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -76,7 +71,7 @@ impl U4 { } } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union B { pub _bitfield_1: u32, _bindgen_union_align: u32, @@ -94,11 +89,6 @@ fn bindgen_test_layout_B() { concat!("Alignment of ", stringify!(B)) ); } -impl Clone for B { - fn clone(&self) -> Self { - *self - } -} impl Default for B { fn default() -> Self { unsafe { ::std::mem::zeroed() } diff --git a/tests/expectations/tests/union_fields.rs b/tests/expectations/tests/union_fields.rs index 988b7ae8e1..0c723b2a1c 100644 --- a/tests/expectations/tests/union_fields.rs +++ b/tests/expectations/tests/union_fields.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union nsStyleUnion { pub mInt: ::std::os::raw::c_int, pub mFloat: f32, @@ -55,11 +55,6 @@ fn bindgen_test_layout_nsStyleUnion() { ) ); } -impl Clone for nsStyleUnion { - fn clone(&self) -> Self { - *self - } -} impl Default for nsStyleUnion { fn default() -> Self { unsafe { ::std::mem::zeroed() } diff --git a/tests/expectations/tests/union_with_anon_struct.rs b/tests/expectations/tests/union_with_anon_struct.rs index 320ce820bf..87bcf6f3d6 100644 --- a/tests/expectations/tests/union_with_anon_struct.rs +++ b/tests/expectations/tests/union_with_anon_struct.rs @@ -5,13 +5,13 @@ #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union foo { pub bar: foo__bindgen_ty_1, _bindgen_union_align: [u32; 2usize], } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1 { pub a: ::std::os::raw::c_uint, pub b: ::std::os::raw::c_uint, @@ -49,11 +49,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!( @@ -77,11 +72,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() } diff --git a/tests/expectations/tests/union_with_anon_struct_bitfield.rs b/tests/expectations/tests/union_with_anon_struct_bitfield.rs index d759055bf3..ef5c16707c 100644 --- a/tests/expectations/tests/union_with_anon_struct_bitfield.rs +++ b/tests/expectations/tests/union_with_anon_struct_bitfield.rs @@ -5,14 +5,14 @@ #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union foo { pub a: ::std::os::raw::c_int, pub __bindgen_anon_1: foo__bindgen_ty_1, _bindgen_union_align: u32, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct foo__bindgen_ty_1 { pub _bitfield_1: u32, pub __bindgen_align: [u32; 0usize], @@ -30,11 +30,6 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { concat!("Alignment of ", stringify!(foo__bindgen_ty_1)) ); } -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} impl foo__bindgen_ty_1 { #[inline] pub fn b(&self) -> ::std::os::raw::c_int { @@ -132,11 +127,6 @@ fn bindgen_test_layout_foo() { concat!("Alignment of field: ", stringify!(foo), "::", stringify!(a)) ); } -impl Clone for foo { - fn clone(&self) -> Self { - *self - } -} impl Default for foo { fn default() -> Self { unsafe { ::std::mem::zeroed() } diff --git a/tests/expectations/tests/union_with_anon_union.rs b/tests/expectations/tests/union_with_anon_union.rs index cb78c900bf..92f8559587 100644 --- a/tests/expectations/tests/union_with_anon_union.rs +++ b/tests/expectations/tests/union_with_anon_union.rs @@ -5,13 +5,13 @@ #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union foo { pub bar: foo__bindgen_ty_1, _bindgen_union_align: u32, } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union foo__bindgen_ty_1 { pub a: ::std::os::raw::c_uint, pub b: ::std::os::raw::c_ushort, @@ -50,11 +50,6 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { ) ); } -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} impl Default for foo__bindgen_ty_1 { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -83,11 +78,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() } diff --git a/tests/expectations/tests/union_with_anon_unnamed_struct.rs b/tests/expectations/tests/union_with_anon_unnamed_struct.rs index 8dd829e23b..1f5e493f72 100644 --- a/tests/expectations/tests/union_with_anon_unnamed_struct.rs +++ b/tests/expectations/tests/union_with_anon_unnamed_struct.rs @@ -5,14 +5,14 @@ #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union pixel { pub rgba: ::std::os::raw::c_uint, pub __bindgen_anon_1: pixel__bindgen_ty_1, _bindgen_union_align: u32, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct pixel__bindgen_ty_1 { pub r: ::std::os::raw::c_uchar, pub g: ::std::os::raw::c_uchar, @@ -72,11 +72,6 @@ fn bindgen_test_layout_pixel__bindgen_ty_1() { ) ); } -impl Clone for pixel__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} #[test] fn bindgen_test_layout_pixel() { assert_eq!( @@ -100,11 +95,6 @@ fn bindgen_test_layout_pixel() { ) ); } -impl Clone for pixel { - fn clone(&self) -> Self { - *self - } -} impl Default for pixel { fn default() -> Self { unsafe { ::std::mem::zeroed() } diff --git a/tests/expectations/tests/union_with_anon_unnamed_union.rs b/tests/expectations/tests/union_with_anon_unnamed_union.rs index dea8b39e16..ba0cf84ed8 100644 --- a/tests/expectations/tests/union_with_anon_unnamed_union.rs +++ b/tests/expectations/tests/union_with_anon_unnamed_union.rs @@ -5,14 +5,14 @@ #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union foo { pub a: ::std::os::raw::c_uint, pub __bindgen_anon_1: foo__bindgen_ty_1, _bindgen_union_align: u32, } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union foo__bindgen_ty_1 { pub b: ::std::os::raw::c_ushort, pub c: ::std::os::raw::c_uchar, @@ -51,11 +51,6 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { ) ); } -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} impl Default for foo__bindgen_ty_1 { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -79,11 +74,6 @@ fn bindgen_test_layout_foo() { concat!("Alignment of field: ", stringify!(foo), "::", stringify!(a)) ); } -impl Clone for foo { - fn clone(&self) -> Self { - *self - } -} impl Default for foo { fn default() -> Self { unsafe { ::std::mem::zeroed() } diff --git a/tests/expectations/tests/union_with_big_member.rs b/tests/expectations/tests/union_with_big_member.rs index d5d19a9bee..e0767ba273 100644 --- a/tests/expectations/tests/union_with_big_member.rs +++ b/tests/expectations/tests/union_with_big_member.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union WithBigArray { pub a: ::std::os::raw::c_int, pub b: [::std::os::raw::c_int; 33usize], @@ -44,18 +44,13 @@ fn bindgen_test_layout_WithBigArray() { ) ); } -impl Clone for WithBigArray { - fn clone(&self) -> Self { - *self - } -} impl Default for WithBigArray { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union WithBigArray2 { pub a: ::std::os::raw::c_int, pub b: [::std::os::raw::c_char; 33usize], @@ -94,18 +89,13 @@ fn bindgen_test_layout_WithBigArray2() { ) ); } -impl Clone for WithBigArray2 { - fn clone(&self) -> Self { - *self - } -} impl Default for WithBigArray2 { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union WithBigMember { pub a: ::std::os::raw::c_int, pub b: WithBigArray, @@ -144,11 +134,6 @@ fn bindgen_test_layout_WithBigMember() { ) ); } -impl Clone for WithBigMember { - fn clone(&self) -> Self { - *self - } -} impl Default for WithBigMember { 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 9b27335d11..1969a33c5c 100644 --- a/tests/expectations/tests/union_with_nesting.rs +++ b/tests/expectations/tests/union_with_nesting.rs @@ -5,20 +5,20 @@ #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union foo { pub a: ::std::os::raw::c_uint, pub __bindgen_anon_1: foo__bindgen_ty_1, _bindgen_union_align: u32, } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub struct foo__bindgen_ty_1 { pub __bindgen_anon_1: foo__bindgen_ty_1__bindgen_ty_1, pub __bindgen_anon_2: foo__bindgen_ty_1__bindgen_ty_2, } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union foo__bindgen_ty_1__bindgen_ty_1 { pub b1: ::std::os::raw::c_ushort, pub b2: ::std::os::raw::c_ushort, @@ -57,18 +57,13 @@ fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_1() { ) ); } -impl Clone for foo__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} impl Default for foo__bindgen_ty_1__bindgen_ty_1 { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union foo__bindgen_ty_1__bindgen_ty_2 { pub c1: ::std::os::raw::c_ushort, pub c2: ::std::os::raw::c_ushort, @@ -107,11 +102,6 @@ fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_2() { ) ); } -impl Clone for foo__bindgen_ty_1__bindgen_ty_2 { - fn clone(&self) -> Self { - *self - } -} impl Default for foo__bindgen_ty_1__bindgen_ty_2 { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -130,11 +120,6 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { concat!("Alignment of ", stringify!(foo__bindgen_ty_1)) ); } -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} impl Default for foo__bindgen_ty_1 { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -158,11 +143,6 @@ fn bindgen_test_layout_foo() { concat!("Alignment of field: ", stringify!(foo), "::", stringify!(a)) ); } -impl Clone for foo { - fn clone(&self) -> Self { - *self - } -} impl Default for foo { fn default() -> Self { unsafe { ::std::mem::zeroed() } diff --git a/tests/expectations/tests/unknown_attr.rs b/tests/expectations/tests/unknown_attr.rs index 5f7c1c3000..b5d83c2e29 100644 --- a/tests/expectations/tests/unknown_attr.rs +++ b/tests/expectations/tests/unknown_attr.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct max_align_t { pub __clang_max_align_nonce1: ::std::os::raw::c_longlong, pub __bindgen_padding_0: u64, @@ -40,8 +40,3 @@ fn bindgen_test_layout_max_align_t() { ) ); } -impl Clone for max_align_t { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/use-core.rs b/tests/expectations/tests/use-core.rs index 093c4a8345..ebbfb9358c 100644 --- a/tests/expectations/tests/use-core.rs +++ b/tests/expectations/tests/use-core.rs @@ -6,7 +6,7 @@ extern crate core; #[repr(C)] -#[derive(Debug, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct foo { pub a: ::std::os::raw::c_int, pub b: ::std::os::raw::c_int, @@ -45,18 +45,13 @@ fn bindgen_test_layout_foo() { ) ); } -impl Clone for foo { - fn clone(&self) -> Self { - *self - } -} impl Default for foo { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } #[repr(C)] -#[derive(Copy)] +#[derive(Copy, Clone)] pub union _bindgen_ty_1 { pub bar: ::std::os::raw::c_int, pub baz: ::std::os::raw::c_long, @@ -95,11 +90,6 @@ fn bindgen_test_layout__bindgen_ty_1() { ) ); } -impl Clone for _bindgen_ty_1 { - fn clone(&self) -> Self { - *self - } -} impl Default for _bindgen_ty_1 { fn default() -> Self { unsafe { ::core::mem::zeroed() } diff --git a/tests/expectations/tests/var-tracing.rs b/tests/expectations/tests/var-tracing.rs index 5042f3f784..d99526c7a7 100644 --- a/tests/expectations/tests/var-tracing.rs +++ b/tests/expectations/tests/var-tracing.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Bar { pub m_baz: ::std::os::raw::c_int, } @@ -36,11 +36,6 @@ 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 - } -} impl Bar { #[inline] pub unsafe fn new(baz: ::std::os::raw::c_int) -> Self { @@ -50,7 +45,7 @@ impl Bar { } } #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Baz { pub _address: u8, } @@ -71,8 +66,3 @@ fn bindgen_test_layout_Baz() { concat!("Alignment of ", stringify!(Baz)) ); } -impl Clone for Baz { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/variadic-method.rs b/tests/expectations/tests/variadic-method.rs index 6b3f70b3ce..94dd73bee0 100644 --- a/tests/expectations/tests/variadic-method.rs +++ b/tests/expectations/tests/variadic-method.rs @@ -9,7 +9,7 @@ extern "C" { pub fn foo(fmt: *const ::std::os::raw::c_char, ...); } #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Bar { pub _address: u8, } @@ -30,8 +30,3 @@ 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 - } -} diff --git a/tests/expectations/tests/vector.rs b/tests/expectations/tests/vector.rs index 87096aa9e4..c75e9829c9 100644 --- a/tests/expectations/tests/vector.rs +++ b/tests/expectations/tests/vector.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct foo { pub mMember: [::std::os::raw::c_longlong; 1usize], } @@ -32,8 +32,3 @@ fn bindgen_test_layout_foo() { ) ); } -impl Clone for foo { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/virtual_inheritance.rs b/tests/expectations/tests/virtual_inheritance.rs index 40e5859f55..c4f7abfa98 100644 --- a/tests/expectations/tests/virtual_inheritance.rs +++ b/tests/expectations/tests/virtual_inheritance.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct A { pub foo: ::std::os::raw::c_int, } @@ -27,15 +27,10 @@ fn bindgen_test_layout_A() { concat!("Alignment of field: ", stringify!(A), "::", stringify!(foo)) ); } -impl Clone for A { - fn clone(&self) -> Self { - *self - } -} #[repr(C)] pub struct B__bindgen_vtable(::std::os::raw::c_void); #[repr(C)] -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Clone)] pub struct B { pub vtable_: *const B__bindgen_vtable, pub bar: ::std::os::raw::c_int, @@ -58,11 +53,6 @@ fn bindgen_test_layout_B() { concat!("Alignment of field: ", stringify!(B), "::", stringify!(bar)) ); } -impl Clone for B { - fn clone(&self) -> Self { - *self - } -} impl Default for B { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -71,7 +61,7 @@ impl Default for B { #[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 baz: ::std::os::raw::c_int, @@ -94,18 +84,13 @@ fn bindgen_test_layout_C() { concat!("Alignment of field: ", stringify!(C), "::", stringify!(baz)) ); } -impl Clone for C { - fn clone(&self) -> Self { - *self - } -} impl Default for C { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Clone)] pub struct D { pub _base: C, pub _base_1: B, @@ -124,11 +109,6 @@ fn bindgen_test_layout_D() { concat!("Alignment of ", stringify!(D)) ); } -impl Clone for D { - fn clone(&self) -> Self { - *self - } -} impl Default for D { fn default() -> Self { unsafe { ::std::mem::zeroed() } diff --git a/tests/expectations/tests/virtual_overloaded.rs b/tests/expectations/tests/virtual_overloaded.rs index 949fb38634..376bae8a84 100644 --- a/tests/expectations/tests/virtual_overloaded.rs +++ b/tests/expectations/tests/virtual_overloaded.rs @@ -7,7 +7,7 @@ #[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, } @@ -24,11 +24,6 @@ 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() } diff --git a/tests/expectations/tests/vtable_recursive_sig.rs b/tests/expectations/tests/vtable_recursive_sig.rs index 0f35890c5f..f0720f2735 100644 --- a/tests/expectations/tests/vtable_recursive_sig.rs +++ b/tests/expectations/tests/vtable_recursive_sig.rs @@ -7,7 +7,7 @@ #[repr(C)] pub struct Base__bindgen_vtable(::std::os::raw::c_void); #[repr(C)] -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Clone)] pub struct Base { pub vtable_: *const Base__bindgen_vtable, } @@ -24,11 +24,6 @@ fn bindgen_test_layout_Base() { concat!("Alignment of ", stringify!(Base)) ); } -impl Clone for Base { - fn clone(&self) -> Self { - *self - } -} impl Default for Base { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -39,7 +34,7 @@ extern "C" { pub fn Base_AsDerived(this: *mut ::std::os::raw::c_void) -> *mut Derived; } #[repr(C)] -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Clone)] pub struct Derived { pub _base: Base, } @@ -56,11 +51,6 @@ fn bindgen_test_layout_Derived() { concat!("Alignment of ", stringify!(Derived)) ); } -impl Clone for Derived { - fn clone(&self) -> Self { - *self - } -} impl Default for Derived { fn default() -> Self { unsafe { ::std::mem::zeroed() } diff --git a/tests/expectations/tests/weird_bitfields.rs b/tests/expectations/tests/weird_bitfields.rs index 7a0b18c958..ac73b70966 100644 --- a/tests/expectations/tests/weird_bitfields.rs +++ b/tests/expectations/tests/weird_bitfields.rs @@ -12,7 +12,7 @@ pub enum nsStyleSVGOpacitySource { eStyleSVGOpacitySource_ContextStrokeOpacity = 2, } #[repr(C)] -#[derive(Debug, Copy)] +#[derive(Debug, Copy, Clone)] pub struct Weird { pub mStrokeDasharrayLength: ::std::os::raw::c_uint, pub _bitfield_1: [u16; 2usize], @@ -163,11 +163,6 @@ fn bindgen_test_layout_Weird() { ) ); } -impl Clone for Weird { - fn clone(&self) -> Self { - *self - } -} impl Default for Weird { 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 49dc9960e9..d0e4c689c7 100644 --- a/tests/expectations/tests/what_is_going_on.rs +++ b/tests/expectations/tests/what_is_going_on.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct UnknownUnits { pub _address: u8, } @@ -22,11 +22,6 @@ fn bindgen_test_layout_UnknownUnits() { concat!("Alignment of ", stringify!(UnknownUnits)) ); } -impl Clone for UnknownUnits { - fn clone(&self) -> Self { - *self - } -} pub type Float = f32; #[repr(C)] #[derive(Debug, Copy, Clone)] diff --git a/tests/expectations/tests/whitelist-namespaces-basic.rs b/tests/expectations/tests/whitelist-namespaces-basic.rs index 316ed44d07..74c782f77c 100644 --- a/tests/expectations/tests/whitelist-namespaces-basic.rs +++ b/tests/expectations/tests/whitelist-namespaces-basic.rs @@ -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 Helper { pub _address: u8, } @@ -32,11 +32,6 @@ pub mod root { concat!("Alignment of ", stringify!(Helper)) ); } - impl Clone for Helper { - fn clone(&self) -> Self { - *self - } - } } } } diff --git a/tests/expectations/tests/whitelist-namespaces.rs b/tests/expectations/tests/whitelist-namespaces.rs index 01dce09a0c..f1c86bde36 100644 --- a/tests/expectations/tests/whitelist-namespaces.rs +++ b/tests/expectations/tests/whitelist-namespaces.rs @@ -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 Helper { pub _address: u8, } @@ -32,14 +32,9 @@ pub mod root { concat!("Alignment of ", stringify!(Helper)) ); } - impl Clone for Helper { - fn clone(&self) -> Self { - *self - } - } } #[repr(C)] - #[derive(Debug, Default, Copy)] + #[derive(Debug, Default, Copy, Clone)] pub struct Test { pub helper: root::outer::inner::Helper, } @@ -66,10 +61,5 @@ pub mod root { ) ); } - impl Clone for Test { - fn clone(&self) -> Self { - *self - } - } } } diff --git a/tests/expectations/tests/whitelisted-item-references-no-partialeq.rs b/tests/expectations/tests/whitelisted-item-references-no-partialeq.rs index a7bbab74a1..32604b12ff 100644 --- a/tests/expectations/tests/whitelisted-item-references-no-partialeq.rs +++ b/tests/expectations/tests/whitelisted-item-references-no-partialeq.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct NoPartialEq { pub _address: u8, } @@ -22,13 +22,8 @@ fn bindgen_test_layout_NoPartialEq() { concat!("Alignment of ", stringify!(NoPartialEq)) ); } -impl Clone for NoPartialEq { - fn clone(&self) -> Self { - *self - } -} #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct WhitelistMe { pub a: NoPartialEq, } @@ -55,8 +50,3 @@ fn bindgen_test_layout_WhitelistMe() { ) ); } -impl Clone for WhitelistMe { - fn clone(&self) -> Self { - *self - } -} diff --git a/tests/expectations/tests/win32-thiscall_nightly.rs b/tests/expectations/tests/win32-thiscall_nightly.rs index 0fd1c00ddc..3b0140dcbf 100644 --- a/tests/expectations/tests/win32-thiscall_nightly.rs +++ b/tests/expectations/tests/win32-thiscall_nightly.rs @@ -6,7 +6,7 @@ #![feature(abi_thiscall)] #[repr(C)] -#[derive(Debug, Default, Copy)] +#[derive(Debug, Default, Copy, Clone)] pub struct Foo { pub _address: u8, } @@ -31,11 +31,6 @@ extern "thiscall" { #[link_name = "\u{1}?test2@Foo@@QAEHH@Z"] pub fn Foo_test2(this: *mut Foo, var: ::std::os::raw::c_int) -> ::std::os::raw::c_int; } -impl Clone for Foo { - fn clone(&self) -> Self { - *self - } -} impl Foo { #[inline] pub unsafe fn test(&mut self) { diff --git a/tests/headers/derive-clone.h b/tests/headers/derive-clone.h new file mode 100644 index 0000000000..a84d35cdd2 --- /dev/null +++ b/tests/headers/derive-clone.h @@ -0,0 +1,5 @@ + +/// This struct should derive `Clone`. +struct ShouldDeriveClone { + int large[33]; +}; diff --git a/tests/headers/derive-clone_1_0.h b/tests/headers/derive-clone_1_0.h new file mode 100644 index 0000000000..34ef40ae97 --- /dev/null +++ b/tests/headers/derive-clone_1_0.h @@ -0,0 +1,7 @@ +// bindgen-flags: --rust-target 1.0 + +/// Since builtin `Clone` impls were introduced in Rust 1.21 this struct +/// should impl `Clone` "manually". +struct ShouldImplClone { + int large[33]; +};