Skip to content

Commit dd3584c

Browse files
committed
rename internal panicking::try to catch_unwind
1 parent 04c1a04 commit dd3584c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

std/src/panic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ pub use core::panic::abort_unwind;
356356
/// ```
357357
#[stable(feature = "catch_unwind", since = "1.9.0")]
358358
pub fn catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> {
359-
unsafe { panicking::r#try(f) }
359+
unsafe { panicking::catch_unwind(f) }
360360
}
361361

362362
/// Triggers a panic without invoking the panic hook.

std/src/panicking.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -499,13 +499,13 @@ pub use realstd::rt::panic_count;
499499

500500
/// Invoke a closure, capturing the cause of an unwinding panic if one occurs.
501501
#[cfg(feature = "panic_immediate_abort")]
502-
pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>> {
502+
pub unsafe fn catch_unwind<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>> {
503503
Ok(f())
504504
}
505505

506506
/// Invoke a closure, capturing the cause of an unwinding panic if one occurs.
507507
#[cfg(not(feature = "panic_immediate_abort"))]
508-
pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>> {
508+
pub unsafe fn catch_unwind<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>> {
509509
union Data<F, R> {
510510
f: ManuallyDrop<F>,
511511
r: ManuallyDrop<R>,
@@ -541,7 +541,7 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
541541
let data_ptr = (&raw mut data) as *mut u8;
542542
// SAFETY:
543543
//
544-
// Access to the union's fields: this is `std` and we know that the `r#try`
544+
// Access to the union's fields: this is `std` and we know that the `catch_unwind`
545545
// intrinsic fills in the `r` or `p` union field based on its return value.
546546
//
547547
// The call to `intrinsics::catch_unwind` is made safe by:
@@ -602,7 +602,7 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
602602
// This function cannot be marked as `unsafe` because `intrinsics::catch_unwind`
603603
// expects normal function pointers.
604604
#[inline]
605-
#[rustc_nounwind] // `intrinsic::r#try` requires catch fn to be nounwind
605+
#[rustc_nounwind] // `intrinsic::catch_unwind` requires catch fn to be nounwind
606606
fn do_catch<F: FnOnce() -> R, R>(data: *mut u8, payload: *mut u8) {
607607
// SAFETY: this is the responsibility of the caller, see above.
608608
//

0 commit comments

Comments
 (0)