Summary
When a newline separates the = sign and the beginning of an unsafe block (as rustfmt sometimes produces), Clippy doesn't recognize a safety comment as decorating the unsafe block:
// SAFETY: ...
let x =
unsafe { ... };
Lint Name
undocumented_unsafe_blocks
Reproducer
I tried this code:
#![deny(clippy::undocumented_unsafe_blocks)]
fn main() {
// SAFETY: No unsafe code here!
let _x =
unsafe { 0 };
// SAFETY: No unsafe code here!
let _y = unsafe { 0 };
}
I expected to see this happen:
Both unsafe blocks should have been recognized as having a safety comment.
Instead, this happened:
undocumented_unsafe_blocks fired on let _x = ....
Version
Summary
When a newline separates the
=sign and the beginning of anunsafeblock (as rustfmt sometimes produces), Clippy doesn't recognize a safety comment as decorating theunsafeblock:Lint Name
undocumented_unsafe_blocks
Reproducer
I tried this code:
I expected to see this happen:
Both
unsafeblocks should have been recognized as having a safety comment.Instead, this happened:
undocumented_unsafe_blocksfired onlet _x = ....Version