From 6679f5f9bc87de2342e23014c88dc672ba10161c Mon Sep 17 00:00:00 2001 From: Joel Wurtz Date: Sun, 22 Oct 2023 00:50:00 +0200 Subject: [PATCH] feat(bailout): flag bailout as a panic function --- src/ffi.rs | 2 +- src/zend/try_catch.rs | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ffi.rs b/src/ffi.rs index 37b79ed26..a6c3d9486 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -31,7 +31,7 @@ extern "C" { ctx: *const c_void, result: *mut *mut c_void, ) -> bool; - pub fn ext_php_rs_zend_bailout(); + pub fn ext_php_rs_zend_bailout() -> !; } include!(concat!(env!("OUT_DIR"), "/bindings.rs")); diff --git a/src/zend/try_catch.rs b/src/zend/try_catch.rs index 99c0aaf69..f74b427a5 100644 --- a/src/zend/try_catch.rs +++ b/src/zend/try_catch.rs @@ -64,7 +64,7 @@ pub fn try_catch R + RefUnwindSafe>(func: F) -> Result ! { ext_php_rs_zend_bailout(); } @@ -83,7 +83,10 @@ mod tests { bailout(); } - assert!(false); + #[allow(unreachable_code)] + { + assert!(false); + } }); assert!(catch.is_err()); @@ -108,7 +111,10 @@ mod tests { bailout(); } - assert!(false); + #[allow(unreachable_code)] + { + assert!(false); + } }); }