RS.CLIPPY.MISSING_SAFETY_DOC

`pub unsafe fn` without `# Safety` docs

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: missing_safety_doc. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for the doc comments of publicly visible unsafe functions and warns if there is no # Safety section.

Why is this bad?

Unsafe functions should document their safety preconditions, so that users can be sure they are using them safely.

Examples

/// This function should really be documented
pub unsafe fn start_apocalypse(u: &mut Universe) {
    unimplemented!();
}

At least write a line about safety:

/// # Safety
///
/// This function should not be called before the horsemen are ready.
pub unsafe fn start_apocalypse(u: &mut Universe) {
    unimplemented!();
}

Configuration

  • check-private-items: Whether to also run the listed lints on private items.

    (default: false)