Closed
Description
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
1.72 (stable)