Closed
Description
Summary
missing_safety_doc
and undocumented_unsafe_blocks
complement each other to provide full safety documentation coverage. While missing_safety_doc
triggers on unsafe trait definitions and warn that safety docs must be provided, undocumented_unsafe_blocks
does not trigger on unsafe trait implementations.
Lint Name
undocumented_unsafe_blocks
Reproducer
I tried this code:
#![warn(clippy::undocumented_unsafe_blocks)]
/// # Safety
///
/// The implementor must justify with a safety comment.
unsafe trait Foo {}
unsafe impl Foo for () {}
/// # Safety
///
/// The caller must justify with a safety comment.
unsafe fn foo() {}
fn main() {
// SAFETY: It's justified.
unsafe {
foo();
}
}
I expected to see this happen:
warning: unsafe impl missing a safety comment
--> src/main.rs:8:1
Instead, this happened:
No lint triggered for the unsafe impl.
Version
rustc 1.59.0 (9d1b2106e 2022-02-23)
binary: rustc
commit-hash: 9d1b2106e23b1abd32fce1f17267604a5102f57a
commit-date: 2022-02-23
host: x86_64-apple-darwin
release: 1.59.0
LLVM version: 13.0.0