rust-lang / rust-lang/rust-bindgen

`--with-derive-custom-struct` doesn't apply to `__BindgenBitfieldUnit`

Open
#3,196 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Invoking bindgen with --with-derive-custom-struct .*=Foo does not add #[derive(Foo)] to __BindgenBitfieldUnit.

I'd like all structs (& unions) to be marked with the derive macro, as it only implements the trait when all fields also implement it.

My current solution is to just manually implement the trait for __BindgenBitfieldUnit, which is fine, but not stable when you decide to rework how bitfields are represented.

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

Start by tracing how --with-derive-custom-struct .*=Foo is applied to generated structs, then inspect generation of __BindgenBitfieldUnit. Add a regression test covering this bitfield type and verify that the requested derive appears on it; done means the custom derive applies consistently to the generated unit.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.