Skip to content

Commit ec85170

Browse files
honggoffemilio
authored andcommitted
Do not generate implementation for clone for FAM
Flexible array members are represented in the generated binding by a struct __IncompleteArrayField<T>. Since such members do not contain any information about how big they are, it is impossible to automatically clone or copy them, either in C or rust. Fixes #1431.
1 parent 79b2b10 commit ec85170

17 files changed

+0
-106
lines changed

src/codegen/mod.rs

-10
Original file line numberDiff line numberDiff line change
@@ -3883,20 +3883,10 @@ mod utils {
38833883
}
38843884
};
38853885

3886-
let incomplete_array_clone_impl = quote! {
3887-
impl<T> ::#prefix::clone::Clone for __IncompleteArrayField<T> {
3888-
#[inline]
3889-
fn clone(&self) -> Self {
3890-
Self::new()
3891-
}
3892-
}
3893-
};
3894-
38953886
let items = vec![
38963887
incomplete_array_decl,
38973888
incomplete_array_impl,
38983889
incomplete_array_debug_impl,
3899-
incomplete_array_clone_impl,
39003890
];
39013891

39023892
let old_items = mem::replace(result, items);

tests/expectations/tests/class.rs

-6
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
3737
fmt.write_str("__IncompleteArrayField")
3838
}
3939
}
40-
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
41-
#[inline]
42-
fn clone(&self) -> Self {
43-
Self::new()
44-
}
45-
}
4640
#[repr(C)]
4741
#[derive(Copy, Clone)]
4842
pub struct C {

tests/expectations/tests/class_1_0.rs

-6
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
3737
fmt.write_str("__IncompleteArrayField")
3838
}
3939
}
40-
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
41-
#[inline]
42-
fn clone(&self) -> Self {
43-
Self::new()
44-
}
45-
}
4640
#[repr(C)]
4741
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
4842
impl<T> __BindgenUnionField<T> {

tests/expectations/tests/derive-hash-struct-with-incomplete-array.rs

-6
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
3737
fmt.write_str("__IncompleteArrayField")
3838
}
3939
}
40-
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
41-
#[inline]
42-
fn clone(&self) -> Self {
43-
Self::new()
44-
}
45-
}
4640
#[repr(C)]
4741
#[derive(Debug, Default)]
4842
pub struct test {

tests/expectations/tests/incomplete-array-padding.rs

-6
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
124124
fmt.write_str("__IncompleteArrayField")
125125
}
126126
}
127-
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
128-
#[inline]
129-
fn clone(&self) -> Self {
130-
Self::new()
131-
}
132-
}
133127
#[repr(C)]
134128
#[derive(Debug)]
135129
pub struct foo {

tests/expectations/tests/issue-643-inner-struct.rs

-6
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
3737
fmt.write_str("__IncompleteArrayField")
3838
}
3939
}
40-
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
41-
#[inline]
42-
fn clone(&self) -> Self {
43-
Self::new()
44-
}
45-
}
4640
#[repr(C)]
4741
#[derive(Debug)]
4842
pub struct rte_ring {

tests/expectations/tests/layout_align.rs

-6
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
124124
fmt.write_str("__IncompleteArrayField")
125125
}
126126
}
127-
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
128-
#[inline]
129-
fn clone(&self) -> Self {
130-
Self::new()
131-
}
132-
}
133127
#[repr(C)]
134128
#[derive(Debug)]
135129
pub struct rte_kni_fifo {

tests/expectations/tests/layout_large_align_field.rs

-6
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
3737
fmt.write_str("__IncompleteArrayField")
3838
}
3939
}
40-
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
41-
#[inline]
42-
fn clone(&self) -> Self {
43-
Self::new()
44-
}
45-
}
4640
pub const RTE_CACHE_LINE_SIZE: u32 = 64;
4741
pub const RTE_LIBRTE_IP_FRAG_MAX_FRAG: u32 = 4;
4842
pub const IP_LAST_FRAG_IDX: _bindgen_ty_1 = _bindgen_ty_1::IP_LAST_FRAG_IDX;

tests/expectations/tests/libclang-9/class.rs

-6
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
3737
fmt.write_str("__IncompleteArrayField")
3838
}
3939
}
40-
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
41-
#[inline]
42-
fn clone(&self) -> Self {
43-
Self::new()
44-
}
45-
}
4640
#[repr(C)]
4741
#[derive(Copy, Clone)]
4842
pub struct C {

tests/expectations/tests/libclang-9/class_1_0.rs

-6
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
3737
fmt.write_str("__IncompleteArrayField")
3838
}
3939
}
40-
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
41-
#[inline]
42-
fn clone(&self) -> Self {
43-
Self::new()
44-
}
45-
}
4640
#[repr(C)]
4741
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
4842
impl<T> __BindgenUnionField<T> {

tests/expectations/tests/libclang-9/derive-hash-struct-with-incomplete-array.rs

-6
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
3737
fmt.write_str("__IncompleteArrayField")
3838
}
3939
}
40-
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
41-
#[inline]
42-
fn clone(&self) -> Self {
43-
Self::new()
44-
}
45-
}
4640
#[repr(C)]
4741
#[derive(Debug, Default)]
4842
pub struct test {

tests/expectations/tests/libclang-9/incomplete-array-padding.rs

-6
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
118118
fmt.write_str("__IncompleteArrayField")
119119
}
120120
}
121-
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
122-
#[inline]
123-
fn clone(&self) -> Self {
124-
Self::new()
125-
}
126-
}
127121
#[repr(C)]
128122
#[derive(Debug)]
129123
pub struct foo {

tests/expectations/tests/libclang-9/issue-643-inner-struct.rs

-6
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
3737
fmt.write_str("__IncompleteArrayField")
3838
}
3939
}
40-
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
41-
#[inline]
42-
fn clone(&self) -> Self {
43-
Self::new()
44-
}
45-
}
4640
#[repr(C)]
4741
#[derive(Debug)]
4842
pub struct rte_ring {

tests/expectations/tests/libclang-9/layout_align.rs

-6
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
118118
fmt.write_str("__IncompleteArrayField")
119119
}
120120
}
121-
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
122-
#[inline]
123-
fn clone(&self) -> Self {
124-
Self::new()
125-
}
126-
}
127121
#[repr(C)]
128122
#[derive(Debug)]
129123
pub struct rte_kni_fifo {

tests/expectations/tests/libclang-9/zero-sized-array.rs

-6
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
3737
fmt.write_str("__IncompleteArrayField")
3838
}
3939
}
40-
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
41-
#[inline]
42-
fn clone(&self) -> Self {
43-
Self::new()
44-
}
45-
}
4640
/// Bizarrely enough, this should *not* get an `_address` field.
4741
#[repr(C)]
4842
#[derive(Debug, Default)]

tests/expectations/tests/zero-size-array-align.rs

-6
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
3737
fmt.write_str("__IncompleteArrayField")
3838
}
3939
}
40-
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
41-
#[inline]
42-
fn clone(&self) -> Self {
43-
Self::new()
44-
}
45-
}
4640
#[repr(C)]
4741
#[derive(Debug, Default)]
4842
pub struct dm_deps {

tests/expectations/tests/zero-sized-array.rs

-6
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
3737
fmt.write_str("__IncompleteArrayField")
3838
}
3939
}
40-
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
41-
#[inline]
42-
fn clone(&self) -> Self {
43-
Self::new()
44-
}
45-
}
4640
/// Bizarrely enough, this should *not* get an `_address` field.
4741
#[repr(C)]
4842
#[derive(Debug, Default)]

0 commit comments

Comments
 (0)