You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried using no_copy, no_hash etc, but they don't seem to work. Here is a small example that reproduces my issue:
/* main.rs */use bindgen::callbacks::ParseCallbacks;use bindgen::EnumVariation;/// Helper for applying custom attributes to enums.#[derive(Debug)]structNeliEnum;implParseCallbacksforNeliEnum{/* fn add_attributes(&self, _info: &AttributeInfo<'_>) -> Vec<String> { // I want to apply neli::neli_enum, which derives Copy, Clone, etc., // so I need to prevent bindgen from deriving them too. vec!["#[neli::neli_enum(serialized_type = \"u8\")]".into()] } */}fnmain(){let bindings = bindgen::Builder::default().default_enum_style(EnumVariation::Rust{non_exhaustive:false}).parse_callbacks(Box::new(NeliEnum)).header("./netlink.h")// This works.no_debug(".*")// This doesn't work quite as advertised: the docs say// this will suppress both Copy and Clone, but in this case,// it looks like it only suppresses Copy?.no_copy(".*")// Does not work, Hash is still derived for sinf_command.no_hash(".*")// Does not work, PartialEq is still derived for sinf_command.no_partialeq(".*").generate().expect("Unable to generate bindings");
bindings
.write_to_file("./src/netlink.rs").expect("Couldn't write bindings!");}
I am trying to generate bindings for a C enum, and make the resulting Rust type not derive
Copy
,Clone
,Hash
,PartialEq
,Eq
:I tried using
no_copy
,no_hash
etc, but they don't seem to work. Here is a small example that reproduces my issue:My
Cargo.toml
is:Expected output
Actual output
I am also confused by the
derive_hash
, etc. docs, which seem to suggest these traits shouldn't have been derived at all:Are the docs wrong, or is this a separate bug? Or am I somehow misinterpreting them?
For context, I'm trying to generate bindings for some netlink types that are shared between a kernel module and my userspace application.
The text was updated successfully, but these errors were encountered: