no-panic is a Rust procedural attribute macro that makes the compiler prove an annotated function cannot panic. It targets code where panic freedom matters more than ordinary runtime testing. section 4.8
Turning possible panics into build failures
The technique relies on Rust’s cleanup rules. A generated sentinel type implements Drop, calls a deliberately missing C symbol from drop, and is then forgotten. If the annotated function might panic, unwinding can invoke Drop, preserving the reference and producing a linker error. If panic is impossible, the compiler can eliminate the unused Drop path. section 4.8
