rust-bindgen icon indicating copy to clipboard operation
rust-bindgen copied to clipboard

derive/impl fail inconsistently for blocked uint32_t/etc

Open talchas opened this issue 2 years ago • 0 comments

Input C/C++ Header

typedef int uint32_t;

struct foo {
  uint32_t a;
};

Bindgen Invocation

    bindgen::Builder::default()
        .header("test.h")
        .parse_callbacks(Box::new(bindgen::CargoCallbacks))
        .allowlist_type("foo")
        .allowlist_recursively(false)
        .generate()
        .expect("bindgen failure").write_to_file("test.rs").unwrap();

Actual Results

No derive impl generated. With .impl_debug(true), the field is not printed.

Expected Results

Derive impl generated (since the struct is correctly generated, and even without allowlist_recursively(false) the struct definition doesn't use the type definition instead of u32).

The particularly odd part is that this succeeds without the parse_callbacks. In 0.58.1 this failed regardless. Workaround is to just generate twice, and throw out the one with the parse callbacks.

talchas avatar Jun 01 '22 21:06 talchas