id: safety-10 original_id: G.UNS.SAS.01 level: G impact: HIGH clippy: missing_safety_doc Add Safety Section in Docs for Public Unsafe Functions Summary Public unsafe functions must have a # Safety sec
阅读全文
Ensure Consistent Data Layout for Custom Types
id: ffi-13 original_id: P.UNS.FFI.13 level: P impact: HIGH Ensure Consistent Data Layout for Custom Types Summary Types shared between Rust and C must have #[repr(C)] to ensure the memory layout match
阅读全文
Unsafe Code Authors Must Verify Safety Invariants
id: safety-02 original_id: P.UNS.SAS.02 level: P impact: CRITICAL Unsafe Code Authors Must Verify Safety Invariants Summary When writing unsafe code, you are taking responsibility for upholding all sa
阅读全文
Do Not Expose Raw Pointers in Public APIs
id: safety-06 original_id: P.UNS.SAS.06 level: P impact: HIGH Do Not Expose Raw Pointers in Public APIs Summary Public APIs should use safe abstractions (references, slices, smart pointers) instead of
阅读全文
FFI Best Practices and Patterns
FFI Best Practices and Patterns Examples of safe and idiomatic Rust-C interoperability. Pattern 1: Basic FFI Wrapper use std::ffi::{CStr, CString}; use std::os::raw::{c_char, c_int, c_void}; use std::
阅读全文
Safe Abstraction Examples
Safe Abstraction Examples Examples of building safe APIs on top of unsafe code. Example 1: Simple Wrapper with Bounds Check /// A slice wrapper that provides unchecked access internally /// but safe a
阅读全文
Unsafe Rust Checker
name: unsafe-checker description: "CRITICAL: Use for unsafe Rust code review and FFI. Triggers on: unsafe, raw pointer, FFI, extern, transmute, *mut, const, union, #[repr(C)], libc, std::ffi, MaybeUni
阅读全文
Unsafe Checker - Quick Reference
Unsafe Checker - Quick Reference Auto-generated from rules/ Rule Summary by Section General Principles (3 rules) IDLevelTitle general-01PDo Not Abuse Unsafe to Escape Compiler Safety Checks general-02
阅读全文
Checklist: Before Writing Unsafe Code
Checklist: Before Writing Unsafe Code Use this checklist before writing any unsafe block or unsafe fn. 1. Do You Really Need Unsafe? Have you tried all safe alternatives? Can you restructure the code
阅读全文
Checklist: Reviewing Unsafe Code
Checklist: Reviewing Unsafe Code Use this checklist when reviewing code containing unsafe. 1. Surface-Level Checks Does every unsafe block have a // SAFETY: comment? Does every unsafe fn have # Safety
阅读全文