rust-lang / rust-lang/rust-clippy
Allow `undocumented_unsafe_block` to detect a safety comment before a block of unsafe impls
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Description
Currently the code block
// SAFETY: RwLockReadGuards act as immutable references, they follow the same rules as them. (see
// core::marker::Sync)
unsafe impl<T: ?Sized + Sync> Sync for RwLockReadGuard<'_, T> {}
unsafe impl<T: ?Sized + Sync> Send for RwLockReadGuard<'_, T> {}
triggers the lint undocumented_unsafe_block for the second unsafe impl.
I would prefer there was an option to allow for the safety comment to count as documenting all the consecutive unsafe impls with a break on an empty line.
Version
rustc 1.98.0-nightly (9e2abe0c6 2026-06-16)
binary: rustc
commit-hash: 9e2abe0c6ab27fcbb95c30695188a75776e2feb1
commit-date: 2026-06-16
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.7
Additional Labels
@rustbot label +C-enhancement
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the consecutive unsafe impls and the undocumented_unsafe_block lint, then locate the lint's implementation and existing tests in rust-clippy. Done means a safety comment documents consecutive unsafe impls until an empty line, with regression coverage for the reported example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100