Skip to content

Commit

Permalink
feat(bailout): flag bailout as a panic function
Browse files Browse the repository at this point in the history
  • Loading branch information
joelwurtz committed Oct 21, 2023
1 parent ba342c4 commit 6679f5f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
12 changes: 9 additions & 3 deletions src/zend/try_catch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub fn try_catch<R, F: FnMut() -> R + RefUnwindSafe>(func: F) -> Result<R, Catch
///
/// When using this function you should ensure that all the memory allocated in the current scope is released
///
pub unsafe fn bailout() {
pub unsafe fn bailout() -> ! {
ext_php_rs_zend_bailout();
}

Expand All @@ -83,7 +83,10 @@ mod tests {
bailout();
}

assert!(false);
#[allow(unreachable_code)]
{
assert!(false);
}
});

assert!(catch.is_err());
Expand All @@ -108,7 +111,10 @@ mod tests {
bailout();
}

assert!(false);
#[allow(unreachable_code)]
{
assert!(false);
}
});
}

Expand Down

0 comments on commit 6679f5f

Please sign in to comment.