Open
Description
Summary
unnecessary_safety_comment
does not take into account a // SAFETY
comment in the first line.
Possibly related: #14554.
Possibly related: #14555.
Possibly related: #14556.
Lint Name
unnecessary_safety_comment
Reproducer
https://godbolt.org/z/ejTxeq148
I tried this code:
// SAFETY: ...
mod x {}
// SAFETY: ...
mod y {}
I expected to see this happen: Two lints, for both safety comments.
Instead, this happened: Only the comment on y
is linted.
Note that adding a single newline on top, or a comment, or an item, will make it work again, e.g.:
//
// SAFETY: ...
mod x {}
// SAFETY: ...
mod y {}
Version
rustc 1.86.0 (05f9846f8 2025-03-31)
rustc 1.88.0-nightly (17ffbc81a 2025-04-04)
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
unnecessary_safety_comment
does not lint the first item of a module without a body #14554unnecessary_safety_comment
does not lint for adoc(hidden)
item #14555unnecessary_safety_comment
does not lint for "orphan" comments #14556