Open
Description
Summary
By definition, unsafe extern "C" fn
s are exposed to the outside world, and can therefore be regarded as if they're pub unsafe fn
s. It is very desirable to be able to require unsafe extern "C" fn
s be annotated with safety docs. Currently, the missing_safety_doc
lint does not trigger for unsafe extern "C" fn
s, wheras it does trigger for pub unsafe extern "C" fn
s.
Lint Name
missing_safety_doc
Reproducer
I tried this code:
unsafe extern "C" fn say_hello(msg: *const Cstr) {
todo!()
}
I expected to see this happen:
warning: unsafe function's docs are missing a `# Safety` section
--> trie_rs/src/ffi.rs:329:1
|
329 | unsafe extern "C" fn say_hello(msg: *const u8) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc
= note: `#[warn(clippy::missing_safety_doc)]` on by default
Instead, this happened:
No complaints by Clippy whatsoever
Version
rustc 1.85.0 (4d91de4e4 2025-02-17)
binary: rustc
commit-hash: 4d91de4e48198da2e33413efdcd9cd2cc0c46688
commit-date: 2025-02-17
host: aarch64-apple-darwin
release: 1.85.0
LLVM version: 19.1.7