rust-lang / rust-lang/rust-bindgen

`no-copy` flag unexpectedly removes `Clone` derive as well

Open
#2,458 6 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
5.3k
Forks
829
Avg merge
1d 1h
Merged PRs (30d)
15

Description

Input C/C++ Header
struct Bytes {
    char bytes[1024];
};
Bindgen Invocation
$ bindgen input.h --no-copy Bytes
Actual Results
/* automatically generated by rust-bindgen 0.64.0 */

#[repr(C)]
#[derive(Debug)]
pub struct Bytes {
    pub bytes: [::std::os::raw::c_char; 1024usize],
}
Expected Results

By default bindgen adds Copy and Clone derives. Using --no-copy should only remove the Copy derivation. Types like these are too big to be Copy but are ok to be explicitly Cloned. TLDR:

/* automatically generated by rust-bindgen 0.64.0 */

#[repr(C)]
#[derive(Debug, Clone)]
pub struct Bytes {
    pub bytes: [::std::os::raw::c_char; 1024usize],
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the shown C++ header and bindgen input.h --no-copy Bytes invocation, then trace how derives are selected for the generated Bytes type. Done means --no-copy removes Copy while retaining Clone, producing the expected derives.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.