It seems a little odd that a safe function will bypass destructors. Is there any reason std::process::exit doesn’t unwind the stack? Personally, I think we need two functions:
Got it. I always forget that unsafe only refers to memory access, not general behavior.
As a result, not running destructors is not considered unsafe, so this function was introduced as safe.
Just for complete correctness in case anyone comes across this thread later, this isn't always true. Failing to call a destructor before freeing or failing to call a destructor on drop is unsafe. there is no guarantee that a destructor will ever be called.
For what it’s worth, the KJ C++ library also encourages RAII style together with a non-unwinding exit(), and its documentation gives some well thought out justification.