rust-unsafe-ffi
Rust Unsafe and FFI
Treat unsafe as a proof obligation. An unsafe block permits specific operations; it does not relax validity, aliasing, initialization, lifetime, data-race, layout, or ABI requirements.
Scope and Routing
Use this skill for raw pointers, NonNull, unsafe functions and traits, unions, MaybeUninit, ManuallyDrop, layout, pinning, allocators, manual Send or Sync, C ABI bindings, callbacks, handles, and ownership transfer.
Route ordinary ownership design to rust-stable, concurrent architecture to rust-concurrency, binding generation and build scripts to rust-cargo-build, and review reporting to rust-code-review.
Workflow
1. Justify and isolate unsafe operations
Identify the operation safe Rust cannot express. Prefer an audited crate or standard-library abstraction when it preserves the required behavior. Keep unsafe blocks small and enable:
#![deny(unsafe_op_in_unsafe_fn)]