mozilla / mozilla/cbindgen

Private type aliases result in a warning

Open
#1,082 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

I have code which looks roughly like this:

type FooBar = foo::Foo<bar::Bar>;

#[unsafe(no_mangle)]
pub unsafe extern "C" fn foo_bar(arg: &Arg) {
    // use `FooBar` inside functions
}

Running cbindgen results in the following warning:

WARN: Cannot find a mangling for generic path GenericPath { ... }. This usually means that a type referenced by this generic was incompatible or not found.

It's possible to work around it by adding /// cbindgen:ignore to the type alias, but I think cbindgen should just ignore such private type aliases automatically.

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

Reproduce the warning with the private FooBar alias and the cbindgen:ignore workaround shown in the issue. Trace how cbindgen handles private type aliases and generic paths; done means private aliases are ignored automatically without emitting the mangling warning.

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
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.