Skip to content

Commit

Permalink
Do not generate implementation for clone for FAM
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
honggoff authored and emilio committed Nov 3, 2019
1 parent 79b2b10 commit ec85170
Show file tree
Hide file tree
Showing 17 changed files with 0 additions and 106 deletions.
10 changes: 0 additions & 10 deletions src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3883,20 +3883,10 @@ mod utils {
}
};

let incomplete_array_clone_impl = quote! {
impl<T> ::#prefix::clone::Clone for __IncompleteArrayField<T> {
#[inline]
fn clone(&self) -> Self {
Self::new()
}
}
};

let items = vec![
incomplete_array_decl,
incomplete_array_impl,
incomplete_array_debug_impl,
incomplete_array_clone_impl,
];

let old_items = mem::replace(result, items);
Expand Down
6 changes: 0 additions & 6 deletions tests/expectations/tests/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
fmt.write_str("__IncompleteArrayField")
}
}
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
#[inline]
fn clone(&self) -> Self {
Self::new()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct C {
Expand Down
6 changes: 0 additions & 6 deletions tests/expectations/tests/class_1_0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
fmt.write_str("__IncompleteArrayField")
}
}
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
#[inline]
fn clone(&self) -> Self {
Self::new()
}
}
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl<T> __BindgenUnionField<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
fmt.write_str("__IncompleteArrayField")
}
}
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
#[inline]
fn clone(&self) -> Self {
Self::new()
}
}
#[repr(C)]
#[derive(Debug, Default)]
pub struct test {
Expand Down
6 changes: 0 additions & 6 deletions tests/expectations/tests/incomplete-array-padding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
fmt.write_str("__IncompleteArrayField")
}
}
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
#[inline]
fn clone(&self) -> Self {
Self::new()
}
}
#[repr(C)]
#[derive(Debug)]
pub struct foo {
Expand Down
6 changes: 0 additions & 6 deletions tests/expectations/tests/issue-643-inner-struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
fmt.write_str("__IncompleteArrayField")
}
}
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
#[inline]
fn clone(&self) -> Self {
Self::new()
}
}
#[repr(C)]
#[derive(Debug)]
pub struct rte_ring {
Expand Down
6 changes: 0 additions & 6 deletions tests/expectations/tests/layout_align.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
fmt.write_str("__IncompleteArrayField")
}
}
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
#[inline]
fn clone(&self) -> Self {
Self::new()
}
}
#[repr(C)]
#[derive(Debug)]
pub struct rte_kni_fifo {
Expand Down
6 changes: 0 additions & 6 deletions tests/expectations/tests/layout_large_align_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
fmt.write_str("__IncompleteArrayField")
}
}
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
#[inline]
fn clone(&self) -> Self {
Self::new()
}
}
pub const RTE_CACHE_LINE_SIZE: u32 = 64;
pub const RTE_LIBRTE_IP_FRAG_MAX_FRAG: u32 = 4;
pub const IP_LAST_FRAG_IDX: _bindgen_ty_1 = _bindgen_ty_1::IP_LAST_FRAG_IDX;
Expand Down
6 changes: 0 additions & 6 deletions tests/expectations/tests/libclang-9/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
fmt.write_str("__IncompleteArrayField")
}
}
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
#[inline]
fn clone(&self) -> Self {
Self::new()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct C {
Expand Down
6 changes: 0 additions & 6 deletions tests/expectations/tests/libclang-9/class_1_0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
fmt.write_str("__IncompleteArrayField")
}
}
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
#[inline]
fn clone(&self) -> Self {
Self::new()
}
}
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl<T> __BindgenUnionField<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
fmt.write_str("__IncompleteArrayField")
}
}
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
#[inline]
fn clone(&self) -> Self {
Self::new()
}
}
#[repr(C)]
#[derive(Debug, Default)]
pub struct test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
fmt.write_str("__IncompleteArrayField")
}
}
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
#[inline]
fn clone(&self) -> Self {
Self::new()
}
}
#[repr(C)]
#[derive(Debug)]
pub struct foo {
Expand Down
6 changes: 0 additions & 6 deletions tests/expectations/tests/libclang-9/issue-643-inner-struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
fmt.write_str("__IncompleteArrayField")
}
}
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
#[inline]
fn clone(&self) -> Self {
Self::new()
}
}
#[repr(C)]
#[derive(Debug)]
pub struct rte_ring {
Expand Down
6 changes: 0 additions & 6 deletions tests/expectations/tests/libclang-9/layout_align.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
fmt.write_str("__IncompleteArrayField")
}
}
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
#[inline]
fn clone(&self) -> Self {
Self::new()
}
}
#[repr(C)]
#[derive(Debug)]
pub struct rte_kni_fifo {
Expand Down
6 changes: 0 additions & 6 deletions tests/expectations/tests/libclang-9/zero-sized-array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
fmt.write_str("__IncompleteArrayField")
}
}
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
#[inline]
fn clone(&self) -> Self {
Self::new()
}
}
/// Bizarrely enough, this should *not* get an `_address` field.
#[repr(C)]
#[derive(Debug, Default)]
Expand Down
6 changes: 0 additions & 6 deletions tests/expectations/tests/zero-size-array-align.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
fmt.write_str("__IncompleteArrayField")
}
}
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
#[inline]
fn clone(&self) -> Self {
Self::new()
}
}
#[repr(C)]
#[derive(Debug, Default)]
pub struct dm_deps {
Expand Down
6 changes: 0 additions & 6 deletions tests/expectations/tests/zero-sized-array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
fmt.write_str("__IncompleteArrayField")
}
}
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
#[inline]
fn clone(&self) -> Self {
Self::new()
}
}
/// Bizarrely enough, this should *not* get an `_address` field.
#[repr(C)]
#[derive(Debug, Default)]
Expand Down

0 comments on commit ec85170

Please sign in to comment.