-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
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)
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have