rust-lang / rust-lang/rust-bindgen

We can generate non-whitelisted structs using opaque items

Open
#453 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

In #452 I'm removing an assertion that was hitting in stylo, concretely with the BaseErrorResult typedef.

This codegen was being called from CompInfo::codegen as expected (it's an inner typedef). The above item was clearly whitelisted (it'd have hit before otherwise).

Upon reflection, ErrorResult is marked as opaque, so we immediately stop tracing it (never whitelist the inner item).

When we arrive to generate code for ErrorResult, we generate opaque structs, but we still generate the inner types for it (which is desirable IMO).

What should we do here @fitzgen? Tracing across opaque stuff doesn't seem desirable, but neither does not generating sub-items for opaque items. Presumably we could change the assertion to something like "is whitelisted or any parent is opaque", or something like that.

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 at CompInfo::codegen and trace how ErrorResult, its opaque status, and the inner BaseErrorResult typedef are handled. Reproduce the stylo case described in the issue, then inspect the whitelist assertion and related code-generation behavior. Done means the intended opaque-item handling is decided and non-whitelisted inner structs are handled consistently without the assertion failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.