rust-lang / rust-lang/rust-bindgen

C++: Inconsistent whitelisting / blacklisting paths for stuff nested inside a class / struct.

Open
#1,428 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
5.3k
Forks
829
Avg merge
1d 1h
Merged PRs (30d)
15

Description

Input C/C++ Header
class Foo {
public:
    static const int SomeStatic;
};

Bindgen Invocation
bindgen::Builder::default()
        .clang_args(&["-x", "c++"])
        .header("wrapper.h")
        .whitelist_type("Foo")
        .blacklist_item("Foo::SomeStatic")
        .generate()
        .expect("Unable to generate bindings");
Actual Results
extern "C" {
    #[link_name = "\u{1}_ZN3Foo10SomeStaticE"]
    pub static Foo_SomeStatic: ::std::os::raw::c_int;
}
Expected Results

Bindings for Foo::SomeStatic shouldn't be generated. They are not used internally by the generated bindings, nor do I intend to use them in my wrapper.

The dead_code lint triggers for it, and I don't want to allow(dead_code) for the entire generated bindings, as I think it's useful to know what items I haven't used yet in my wrapper library.

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 with the minimal C++ header and bindgen::Builder invocation shown in the issue, then inspect how nested C++ names are matched by whitelist_type and blacklist_item. Reproduce the generated Foo_SomeStatic binding and trace the filtering path; done means Foo::SomeStatic is omitted while Foo remains available.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.