Skip to content

Commit 731c6dc

Browse files
committed
Document catch_fn in r#try cannot unwind
1 parent 5c9b371 commit 731c6dc

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

library/core/src/intrinsics.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2276,6 +2276,8 @@ extern "rust-intrinsic" {
22762276
/// takes the data pointer and a pointer to the target-specific exception
22772277
/// object that was caught. For more information see the compiler's
22782278
/// source as well as std's catch implementation.
2279+
///
2280+
/// `catch_fn` must not unwind.
22792281
#[rustc_nounwind]
22802282
pub fn r#try(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32;
22812283

library/std/src/panicking.rs

+1
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
498498
// This function cannot be marked as `unsafe` because `intrinsics::r#try`
499499
// expects normal function pointers.
500500
#[inline]
501+
#[rustc_nounwind] // `intrinsic::r#try` requires catch fn to be nounwind
501502
fn do_catch<F: FnOnce() -> R, R>(data: *mut u8, payload: *mut u8) {
502503
// SAFETY: this is the responsibility of the caller, see above.
503504
//

0 commit comments

Comments
 (0)