rust-lang / rust-lang/rust-bindgen
Add a phase that removes ResolvedTypeRefs before codegen
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
Ever since we got the graphviz visualizations of our IR graph, it has become immediately clear that we have a TON of ResolvedTypeRefs all over the place. In fact, 8 out of 15 IR items (more than half!) are ResolvedTypeRefs in this example I happen to be looking at:

A pass over the IR items where we replace all references to ResolvedTypeRefs with references to the type being transitively referenced via the ResolvedTypeRef would probably give us speed ups in codegen and analysis, because we wouldn't have to look at useless items anymore. It would also make looking at these graphs easier, since there would be less visual noise :-P
A good time to do this would be in ir::context::BindgenContext::gen, after we resolve unresolved type refs in resolve_typerefs. https://github.com/servo/rust-bindgen/blob/master/src/ir/context.rs#L529
I can mentor whoever would like to take a stab at this.
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 in src/ir/context.rs at ir::context::BindgenContext::gen, immediately after resolve_typerefs resolves unresolved type references. Trace the IR items and replace references to ResolvedTypeRefs with the transitively referenced type. Done means the phase removes these redundant references before codegen, reducing IR graph noise and avoiding unnecessary work in code generation and analysis.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100