Skip to content

Commit b06c43c

Browse files
authored
Unrolled build for #141505
Rollup merge of #141505 - RalfJung:catch_unwind, r=Noratrieb rename internal panicking::try to catch_unwind The public function is called `catch_unwind`, the intrinsic at some point got renamed to `catch_unwind` -- there's no reason to have the internal implementation of this still be called `try`, so let's rename it to match the rest.
2 parents 5e16c66 + 1827bc0 commit b06c43c

File tree

8 files changed

+28
-28
lines changed

8 files changed

+28
-28
lines changed

library/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.

library/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
//

src/tools/miri/src/shims/panic.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
5656
interp_ok(())
5757
}
5858

59-
/// Handles the `try` intrinsic, the underlying implementation of `std::panicking::try`.
59+
/// Handles the `catch_unwind` intrinsic.
6060
fn handle_catch_unwind(
6161
&mut self,
6262
args: &[OpTy<'tcx>],
@@ -66,7 +66,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
6666
let this = self.eval_context_mut();
6767

6868
// Signature:
69-
// fn r#try(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32
69+
// fn catch_unwind(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32
7070
// Calls `try_fn` with `data` as argument. If that executes normally, returns 0.
7171
// If that unwinds, calls `catch_fn` with the first argument being `data` and
7272
// then second argument being a target-dependent `payload` (i.e. it is up to us to define
@@ -120,14 +120,14 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
120120
// We only care about `catch_panic` if we're unwinding - if we're doing a normal
121121
// return, then we don't need to do anything special.
122122
if let (true, Some(catch_unwind)) = (unwinding, extra.catch_unwind.take()) {
123-
// We've just popped a frame that was pushed by `try`,
123+
// We've just popped a frame that was pushed by `catch_unwind`,
124124
// and we are unwinding, so we should catch that.
125125
trace!(
126126
"unwinding: found catch_panic frame during unwinding: {:?}",
127127
this.frame().instance()
128128
);
129129

130-
// We set the return value of `try` to 1, since there was a panic.
130+
// We set the return value of `catch_unwind` to 1, since there was a panic.
131131
this.write_scalar(Scalar::from_i32(1), &catch_unwind.dest)?;
132132

133133
// The Thread's `panic_payload` holds what was passed to `miri_start_unwind`.
@@ -142,7 +142,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
142142
ExternAbi::Rust,
143143
&[catch_unwind.data, payload],
144144
None,
145-
// Directly return to caller of `try`.
145+
// Directly return to caller of `catch_unwind`.
146146
StackPopCleanup::Goto {
147147
ret: catch_unwind.ret,
148148
// `catch_fn` must not unwind.

src/tools/miri/tests/fail/panic/bad_unwind.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ LL | std::panic::catch_unwind(|| unwind()).unwrap_err();
1313
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
1414
= note: BACKTRACE:
1515
= note: inside closure at tests/fail/panic/bad_unwind.rs:LL:CC
16-
= note: inside `std::panicking::r#try::do_call::<{closure@tests/fail/panic/bad_unwind.rs:LL:CC}, ()>` at RUSTLIB/std/src/panicking.rs:LL:CC
17-
= note: inside `std::panicking::r#try::<(), {closure@tests/fail/panic/bad_unwind.rs:LL:CC}>` at RUSTLIB/std/src/panicking.rs:LL:CC
16+
= note: inside `std::panicking::catch_unwind::do_call::<{closure@tests/fail/panic/bad_unwind.rs:LL:CC}, ()>` at RUSTLIB/std/src/panicking.rs:LL:CC
17+
= note: inside `std::panicking::catch_unwind::<(), {closure@tests/fail/panic/bad_unwind.rs:LL:CC}>` at RUSTLIB/std/src/panicking.rs:LL:CC
1818
= note: inside `std::panic::catch_unwind::<{closure@tests/fail/panic/bad_unwind.rs:LL:CC}, ()>` at RUSTLIB/std/src/panic.rs:LL:CC
1919
note: inside `main`
2020
--> tests/fail/panic/bad_unwind.rs:LL:CC

src/tools/miri/tests/fail/tail_calls/cc-mismatch.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ LL | extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
1111
= note: inside `std::sys::backtrace::__rust_begin_short_backtrace::<fn(), ()>` at RUSTLIB/std/src/sys/backtrace.rs:LL:CC
1212
= note: inside closure at RUSTLIB/std/src/rt.rs:LL:CC
1313
= note: inside `std::ops::function::impls::<impl std::ops::FnOnce<()> for &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>::call_once` at RUSTLIB/core/src/ops/function.rs:LL:CC
14-
= note: inside `std::panicking::r#try::do_call::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at RUSTLIB/std/src/panicking.rs:LL:CC
15-
= note: inside `std::panicking::r#try::<i32, &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>` at RUSTLIB/std/src/panicking.rs:LL:CC
14+
= note: inside `std::panicking::catch_unwind::do_call::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at RUSTLIB/std/src/panicking.rs:LL:CC
15+
= note: inside `std::panicking::catch_unwind::<i32, &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>` at RUSTLIB/std/src/panicking.rs:LL:CC
1616
= note: inside `std::panic::catch_unwind::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at RUSTLIB/std/src/panic.rs:LL:CC
1717
= note: inside closure at RUSTLIB/std/src/rt.rs:LL:CC
18-
= note: inside `std::panicking::r#try::do_call::<{closure@std::rt::lang_start_internal::{closure#0}}, isize>` at RUSTLIB/std/src/panicking.rs:LL:CC
19-
= note: inside `std::panicking::r#try::<isize, {closure@std::rt::lang_start_internal::{closure#0}}>` at RUSTLIB/std/src/panicking.rs:LL:CC
18+
= note: inside `std::panicking::catch_unwind::do_call::<{closure@std::rt::lang_start_internal::{closure#0}}, isize>` at RUSTLIB/std/src/panicking.rs:LL:CC
19+
= note: inside `std::panicking::catch_unwind::<isize, {closure@std::rt::lang_start_internal::{closure#0}}>` at RUSTLIB/std/src/panicking.rs:LL:CC
2020
= note: inside `std::panic::catch_unwind::<{closure@std::rt::lang_start_internal::{closure#0}}, isize>` at RUSTLIB/std/src/panic.rs:LL:CC
2121
= note: inside `std::rt::lang_start_internal` at RUSTLIB/std/src/rt.rs:LL:CC
2222
= note: inside `std::rt::lang_start::<()>` at RUSTLIB/std/src/rt.rs:LL:CC

src/tools/miri/tests/pass/backtrace/backtrace-api-v1.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ RUSTLIB/core/src/ops/function.rs:LL:CC (<fn() as std::ops::FnOnce<()>>::call_onc
77
RUSTLIB/std/src/sys/backtrace.rs:LL:CC (std::sys::backtrace::__rust_begin_short_backtrace)
88
RUSTLIB/std/src/rt.rs:LL:CC (std::rt::lang_start::{closure#0})
99
RUSTLIB/core/src/ops/function.rs:LL:CC (std::ops::function::impls::call_once)
10-
RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try::do_call)
11-
RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try)
10+
RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::catch_unwind::do_call)
11+
RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::catch_unwind)
1212
RUSTLIB/std/src/panic.rs:LL:CC (std::panic::catch_unwind)
1313
RUSTLIB/std/src/rt.rs:LL:CC (std::rt::lang_start_internal::{closure#0})
14-
RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try::do_call)
15-
RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try)
14+
RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::catch_unwind::do_call)
15+
RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::catch_unwind)
1616
RUSTLIB/std/src/panic.rs:LL:CC (std::panic::catch_unwind)
1717
RUSTLIB/std/src/rt.rs:LL:CC (std::rt::lang_start_internal)
1818
RUSTLIB/std/src/rt.rs:LL:CC (std::rt::lang_start)

src/tools/miri/tests/pass/backtrace/backtrace-global-alloc.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
at RUSTLIB/std/src/rt.rs:LL:CC
99
4: std::ops::function::impls::call_once
1010
at RUSTLIB/core/src/ops/function.rs:LL:CC
11-
5: std::panicking::r#try::do_call
11+
5: std::panicking::catch_unwind::do_call
1212
at RUSTLIB/std/src/panicking.rs:LL:CC
13-
6: std::panicking::r#try
13+
6: std::panicking::catch_unwind
1414
at RUSTLIB/std/src/panicking.rs:LL:CC
1515
7: std::panic::catch_unwind
1616
at RUSTLIB/std/src/panic.rs:LL:CC
1717
8: std::rt::lang_start_internal::{closure#0}
1818
at RUSTLIB/std/src/rt.rs:LL:CC
19-
9: std::panicking::r#try::do_call
19+
9: std::panicking::catch_unwind::do_call
2020
at RUSTLIB/std/src/panicking.rs:LL:CC
21-
10: std::panicking::r#try
21+
10: std::panicking::catch_unwind
2222
at RUSTLIB/std/src/panicking.rs:LL:CC
2323
11: std::panic::catch_unwind
2424
at RUSTLIB/std/src/panic.rs:LL:CC

src/tools/miri/tests/pass/backtrace/backtrace-std.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
at RUSTLIB/std/src/rt.rs:LL:CC
1717
8: std::ops::function::impls::call_once
1818
at RUSTLIB/core/src/ops/function.rs:LL:CC
19-
9: std::panicking::r#try::do_call
19+
9: std::panicking::catch_unwind::do_call
2020
at RUSTLIB/std/src/panicking.rs:LL:CC
21-
10: std::panicking::r#try
21+
10: std::panicking::catch_unwind
2222
at RUSTLIB/std/src/panicking.rs:LL:CC
2323
11: std::panic::catch_unwind
2424
at RUSTLIB/std/src/panic.rs:LL:CC
2525
12: std::rt::lang_start_internal::{closure#0}
2626
at RUSTLIB/std/src/rt.rs:LL:CC
27-
13: std::panicking::r#try::do_call
27+
13: std::panicking::catch_unwind::do_call
2828
at RUSTLIB/std/src/panicking.rs:LL:CC
29-
14: std::panicking::r#try
29+
14: std::panicking::catch_unwind
3030
at RUSTLIB/std/src/panicking.rs:LL:CC
3131
15: std::panic::catch_unwind
3232
at RUSTLIB/std/src/panic.rs:LL:CC

0 commit comments

Comments
 (0)