rust-lang / rust-lang/rust-bindgen

whitelist_recursively sees through blacklisted types

Open
#1,455 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Input C/C++ Header
typedef struct file_s {
} file_t;
void take_file(file_t* f);
Bindgen Invocation
    let bindings = bindgen::builder()
        .header_contents("test.h", ...)
        .trust_clang_mangling(false)
        .derive_copy(true)
        .blacklist_type("file_t")
        .whitelist_function("take_file")
        .layout_tests(false)
        .generate()
        .expect("bindgen error");
Actual Results
/* automatically generated by rust-bindgen */

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct file_s {}
extern "C" {
    pub fn take_file(f: *mut file_t);
}
Expected Results

Since no whitelisted items depend on file_s, I expect it to not be emitted:

/* automatically generated by rust-bindgen */

extern "C" {
    pub fn take_file(f: *mut file_t);
}

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 provided C++ header and bindgen invocation, then trace whitelist_recursively to see why the blacklisted file_t exposes file_s. Done means the generated bindings match the expected output and do not emit file_s; add or run a regression test for this case if the existing test layout supports it.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, rust
Domain
compilers, devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.