summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ir/ty.rs3
-rw-r--r--tests/expectations/tests/class.rs16
-rw-r--r--tests/expectations/tests/issue-643-inner-struct.rs5
-rw-r--r--tests/expectations/tests/layout.rs5
-rw-r--r--tests/expectations/tests/layout_align.rs5
-rw-r--r--tests/expectations/tests/layout_large_align_field.rs4
-rw-r--r--tests/expectations/tests/layout_mbuf.rs4
7 files changed, 5 insertions, 37 deletions
diff --git a/src/ir/ty.rs b/src/ir/ty.rs
index b53e27bf..13b5f2ee 100644
--- a/src/ir/ty.rs
+++ b/src/ir/ty.rs
@@ -531,7 +531,8 @@ impl<'a> CanDeriveCopy<'a> for Type {
fn can_derive_copy(&self, ctx: &BindgenContext, item: &Item) -> bool {
match self.kind {
- TypeKind::Array(t, _) => {
+ TypeKind::Array(t, len) => {
+ len > 0 &&
t.can_derive_copy_in_array(ctx, ())
}
TypeKind::ResolvedTypeRef(t) |
diff --git a/tests/expectations/tests/class.rs b/tests/expectations/tests/class.rs
index 413c033a..26e6a62c 100644
--- a/tests/expectations/tests/class.rs
+++ b/tests/expectations/tests/class.rs
@@ -90,7 +90,6 @@ impl Default for C {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
-#[derive(Copy)]
pub struct C_with_zero_length_array {
pub a: ::std::os::raw::c_int,
pub big_array: [::std::os::raw::c_char; 33usize],
@@ -123,14 +122,10 @@ fn bindgen_test_layout_C_with_zero_length_array() {
C_with_zero_length_array ) , "::" , stringify ! (
zero_length_array ) ));
}
-impl Clone for C_with_zero_length_array {
- fn clone(&self) -> Self { *self }
-}
impl Default for C_with_zero_length_array {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
-#[derive(Copy)]
pub struct C_with_incomplete_array {
pub a: ::std::os::raw::c_int,
pub big_array: [::std::os::raw::c_char; 33usize],
@@ -145,14 +140,10 @@ fn bindgen_test_layout_C_with_incomplete_array() {
concat ! (
"Alignment of " , stringify ! ( C_with_incomplete_array ) ));
}
-impl Clone for C_with_incomplete_array {
- fn clone(&self) -> Self { *self }
-}
impl Default for C_with_incomplete_array {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
-#[derive(Copy)]
pub struct C_with_zero_length_array_and_incomplete_array {
pub a: ::std::os::raw::c_int,
pub big_array: [::std::os::raw::c_char; 33usize],
@@ -170,9 +161,6 @@ fn bindgen_test_layout_C_with_zero_length_array_and_incomplete_array() {
"Alignment of " , stringify ! (
C_with_zero_length_array_and_incomplete_array ) ));
}
-impl Clone for C_with_zero_length_array_and_incomplete_array {
- fn clone(&self) -> Self { *self }
-}
impl Default for C_with_zero_length_array_and_incomplete_array {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
@@ -194,7 +182,6 @@ fn bindgen_test_layout_WithDtor() {
stringify ! ( b ) ));
}
#[repr(C)]
-#[derive(Copy)]
pub struct IncompleteArrayNonCopiable {
pub whatever: *mut ::std::os::raw::c_void,
pub incomplete_array: __IncompleteArrayField<C>,
@@ -209,9 +196,6 @@ fn bindgen_test_layout_IncompleteArrayNonCopiable() {
"Alignment of " , stringify ! ( IncompleteArrayNonCopiable )
));
}
-impl Clone for IncompleteArrayNonCopiable {
- fn clone(&self) -> Self { *self }
-}
impl Default for IncompleteArrayNonCopiable {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
diff --git a/tests/expectations/tests/issue-643-inner-struct.rs b/tests/expectations/tests/issue-643-inner-struct.rs
index a2225003..82be5c92 100644
--- a/tests/expectations/tests/issue-643-inner-struct.rs
+++ b/tests/expectations/tests/issue-643-inner-struct.rs
@@ -38,7 +38,7 @@ impl <T> ::std::clone::Clone for __IncompleteArrayField<T> {
}
impl <T> ::std::marker::Copy for __IncompleteArrayField<T> { }
#[repr(C)]
-#[derive(Debug, Copy)]
+#[derive(Debug)]
pub struct rte_ring {
pub memzone: *mut rte_memzone,
pub prod: rte_ring_prod,
@@ -92,9 +92,6 @@ fn bindgen_test_layout_rte_ring() {
assert_eq! (::std::mem::align_of::<rte_ring>() , 8usize , concat ! (
"Alignment of " , stringify ! ( rte_ring ) ));
}
-impl Clone for rte_ring {
- fn clone(&self) -> Self { *self }
-}
impl Default for rte_ring {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
diff --git a/tests/expectations/tests/layout.rs b/tests/expectations/tests/layout.rs
index c3673cb1..28ebdc76 100644
--- a/tests/expectations/tests/layout.rs
+++ b/tests/expectations/tests/layout.rs
@@ -38,7 +38,7 @@ impl <T> ::std::clone::Clone for __IncompleteArrayField<T> {
}
impl <T> ::std::marker::Copy for __IncompleteArrayField<T> { }
#[repr(C, packed)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default)]
pub struct header {
pub proto: ::std::os::raw::c_char,
pub size: ::std::os::raw::c_uint,
@@ -50,6 +50,3 @@ fn bindgen_test_layout_header() {
assert_eq!(::std::mem::size_of::<header>() , 16usize , concat ! (
"Size of: " , stringify ! ( header ) ));
}
-impl Clone for header {
- fn clone(&self) -> Self { *self }
-}
diff --git a/tests/expectations/tests/layout_align.rs b/tests/expectations/tests/layout_align.rs
index c2548938..102f1785 100644
--- a/tests/expectations/tests/layout_align.rs
+++ b/tests/expectations/tests/layout_align.rs
@@ -38,7 +38,7 @@ impl <T> ::std::clone::Clone for __IncompleteArrayField<T> {
}
impl <T> ::std::marker::Copy for __IncompleteArrayField<T> { }
#[repr(C)]
-#[derive(Debug, Copy)]
+#[derive(Debug)]
pub struct rte_kni_fifo {
/// < Next position to be written
pub write: ::std::os::raw::c_uint,
@@ -59,9 +59,6 @@ fn bindgen_test_layout_rte_kni_fifo() {
assert_eq! (::std::mem::align_of::<rte_kni_fifo>() , 8usize , concat ! (
"Alignment of " , stringify ! ( rte_kni_fifo ) ));
}
-impl Clone for rte_kni_fifo {
- fn clone(&self) -> Self { *self }
-}
impl Default for rte_kni_fifo {
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 6649f10d..0d86acda 100644
--- a/tests/expectations/tests/layout_large_align_field.rs
+++ b/tests/expectations/tests/layout_large_align_field.rs
@@ -317,7 +317,6 @@ impl Default for ip_frag_tbl_stat {
}
/// fragmentation table
#[repr(C)]
-#[derive(Copy)]
pub struct rte_ip_frag_tbl {
/// < ttl for table entries.
pub max_cycles: u64,
@@ -403,9 +402,6 @@ fn bindgen_test_layout_rte_ip_frag_tbl() {
"Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) ,
"::" , stringify ! ( pkt ) ));
}
-impl Clone for rte_ip_frag_tbl {
- fn clone(&self) -> Self { *self }
-}
impl Default for rte_ip_frag_tbl {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
diff --git a/tests/expectations/tests/layout_mbuf.rs b/tests/expectations/tests/layout_mbuf.rs
index 2b614c6d..77198c35 100644
--- a/tests/expectations/tests/layout_mbuf.rs
+++ b/tests/expectations/tests/layout_mbuf.rs
@@ -58,7 +58,6 @@ impl Clone for rte_atomic16_t {
}
/// The generic rte_mbuf, containing a packet mbuf.
#[repr(C)]
-#[derive(Copy)]
pub struct rte_mbuf {
pub cacheline0: MARKER,
/// < Virtual address of segment buffer.
@@ -1078,9 +1077,6 @@ fn bindgen_test_layout_rte_mbuf() {
"Alignment of field: " , stringify ! ( rte_mbuf ) , "::" ,
stringify ! ( timesync ) ));
}
-impl Clone for rte_mbuf {
- fn clone(&self) -> Self { *self }
-}
impl Default for rte_mbuf {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}