#![no_std]
struct NoPanic;
extern "C" {
#[link_name = "\n\nHEY! ACTUAL ERROR DOWN HERE!!! (sorry for that big mess up there) \
the compiler was unable to prove that some code passed to assert_panic_free is \
actually panic-free. Please ensure that optimizations are enabled."]
fn trigger() -> !;
}
impl Drop for NoPanic {
fn drop(&mut self) {
unsafe {
trigger();
}
}
}
pub fn assert_panic_free<R, F: FnOnce() -> R>(f: F) -> R {
let guard = NoPanic;
let result = f();
core::mem::forget(guard);
result
}