rust.unsafe_block_unaudited
Correctness
High
Detects unsafe blocks without safety documentation explaining why the code is sound.
Why It Matters
Section titled “Why It Matters”Unaudited unsafe:
- Hides undefined behavior — Easy to miss errors
- Blocks code review — No safety reasoning documented
- Causes memory bugs — Use-after-free, data races
Example
Section titled “Example”// ❌ Before (undocumented unsafe)unsafe { ptr::copy_nonoverlapping(src, dst, len);}// ✅ After (documented safety invariants)// SAFETY: `src` and `dst` are valid for `len` bytes,// properly aligned, and non-overlapping.// This is ensured by the allocation in `new()`.unsafe { ptr::copy_nonoverlapping(src, dst, len);}What Unfault Detects
Section titled “What Unfault Detects”- Unsafe blocks without SAFETY comments
- Unsafe fn implementations without docs
- Missing invariant documentation
Auto-Fix
Section titled “Auto-Fix”Unfault adds a SAFETY comment template for you to fill in.