rust-lang / rust-bindgen

Automatically generates Rust FFI bindings to C (and some C++) libraries.
https://rust-lang.github.io/rust-bindgen/
BSD 3-Clause "New" or "Revised" License
4.39k stars 691 forks source link

Have some easy way to #[allow(non_camel_case_types)] (or even do it by default) #2757

Closed HadrienG2 closed 6 months ago

HadrienG2 commented 7 months ago

C and C++ commonly use snake_case type names, so the non_camel_case_types default rustc lint generates a lot of noise in bindgen-originated modules. There should at least be an easy way to disable this lint in bindgen's output, and imo it should be turned off by default.

HadrienG2 commented 7 months ago

After closer investigation, --raw-line can be used to inhibit the lint quite easily, so the only remaining question is, should bindgen make it the default.

pvdrz commented 6 months ago

Even though having it as a default sounds like an attractive proposition, it would require to have an option to opt out from this behavior as bindgen's API is pretty large already.

This also opens the door to have other attributes injected by default and, as a consequence, more options to not inject those attributes.

emilio commented 6 months ago

Yeah I think raw-line is more flexible and already a thing.