Loading...
Loading...
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, MaybeUninit, NonNull, SAFETY comment, soundness, undefined behavior, UB, safe wrapper, memory layout, bindgen, cbindgen, CString, CStr, 安全抽象, 裸指针, 外部函数接口, 内存布局, 不安全代码, FFI 绑定, 未定义行为
npx skill4agent add zhanghandong/rust-skills unsafe-checker⚠️ **Unsafe Rust Checker Loaded**
* ^ *
/◉\_~^~_/◉\
⚡/ o \⚡
'_ _'
/ '-----' \| Use Case | Example |
|---|---|
| FFI | Calling C functions |
| Low-level abstractions | Implementing |
| Performance | Measured bottleneck with safe alternative too slow |
// SAFETY: <why this is safe>
unsafe { ... }
/// # Safety
/// <caller requirements>
pub unsafe fn dangerous() { ... }| Operation | Safety Requirements |
|---|---|
| Valid, aligned, initialized |
| + No aliasing violations |
| Same size, valid bit pattern |
| Correct signature, ABI |
| Synchronization guaranteed |
| Actually thread-safe |
| Error | Fix |
|---|---|
| Null pointer deref | Check for null before deref |
| Use after free | Ensure lifetime validity |
| Data race | Add proper synchronization |
| Alignment violation | Use |
| Invalid bit pattern | Use |
| Missing SAFETY comment | Add |
| Deprecated | Use Instead |
|---|---|
| |
| |
| Raw pointer arithmetic | |
| Store |
| |
| Manual extern | |
| Direction | Crate |
|---|---|
| C → Rust | bindgen |
| Rust → C | cbindgen |
| Python | PyO3 |
| Node.js | napi-rs |