If you happen to write unsafe code in Rust where normal static checks are not available and want better UX for detecting memory issues along side using various sanitizers, checkout my new crate smartalloc which provides idiomatic Rust binding for the original C version here.
Beside the reason in README, note that MIRI can’t be used now since it doesn’t support FFI function call. With Rust 1.65.0-nightly running
cargo +nightly miri run --example undetected
results the error
error: unsupported operation: can't call foreign function: sm_malloc --> examples/undetected.rs:6:16 | 5 | #[global_allocator] | ------------------- in this procedural macro expansion 6 | static GLOBAL: SmartAlloc = SmartAlloc; | ^^^^^^^^^^ can't call foreign function: sm_malloc | = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support = note: BACKTRACE: = note: inside `_::__rg_alloc` at examples/undetected.rs:6:16 = note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info) note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace