-
Notifications
You must be signed in to change notification settings - Fork 707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copy not derived when using whitelist_recursively(false) #1454
Comments
So what's going on is that when not whitelisting recursively we're not seeing through the built-in types (since they're not whitelisted!) and then we think we cannot derive stuff for them. You can see this if you do I think we could auto-whitelist items that don't generate code to make this better. |
When not whitelisting recursively. Fixes rust-lang#1454
#1492 should address this. You should also whitelist We could do the check of whether we're a known alias there as well, which would be more convenient too, though a bit more code and another list that we need to make sure doesn't go out of sync. Thoughts @jethrogb? Does that patch would work for you? |
Two more examples of things I'd like to work (I don't know how bindgen is supposed to figure out which types are ok to derive, maybe yet another addition to Input C/C++ Header#include <sys/resource.h>
typedef struct
{
struct rlimit core;
struct rlimit cpu;
struct rlimit data;
struct rlimit fsize;
}
my_rlimit_conf; Bindgen Invocationlet bindings = bindgen::builder()
.header_contents("test.h", ...)
.trust_clang_mangling(false)
.derive_copy(true)
.whitelist_type("my_rlimit_conf")
.whitelist_recursively(false)
.layout_tests(false)
.generate()
.expect("bindgen error");
println!("
extern crate libc;
use libc::rlimit;
{}
", bindings.to_string()); Actual Resultsextern crate libc;
use libc::rlimit;
/* automatically generated by rust-bindgen */
#[repr(C)]
pub struct my_rlimit_conf {
pub core: rlimit,
pub cpu: rlimit,
pub data: rlimit,
pub fsize: rlimit,
} Expected Resultsextern crate libc;
use libc::rlimit;
/* automatically generated by rust-bindgen */
#[repr(C)]
#[derive(Copy, Clone)]
pub struct my_rlimit_conf {
pub core: rlimit,
pub cpu: rlimit,
pub data: rlimit,
pub fsize: rlimit,
} (maybe also Input C/C++ Header#include <zlib.h>
typedef struct
{
z_streamp stream;
}
mystruct; Bindgen Invocationlet bindings = bindgen::builder()
.header_contents("test.h", ...)
.trust_clang_mangling(false)
.derive_copy(true)
.whitelist_type("mystruct")
.whitelist_recursively(false)
.layout_tests(false)
.generate()
.expect("bindgen error");
println!("
extern crate libz_sys;
use libz_sys::z_streamp;
{}
", bindings.to_string()); Actual Resultsextern crate libz_sys;
use libz_sys::z_streamp;
/* automatically generated by rust-bindgen */
#[repr(C)]
pub struct mystruct {
pub stream: z_streamp,
} Expected Resultsextern crate libz_sys;
use libz_sys::z_streamp;
/* automatically generated by rust-bindgen */
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct mystruct {
pub stream: z_streamp,
} |
Can we do something like if the non-whitelisted types of member fields were emitted and that would result in the particular derive, then we do the derive anyway without emitting the member type? |
When not whitelisting recursively. Fixes rust-lang#1454
When not whitelisting recursively. Fixes rust-lang#1454
When not whitelisting recursively. Fixes rust-lang#1454
Please reopen |
Input C/C++ Header
Bindgen Invocation
Actual Results
Expected Results
The text was updated successfully, but these errors were encountered: