Skip to content

Commit d95c321

Browse files
authored
Rollup merge of #121598 - RalfJung:catch_unwind, r=oli-obk
rename 'try' intrinsic to 'catch_unwind' The intrinsic has nothing to do with `try` blocks, and corresponds to the stable `catch_unwind` function, so this makes a lot more sense IMO. Also rename Miri's special function while we are at it, to reflect the level of abstraction it works on: it's an unwinding mechanism, on which Rust implements panics.
2 parents fc3800f + a3c0f3a commit d95c321

File tree

24 files changed

+67
-55
lines changed

24 files changed

+67
-55
lines changed

compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use rustc_middle::ty::layout::{HasParamEnv, ValidityRequirement};
2323
use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths};
2424
use rustc_middle::ty::GenericArgsRef;
2525
use rustc_span::source_map::Spanned;
26-
use rustc_span::symbol::{kw, sym, Symbol};
26+
use rustc_span::symbol::{sym, Symbol};
2727

2828
pub(crate) use self::llvm::codegen_llvm_intrinsic_call;
2929
use crate::prelude::*;
@@ -1132,7 +1132,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
11321132
ret.write_cvalue(fx, val);
11331133
}
11341134

1135-
kw::Try => {
1135+
sym::catch_unwind => {
11361136
intrinsic_args!(fx, args => (f, data, catch_fn); intrinsic);
11371137
let f = f.load_scalar(fx);
11381138
let data = data.load_scalar(fx);

compiler/rustc_codegen_gcc/src/intrinsic/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use rustc_middle::ty::{self, Instance, Ty};
2121
use rustc_middle::ty::layout::LayoutOf;
2222
#[cfg(feature="master")]
2323
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt};
24-
use rustc_span::{Span, Symbol, symbol::kw, sym};
24+
use rustc_span::{Span, Symbol, sym};
2525
use rustc_target::abi::HasDataLayout;
2626
use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode};
2727
use rustc_target::spec::PanicStrategy;
@@ -129,7 +129,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
129129
let res = self.context.new_call(None, builtin, &[a]);
130130
self.icmp(IntPredicate::IntEQ, res, self.const_i32(0))
131131
}
132-
kw::Try => {
132+
sym::catch_unwind => {
133133
try_intrinsic(
134134
self,
135135
args[0].immediate(),

compiler/rustc_codegen_llvm/src/intrinsic.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_hir as hir;
1717
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, LayoutOf};
1818
use rustc_middle::ty::{self, GenericArgsRef, Ty};
1919
use rustc_middle::{bug, span_bug};
20-
use rustc_span::{sym, symbol::kw, Span, Symbol};
20+
use rustc_span::{sym, Span, Symbol};
2121
use rustc_target::abi::{self, Align, HasDataLayout, Primitive};
2222
use rustc_target::spec::{HasTargetSpec, PanicStrategy};
2323

@@ -133,8 +133,8 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
133133
}
134134
sym::unlikely => self
135135
.call_intrinsic("llvm.expect.i1", &[args[0].immediate(), self.const_bool(false)]),
136-
kw::Try => {
137-
try_intrinsic(
136+
sym::catch_unwind => {
137+
catch_unwind_intrinsic(
138138
self,
139139
args[0].immediate(),
140140
args[1].immediate(),
@@ -457,7 +457,7 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
457457
}
458458
}
459459

460-
fn try_intrinsic<'ll>(
460+
fn catch_unwind_intrinsic<'ll>(
461461
bx: &mut Builder<'_, 'll, '_>,
462462
try_func: &'ll Value,
463463
data: &'ll Value,

compiler/rustc_hir_analysis/src/check/intrinsic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_hir as hir;
1212
use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
1313
use rustc_middle::ty::{self, Ty, TyCtxt};
1414
use rustc_span::def_id::LocalDefId;
15-
use rustc_span::symbol::{kw, sym};
15+
use rustc_span::symbol::sym;
1616
use rustc_span::{Span, Symbol};
1717
use rustc_target::spec::abi::Abi;
1818

@@ -445,7 +445,7 @@ pub fn check_intrinsic_type(
445445
)
446446
}
447447

448-
kw::Try => {
448+
sym::catch_unwind => {
449449
let mut_u8 = Ty::new_mut_ptr(tcx, tcx.types.u8);
450450
let try_fn_ty = ty::Binder::dummy(tcx.mk_fn_sig(
451451
[mut_u8],

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ symbols! {
487487
call_once,
488488
caller_location,
489489
capture_disjoint_fields,
490+
catch_unwind,
490491
cause,
491492
cdylib,
492493
ceilf32,

library/core/src/intrinsics.rs

+18-7
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
7575
unsafe { crate::ptr::drop_in_place(to_drop) }
7676
}
7777

78+
#[cfg(bootstrap)]
79+
pub use self::r#try as catch_unwind;
80+
7881
extern "rust-intrinsic" {
7982
// N.B., these intrinsics take raw pointers because they mutate aliased
8083
// memory, which is not valid for either `&` or `&mut`.
@@ -2382,16 +2385,24 @@ extern "rust-intrinsic" {
23822385
#[rustc_nounwind]
23832386
pub fn variant_count<T>() -> usize;
23842387

2385-
/// Rust's "try catch" construct which invokes the function pointer `try_fn`
2386-
/// with the data pointer `data`.
2387-
///
2388-
/// The third argument is a function called if a panic occurs. This function
2389-
/// takes the data pointer and a pointer to the target-specific exception
2390-
/// object that was caught. For more information see the compiler's
2391-
/// source as well as std's catch implementation.
2388+
/// Rust's "try catch" construct for unwinding. Invokes the function pointer `try_fn` with the
2389+
/// data pointer `data`, and calls `catch_fn` if unwinding occurs while `try_fn` runs.
23922390
///
23932391
/// `catch_fn` must not unwind.
2392+
///
2393+
/// The third argument is a function called if an unwind occurs (both Rust unwinds and foreign
2394+
/// unwinds). This function takes the data pointer and a pointer to the target-specific
2395+
/// exception object that was caught. For more information, see the compiler's source as well as
2396+
/// std's `catch_unwind` implementation.
2397+
///
2398+
/// The stable version of this intrinsic is `std::panic::catch_unwind`.
2399+
#[rustc_nounwind]
2400+
#[cfg(not(bootstrap))]
2401+
pub fn catch_unwind(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32;
2402+
2403+
/// For bootstrap only, see `catch_unwind`.
23942404
#[rustc_nounwind]
2405+
#[cfg(bootstrap)]
23952406
pub fn r#try(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32;
23962407

23972408
/// Emits a `!nontemporal` store according to LLVM (see their docs).

library/panic_unwind/src/miri.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ type Payload = Box<Box<dyn Any + Send>>;
88

99
extern "Rust" {
1010
/// Miri-provided extern function to begin unwinding.
11-
fn miri_start_panic(payload: *mut u8) -> !;
11+
fn miri_start_unwind(payload: *mut u8) -> !;
1212
}
1313

1414
pub unsafe fn panic(payload: Box<dyn Any + Send>) -> u32 {
15-
// The payload we pass to `miri_start_panic` will be exactly the argument we get
15+
// The payload we pass to `miri_start_unwind` will be exactly the argument we get
1616
// in `cleanup` below. So we just box it up once, to get something pointer-sized.
1717
let payload_box: Payload = Box::new(payload);
18-
miri_start_panic(Box::into_raw(payload_box) as *mut u8)
18+
miri_start_unwind(Box::into_raw(payload_box) as *mut u8)
1919
}
2020

2121
pub unsafe fn cleanup(payload_box: *mut u8) -> Box<dyn Any + Send> {

library/std/src/panicking.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -508,12 +508,12 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
508508
// Access to the union's fields: this is `std` and we know that the `r#try`
509509
// intrinsic fills in the `r` or `p` union field based on its return value.
510510
//
511-
// The call to `intrinsics::r#try` is made safe by:
511+
// The call to `intrinsics::catch_unwind` is made safe by:
512512
// - `do_call`, the first argument, can be called with the initial `data_ptr`.
513513
// - `do_catch`, the second argument, can be called with the `data_ptr` as well.
514514
// See their safety preconditions for more information
515515
unsafe {
516-
return if intrinsics::r#try(do_call::<F, R>, data_ptr, do_catch::<F, R>) == 0 {
516+
return if intrinsics::catch_unwind(do_call::<F, R>, data_ptr, do_catch::<F, R>) == 0 {
517517
Ok(ManuallyDrop::into_inner(data.r))
518518
} else {
519519
Err(ManuallyDrop::into_inner(data.p))
@@ -540,7 +540,7 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
540540
// Its must contains a valid `f` (type: F) value that can be use to fill
541541
// `data.r`.
542542
//
543-
// This function cannot be marked as `unsafe` because `intrinsics::r#try`
543+
// This function cannot be marked as `unsafe` because `intrinsics::catch_unwind`
544544
// expects normal function pointers.
545545
#[inline]
546546
fn do_call<F: FnOnce() -> R, R>(data: *mut u8) {
@@ -562,7 +562,7 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
562562
// Since this uses `cleanup` it also hinges on a correct implementation of
563563
// `__rustc_panic_cleanup`.
564564
//
565-
// This function cannot be marked as `unsafe` because `intrinsics::r#try`
565+
// This function cannot be marked as `unsafe` because `intrinsics::catch_unwind`
566566
// expects normal function pointers.
567567
#[inline]
568568
#[rustc_nounwind] // `intrinsic::r#try` requires catch fn to be nounwind

src/tools/miri/src/concurrency/thread.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ pub struct Thread<'mir, 'tcx> {
143143
join_status: ThreadJoinStatus,
144144

145145
/// Stack of active panic payloads for the current thread. Used for storing
146-
/// the argument of the call to `miri_start_panic` (the panic payload) when unwinding.
146+
/// the argument of the call to `miri_start_unwind` (the panic payload) when unwinding.
147147
/// This is pointer-sized, and matches the `Payload` type in `src/libpanic_unwind/miri.rs`.
148148
///
149149
/// In real unwinding, the payload gets passed as an argument to the landing pad,

src/tools/miri/src/shims/foreign_items.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
6868
let ret = match ret {
6969
None =>
7070
match link_name.as_str() {
71-
"miri_start_panic" => {
72-
// `check_shim` happens inside `handle_miri_start_panic`.
73-
this.handle_miri_start_panic(abi, link_name, args, unwind)?;
71+
"miri_start_unwind" => {
72+
// `check_shim` happens inside `handle_miri_start_unwind`.
73+
this.handle_miri_start_unwind(abi, link_name, args, unwind)?;
7474
return Ok(None);
7575
}
7676
// This matches calls to the foreign item `panic_impl`.

src/tools/miri/src/shims/intrinsics/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
5454

5555
// Some intrinsics are special and need the "ret".
5656
match intrinsic_name {
57-
"try" => return this.handle_try(args, dest, ret),
57+
"catch_unwind" => return this.handle_catch_unwind(args, dest, ret),
5858
_ => {}
5959
}
6060

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
//! The core pieces of the runtime are:
44
//! - An implementation of `__rust_maybe_catch_panic` that pushes the invoked stack frame with
55
//! some extra metadata derived from the panic-catching arguments of `__rust_maybe_catch_panic`.
6-
//! - A hack in `libpanic_unwind` that calls the `miri_start_panic` intrinsic instead of the
6+
//! - A hack in `libpanic_unwind` that calls the `miri_start_unwind` intrinsic instead of the
77
//! target-native panic runtime. (This lives in the rustc repo.)
8-
//! - An implementation of `miri_start_panic` that stores its argument (the panic payload), and then
8+
//! - An implementation of `miri_start_unwind` that stores its argument (the panic payload), and then
99
//! immediately returns, but on the *unwind* edge (not the normal return edge), thus initiating unwinding.
1010
//! - A hook executed each time a frame is popped, such that if the frame pushed by `__rust_maybe_catch_panic`
1111
//! gets popped *during unwinding*, we take the panic payload and store it according to the extra
@@ -44,9 +44,9 @@ impl VisitProvenance for CatchUnwindData<'_> {
4444

4545
impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriInterpCx<'mir, 'tcx> {}
4646
pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
47-
/// Handles the special `miri_start_panic` intrinsic, which is called
47+
/// Handles the special `miri_start_unwind` intrinsic, which is called
4848
/// by libpanic_unwind to delegate the actual unwinding process to Miri.
49-
fn handle_miri_start_panic(
49+
fn handle_miri_start_unwind(
5050
&mut self,
5151
abi: Abi,
5252
link_name: Symbol,
@@ -55,7 +55,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
5555
) -> InterpResult<'tcx> {
5656
let this = self.eval_context_mut();
5757

58-
trace!("miri_start_panic: {:?}", this.frame().instance);
58+
trace!("miri_start_unwind: {:?}", this.frame().instance);
5959

6060
// Get the raw pointer stored in arg[0] (the panic payload).
6161
let [payload] = this.check_shim(abi, Abi::Rust, link_name, args)?;
@@ -69,7 +69,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
6969
}
7070

7171
/// Handles the `try` intrinsic, the underlying implementation of `std::panicking::try`.
72-
fn handle_try(
72+
fn handle_catch_unwind(
7373
&mut self,
7474
args: &[OpTy<'tcx, Provenance>],
7575
dest: &PlaceTy<'tcx, Provenance>,
@@ -85,7 +85,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
8585
// what that is), and returns 1.
8686
// The `payload` is passed (by libstd) to `__rust_panic_cleanup`, which is then expected to
8787
// return a `Box<dyn Any + Send + 'static>`.
88-
// In Miri, `miri_start_panic` is passed exactly that type, so we make the `payload` simply
88+
// In Miri, `miri_start_unwind` is passed exactly that type, so we make the `payload` simply
8989
// a pointer to `Box<dyn Any + Send + 'static>`.
9090

9191
// Get all the arguments.
@@ -141,7 +141,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
141141
// We set the return value of `try` to 1, since there was a panic.
142142
this.write_scalar(Scalar::from_i32(1), &catch_unwind.dest)?;
143143

144-
// The Thread's `panic_payload` holds what was passed to `miri_start_panic`.
144+
// The Thread's `panic_payload` holds what was passed to `miri_start_unwind`.
145145
// This is exactly the second argument we need to pass to `catch_fn`.
146146
let payload = this.active_thread_mut().panic_payloads.pop().unwrap();
147147

src/tools/miri/tests/fail/function_calls/check_callback_abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fn main() {
88
unsafe {
99
// Make sure we check the ABI when Miri itself invokes a function
1010
// as part of a shim implementation.
11-
std::intrinsics::r#try(
11+
std::intrinsics::catch_unwind(
1212
//~^ ERROR: calling a function with ABI C using caller ABI Rust
1313
std::mem::transmute::<extern "C" fn(*mut u8), _>(try_fn),
1414
std::ptr::null_mut(),

src/tools/miri/tests/fail/function_calls/check_callback_abi.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
error: Undefined Behavior: calling a function with ABI C using caller ABI Rust
22
--> $DIR/check_callback_abi.rs:LL:CC
33
|
4-
LL | / std::intrinsics::r#try(
4+
LL | / std::intrinsics::catch_unwind(
55
LL | |
66
LL | | std::mem::transmute::<extern "C" fn(*mut u8), _>(try_fn),
77
LL | | std::ptr::null_mut(),

src/tools/miri/tests/fail/panic/bad_miri_start_panic.rs src/tools/miri/tests/fail/panic/bad_miri_start_unwind.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
#![feature(c_unwind)]
44

55
extern "C" {
6-
fn miri_start_panic(payload: *mut u8) -> !;
6+
fn miri_start_unwind(payload: *mut u8) -> !;
77
}
88

99
fn main() {
10-
unsafe { miri_start_panic(&mut 0) }
10+
unsafe { miri_start_unwind(&mut 0) }
1111
//~^ ERROR: unwinding past a stack frame that does not allow unwinding
1212
}

src/tools/miri/tests/fail/panic/bad_miri_start_panic.stderr src/tools/miri/tests/fail/panic/bad_miri_start_unwind.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
WARNING: the flag `-Zmiri-disable-abi-check` is deprecated and planned to be removed.
22
If you have a use-case for it, please file an issue.
33
error: Undefined Behavior: unwinding past a stack frame that does not allow unwinding
4-
--> $DIR/bad_miri_start_panic.rs:LL:CC
4+
--> $DIR/bad_miri_start_unwind.rs:LL:CC
55
|
6-
LL | unsafe { miri_start_panic(&mut 0) }
7-
| ^^^^^^^^^^^^^^^^^^^^^^^^ unwinding past a stack frame that does not allow unwinding
6+
LL | unsafe { miri_start_unwind(&mut 0) }
7+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ unwinding past a stack frame that does not allow unwinding
88
|
99
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
1010
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
1111
= note: BACKTRACE:
12-
= note: inside `main` at $DIR/bad_miri_start_panic.rs:LL:CC
12+
= note: inside `main` at $DIR/bad_miri_start_unwind.rs:LL:CC
1313

1414
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1515

src/tools/miri/tests/fail/panic/unwind_panic_abort.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
//! Unwinding despite `-C panic=abort` is an error.
44
55
extern "Rust" {
6-
fn miri_start_panic(payload: *mut u8) -> !;
6+
fn miri_start_unwind(payload: *mut u8) -> !;
77
}
88

99
fn main() {
1010
unsafe {
11-
miri_start_panic(&mut 0); //~ ERROR: unwinding past a stack frame that does not allow unwinding
11+
miri_start_unwind(&mut 0); //~ ERROR: unwinding past a stack frame that does not allow unwinding
1212
}
1313
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: unwinding past a stack frame that does not allow unwinding
22
--> $DIR/unwind_panic_abort.rs:LL:CC
33
|
4-
LL | miri_start_panic(&mut 0);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^ unwinding past a stack frame that does not allow unwinding
4+
LL | miri_start_unwind(&mut 0);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ unwinding past a stack frame that does not allow unwinding
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

src/tools/miri/tests/pass/function_calls/disable_abi_check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn main() {
1515
unsafe {
1616
let _ = malloc(0);
1717
std::mem::transmute::<fn(), extern "C" fn()>(foo)();
18-
std::intrinsics::r#try(
18+
std::intrinsics::catch_unwind(
1919
std::mem::transmute::<extern "C" fn(*mut u8), _>(try_fn),
2020
std::ptr::null_mut(),
2121
|_, _| unreachable!(),

src/tools/miri/tests/utils/miri_extern.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ extern "Rust" {
5656
///
5757
/// This is internal and unstable and should not be used; we give it here
5858
/// just to be complete.
59-
pub fn miri_start_panic(payload: *mut u8) -> !;
59+
pub fn miri_start_unwind(payload: *mut u8) -> !;
6060

6161
/// Miri-provided extern function to get the internal unique identifier for the allocation that a pointer
6262
/// points to. If this pointer is invalid (not pointing to an allocation), interpretation will abort.

tests/assembly/wasm_exceptions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub fn test_cleanup() {
4141
#[no_mangle]
4242
pub fn test_rtry() {
4343
unsafe {
44-
core::intrinsics::r#try(|_| {
44+
core::intrinsics::catch_unwind(|_| {
4545
may_panic();
4646
}, core::ptr::null_mut(), |data, exception| {
4747
log_number(data as usize);

tests/codegen/wasm_exceptions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn test_cleanup() {
3535
#[no_mangle]
3636
pub fn test_rtry() {
3737
unsafe {
38-
core::intrinsics::r#try(|_| {
38+
core::intrinsics::catch_unwind(|_| {
3939
may_panic();
4040
}, core::ptr::null_mut(), |data, exception| {
4141
log_number(data as usize);

tests/run-make/wasm-exceptions-nostd/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub extern "C" fn start() -> usize {
3939
let data = 0x1234usize as *mut u8; // Something to recognize
4040

4141
unsafe {
42-
core::intrinsics::r#try(|data: *mut u8| {
42+
core::intrinsics::catch_unwind(|data: *mut u8| {
4343
let _log_on_drop = LogOnDrop;
4444

4545
logging::log_str(&alloc::format!("`r#try` called with ptr {:?}", data));

0 commit comments

Comments
 (0)