rust-lang / rust-lang/rust-bindgen

Compute padding outside of codegen

Open
#959 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-bitfields A-derive E-less-easy enhancement
Dominant language
Rust
Stars
5.3k
Forks
829
Avg merge
1d 1h
Merged PRs (30d)
15

Description

Right now, we compute a struct's padding fields while we are codegen'ing it.

Instead, we should have a dedicated phase for computing implicit padding fields that transforms from structs-with-only-explicit-fields to structs-with-explicit-fields-and-implicit-padding-fields.

Benefits this will give us:

This new phase should probably happen either right before or right after we compute allocation units for bitfields. I'm not 100% sure which, and determining it requires further investigation/experimentation.

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 where struct padding is computed during code generation and where bitfield allocation units are computed. Read src/ir/analysis/derive_debug.rs, especially the referenced trait-derivation logic, and investigate whether the new padding phase belongs before or after bitfield allocation. Done means structs are transformed to include implicit padding before later analyses can derive precise traits.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.