about summary refs log tree commit diff
path: root/library
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2020-12-25 23:37:27 +0100
committerRalf Jung <post@ralfj.de>2020-12-25 23:37:27 +0100
commit1600f7d693c5fba1b279f8d96ec714c897e21799 (patch)
treea8b47b92191840e170894f7511e93126d36b946a /library
parent7524eb2704b025a6b36bcc280ce2a81bdb782699 (diff)
downloadrust-1600f7d693c5fba1b279f8d96ec714c897e21799.tar.gz
rust-1600f7d693c5fba1b279f8d96ec714c897e21799.zip
fix another comment, and make __rust_start_panic code a bit more semantically clear
Diffstat (limited to 'library')
-rw-r--r--library/panic_unwind/src/lib.rs4
-rw-r--r--library/std/src/panicking.rs5
2 files changed, 5 insertions, 4 deletions
diff --git a/library/panic_unwind/src/lib.rs b/library/panic_unwind/src/lib.rs
index 1ac050be3e4..9ce9c477ec0 100644
--- a/library/panic_unwind/src/lib.rs
+++ b/library/panic_unwind/src/lib.rs
@@ -105,7 +105,7 @@ pub unsafe extern "C" fn __rust_panic_cleanup(payload: *mut u8) -> *mut (dyn Any
 #[rustc_std_internal_symbol]
 #[unwind(allowed)]
 pub unsafe extern "C" fn __rust_start_panic(payload: *mut &mut dyn BoxMeUp) -> u32 {
-    let payload = (*payload).take_box();
+    let payload = Box::from_raw((*payload).take_box());
 
-    imp::panic(Box::from_raw(payload))
+    imp::panic(payload)
 }
diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs
index 7f4b739cbf8..6cd572cbe87 100644
--- a/library/std/src/panicking.rs
+++ b/library/std/src/panicking.rs
@@ -44,8 +44,9 @@ use realstd::io::set_output_capture;
 extern "C" {
     fn __rust_panic_cleanup(payload: *mut u8) -> *mut (dyn Any + Send + 'static);
 
-    /// `payload` is actually a `Box<dyn BoxMeUp>`, but we pass this by-reference 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: *mut &mut dyn BoxMeUp) -> u32;
 }