Skip to content

Commit 1600f7d

Browse files
committed
fix another comment, and make __rust_start_panic code a bit more semantically clear
1 parent 7524eb2 commit 1600f7d

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

library/panic_unwind/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ pub unsafe extern "C" fn __rust_panic_cleanup(payload: *mut u8) -> *mut (dyn Any
105105
#[rustc_std_internal_symbol]
106106
#[unwind(allowed)]
107107
pub unsafe extern "C" fn __rust_start_panic(payload: *mut &mut dyn BoxMeUp) -> u32 {
108-
let payload = (*payload).take_box();
108+
let payload = Box::from_raw((*payload).take_box());
109109

110-
imp::panic(Box::from_raw(payload))
110+
imp::panic(payload)
111111
}

library/std/src/panicking.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ use realstd::io::set_output_capture;
4444
extern "C" {
4545
fn __rust_panic_cleanup(payload: *mut u8) -> *mut (dyn Any + Send + 'static);
4646

47-
/// `payload` is actually a `Box<dyn BoxMeUp>`, but we pass this by-reference because the other
48-
/// end of this call does not depend on liballoc, and thus cannot use `Box`.
47+
/// `payload` is passed through another layer of raw pointers as `&mut dyn Trait` is not
48+
/// FFI-safe. `BoxMeUp` lazily performs allocation only when needed (this avoids allocations
49+
/// when using the "abort" panic runtime).
4950
#[unwind(allowed)]
5051
fn __rust_start_panic(payload: *mut &mut dyn BoxMeUp) -> u32;
5152
}

0 commit comments

Comments
 (0)