Document catch_fn in r#try cannot unwind
This commit is contained in:
parent
5c9b371a2f
commit
731c6dcb60
2 changed files with 3 additions and 0 deletions
|
@ -2276,6 +2276,8 @@ extern "rust-intrinsic" {
|
||||||
/// takes the data pointer and a pointer to the target-specific exception
|
/// takes the data pointer and a pointer to the target-specific exception
|
||||||
/// object that was caught. For more information see the compiler's
|
/// object that was caught. For more information see the compiler's
|
||||||
/// source as well as std's catch implementation.
|
/// source as well as std's catch implementation.
|
||||||
|
///
|
||||||
|
/// `catch_fn` must not unwind.
|
||||||
#[rustc_nounwind]
|
#[rustc_nounwind]
|
||||||
pub fn r#try(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32;
|
pub fn r#try(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32;
|
||||||
|
|
||||||
|
|
|
@ -498,6 +498,7 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
|
||||||
// This function cannot be marked as `unsafe` because `intrinsics::r#try`
|
// This function cannot be marked as `unsafe` because `intrinsics::r#try`
|
||||||
// expects normal function pointers.
|
// expects normal function pointers.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[rustc_nounwind] // `intrinsic::r#try` requires catch fn to be nounwind
|
||||||
fn do_catch<F: FnOnce() -> R, R>(data: *mut u8, payload: *mut u8) {
|
fn do_catch<F: FnOnce() -> R, R>(data: *mut u8, payload: *mut u8) {
|
||||||
// SAFETY: this is the responsibility of the caller, see above.
|
// SAFETY: this is the responsibility of the caller, see above.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Add table
Reference in a new issue