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.23k stars 679 forks source link

Allow adding extra documentation to bindgen-generated entities #2758

Open HadrienG2 opened 4 months ago

HadrienG2 commented 4 months ago

C libraries are not always very careful about documenting their safety requirements. But unsafe rust functions are expected to document in which circumstances they are safe to use. To resolve this impedance mismatch without huge upstream doc contributions, which may be rejected, it would be nice if one could append manually written # Safety sections to bindgen's autogenerated function docs. This could take the form of a HashMap from C function name to safety docs.

pvdrz commented 3 months ago

This could be seen as a particular case of https://github.com/rust-lang/rust-bindgen/issues/2739