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.46k stars 694 forks source link

Allow adding extra documentation to bindgen-generated entities #2758

Open HadrienG2 opened 9 months ago

HadrienG2 commented 9 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 7 months ago

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