mozilla / mozilla/cbindgen

Strange monomorphism for generic with array in type parameter

Open
#1,068 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
3k
Forks
386
Avg merge
1h 43m
Merged PRs (30d)
1

Description

struct Foo<T> {
  inner: T
}

#[no_mangle]
pub extern "C" fn foo_array -> Foo<[u8;32]> {
  todo!()
}

will generate types like:

typedef struct Foo__________u8__________32 {
  uint8_t[32]
} Foo__________u8__________32;

Why so many underscores? I'm tempted to use rename_item and rename all these to have a single underscore. but leads me to wonder if this is intentional and needed for some reason?

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 reproducing the issue with the Rust Foo and foo_array example, then inspect the generated C type name and compare it with the expected naming behavior. Determine whether the repeated underscores are intentional or a naming defect; done means the behavior is explained and, if needed, covered by a focused regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.