From 731c6dcb60ffd4980b27338be652bb932790cc83 Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Wed, 12 Apr 2023 14:55:35 +0100 Subject: [PATCH] Document catch_fn in r#try cannot unwind --- library/core/src/intrinsics.rs | 2 ++ library/std/src/panicking.rs | 1 + 2 files changed, 3 insertions(+) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 10c5425b7cf..a7c100e1b23 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -2276,6 +2276,8 @@ extern "rust-intrinsic" { /// takes the data pointer and a pointer to the target-specific exception /// object that was caught. For more information see the compiler's /// source as well as std's catch implementation. + /// + /// `catch_fn` must not unwind. #[rustc_nounwind] pub fn r#try(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32; diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs index e505466e535..a46a29cbad6 100644 --- a/library/std/src/panicking.rs +++ b/library/std/src/panicking.rs @@ -498,6 +498,7 @@ pub unsafe fn r#try R>(f: F) -> Result> // This function cannot be marked as `unsafe` because `intrinsics::r#try` // expects normal function pointers. #[inline] + #[rustc_nounwind] // `intrinsic::r#try` requires catch fn to be nounwind fn do_catch R, R>(data: *mut u8, payload: *mut u8) { // SAFETY: this is the responsibility of the caller, see above. //