Skip to content

Allow undocumented_unsafe_block to detect a safety comment before a block of unsafe impls #17280

Description

@programmerlexi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messages

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions