rust-lang / rust-lang/rust-bindgen

Should not derive Debug, Copy, Clone for struct without definition

Open
#1,969 0 comments 0 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
typedef struct foo bar;
Bindgen Invocation
$ bindgen input.h 
Actual Results
/* automatically generated by rust-bindgen 0.56.0 */

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct foo {
    _unused: [u8; 0],
}
pub type bar = foo;
Expected Results

Debug, Copy, Clone should not be derived if bindgen does not know the true size or layout of struct foo and is just using a placeholder. Obviously I can use no_copy, no_debug, no_defaultto suppress it, but bindgen should never derive these traits on such a struct no matter how these flags are set.

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 reported input.h and bindgen invocation first, then inspect the code path that emits derives for placeholder structs. Done means generated bindings for typedef struct foo bar; omit Debug, Copy, and Clone while preserving the placeholder and alias behavior.

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.