rust-lang / rust-lang/rust-bindgen

Consider using field names for anonymous types/unions

Open
#2,759 2 comments 1 reaction 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

While they have a good chance of avoiding namespace collisions, numbered anonymous types are decidedly not very readable.

image

It would be nice if bindgen could use the field name instead when naming the anonymous type. In the above example, hwloc_bridge_attr_s__bindgen_ty_1 would become hwloc_bridge_attr_s__upstream and hwloc_bridge_attr_s__bindgen_ty_2 would become hwloc_bridge_attr_s__downstream.

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

No source file or test is named. Start by locating bindgen's handling of anonymous types and unions, then compare generated bindings with the issue's hwloc_bridge_attr_s example. Done means the anonymous types use field-based names such as __upstream and __downstream while still avoiding namespace collisions.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.