X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=library%2Fstd%2Fsrc%2Fpanicking.rs;h=6cd572cbe87c131b661d56d7483d62df2e2c551e;hb=a6bd5246da7806786b5c1f61d05a957c9ae68903;hp=8ba3feccb6bcc8f817efa43cd0b373124c27bcd8;hpb=8cfa7b4ec9d314a412f79c1748bd2dfa7575b2e3;p=rust.git diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs index 8ba3feccb6b..6cd572cbe87 100644 --- a/library/std/src/panicking.rs +++ b/library/std/src/panicking.rs @@ -44,11 +44,11 @@ extern "C" { fn __rust_panic_cleanup(payload: *mut u8) -> *mut (dyn Any + Send + 'static); - /// `payload` is actually a `*mut &mut dyn BoxMeUp` but that would cause FFI warnings. - /// It cannot be `Box` because the other end of this call does not depend - /// on liballoc, and thus cannot use `Box`. + /// `payload` is passed through another layer of raw pointers as `&mut dyn Trait` is not + /// FFI-safe. `BoxMeUp` lazily performs allocation only when needed (this avoids allocations + /// when using the "abort" panic runtime). #[unwind(allowed)] - fn __rust_start_panic(payload: usize) -> u32; + fn __rust_start_panic(payload: *mut &mut dyn BoxMeUp) -> u32; } /// This function is called by the panic runtime if FFI code catches a Rust @@ -637,7 +637,7 @@ fn get(&mut self) -> &(dyn Any + Send) { fn rust_panic(mut msg: &mut dyn BoxMeUp) -> ! { let code = unsafe { let obj = &mut msg as *mut &mut dyn BoxMeUp; - __rust_start_panic(obj as usize) + __rust_start_panic(obj) }; rtabort!("failed to initiate panic, error {}", code) }