Skip to content

unnecessary_safety_comment does not lint for a doc(hidden) item #14555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ojeda opened this issue Apr 5, 2025 · 0 comments
Open

unnecessary_safety_comment does not lint for a doc(hidden) item #14555

ojeda opened this issue Apr 5, 2025 · 0 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't

Comments

@ojeda
Copy link
Contributor

ojeda commented Apr 5, 2025

Summary

unnecessary_safety_comment does not lint for a doc(hidden) item (if above it).

Possibly related: #14553.
Possibly related: #14554.
Possibly related: #14556.

Lint Name

unnecessary_safety_comment

Reproducer

https://godbolt.org/z/Wxde5d7f4

I tried this code:

// This line should avoid #14553.

// SAFETY: ...
mod x {}

// SAFETY: ...
#[doc(hidden)]
mod y {}

#[doc(hidden)]
// SAFETY: ...
mod z {}

I expected to see this happen: Three lints, for all safety comments.

Instead, this happened: The safety comment for y is not linted.

Version

rustc 1.86.0 (05f9846f8 2025-03-31)
rustc 1.88.0-nightly (17ffbc81a 2025-04-04)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't
Projects
None yet
Development

No branches or pull requests

1 participant