Skip to content

Commit

Permalink
Improve documentation in raise module
Browse files Browse the repository at this point in the history
- Improve safety comment on `ExceptionPayload` unsafe impl
- Document why `panic::resume_unwind` is used instead of `panic_any!`
  • Loading branch information
lopopolo committed Nov 8, 2022
1 parent 2414e9c commit 958bece
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion artichoke-backend/src/raise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct ExceptionPayload {
inner: Value,
}

// SAFETY:
// SAFETY: this panic payload never crosses a thread boundary.
//
// - mruby is single threaded and cannot be `Send`.
// - This struct is used directly in `std::panic::resume_unwind` and is not used
Expand All @@ -33,6 +33,8 @@ unsafe impl Send for ExceptionPayload {}
#[no_mangle]
unsafe extern "C-unwind" fn artichoke_exc_throw(mrb: *mut sys::mrb_state, exc: sys::mrb_value) -> ! {
let _ = mrb;
// Use `panic::resume_unwind` instead of `panic_any!` here to avoid running
// the built-in panic hook and printing stack to stderr.
panic::resume_unwind(Box::new(ExceptionPayload {
inner: Value::from(exc),
}));
Expand Down

0 comments on commit 958bece

Please sign in to comment.