Skip to content

Commit 6679f5f

Browse files
committed
feat(bailout): flag bailout as a panic function
1 parent ba342c4 commit 6679f5f

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/ffi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ extern "C" {
3131
ctx: *const c_void,
3232
result: *mut *mut c_void,
3333
) -> bool;
34-
pub fn ext_php_rs_zend_bailout();
34+
pub fn ext_php_rs_zend_bailout() -> !;
3535
}
3636

3737
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));

src/zend/try_catch.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub fn try_catch<R, F: FnMut() -> R + RefUnwindSafe>(func: F) -> Result<R, Catch
6464
///
6565
/// When using this function you should ensure that all the memory allocated in the current scope is released
6666
///
67-
pub unsafe fn bailout() {
67+
pub unsafe fn bailout() -> ! {
6868
ext_php_rs_zend_bailout();
6969
}
7070

@@ -83,7 +83,10 @@ mod tests {
8383
bailout();
8484
}
8585

86-
assert!(false);
86+
#[allow(unreachable_code)]
87+
{
88+
assert!(false);
89+
}
8790
});
8891

8992
assert!(catch.is_err());
@@ -108,7 +111,10 @@ mod tests {
108111
bailout();
109112
}
110113

111-
assert!(false);
114+
#[allow(unreachable_code)]
115+
{
116+
assert!(false);
117+
}
112118
});
113119
}
114120

0 commit comments

Comments
 (0)