rust-lang / rust-lang/rust-bindgen
Use field name instead of bindgen_ty_1
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
Hi!
This is related to #1971 but not exactly the same. In my case, the unions and structs are named by their field, so it would be nice if bindgen could make use of that name.
Since I saw that the other issue was "help wanted" I spend some time trying to figure it out, but with all complex type parsing code I couldn't understand how to link the resolved type to the field name.
Input C/C++ Header
struct snd_ctl_event {
int type;
union {
struct {
unsigned int mask;
struct snd_ctl_elem_id id;
} elem;
unsigned char data8[60];
} data;
};
Actual Results
pub struct snd_ctl_event__bindgen_ty_1__bindgen_ty_1 {
pub mask: c_uint,
pub id: snd_ctl_elem_id,
}
pub union snd_ctl_event__bindgen_ty_1 {
pub elem: snd_ctl_event__bindgen_ty_1__bindgen_ty_1,
pub data8: [c_uchar; 60],
// some fields omitted
}
// etc
Expected Results
pub struct snd_ctl_event__data__elem {
pub mask: c_uint,
pub id: snd_ctl_elem_id,
}
pub union snd_ctl_event__data {
pub elem: snd_ctl_event__data__elem,
pub data8: [c_uchar; 60],
// some fields omitted
}
// etc
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with bindgen's complex type parsing code and compare this issue with related issue #1971. Trace how anonymous unions and structs are linked to their fields; done means generated names use the field path, such as snd_ctl_event__data and snd_ctl_event__data__elem, instead of bindgen_ty_1.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100