about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2019-11-25 12:16:08 +0100
committerRalf Jung <post@ralfj.de>2019-11-25 12:16:08 +0100
commit08f779cb4b481be58eeb5ecc421f69503780e8b1 (patch)
tree95896dbd33e56152d8f42a065317b70f7a3f5aff /src/libstd
parentcd5d0c7b102d2573165efdbd2ffc31c4a5be3bb5 (diff)
downloadrust-08f779cb4b481be58eeb5ecc421f69503780e8b1.tar.gz
rust-08f779cb4b481be58eeb5ecc421f69503780e8b1.zip
better comment and rename BoxMeUp::box_me_up to take_box
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/panicking.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs
index a0f6183d514..a16eec45b9a 100644
--- a/src/libstd/panicking.rs
+++ b/src/libstd/panicking.rs
@@ -340,6 +340,7 @@ fn panic_handler(info: &PanicInfo<'_>) -> ! {
             use crate::fmt::Write;
 
             let inner = self.inner;
+            // Lazily, the first time this gets called, run the actual string formatting.
             self.string.get_or_insert_with(|| {
                 let mut s = String::new();
                 drop(s.write_fmt(*inner));
@@ -349,7 +350,7 @@ fn panic_handler(info: &PanicInfo<'_>) -> ! {
     }
 
     unsafe impl<'a> BoxMeUp for PanicPayload<'a> {
-        fn box_me_up(&mut self) -> *mut (dyn Any + Send) {
+        fn take_box(&mut self) -> *mut (dyn Any + Send) {
             let contents = mem::take(self.fill());
             Box::into_raw(Box::new(contents))
         }
@@ -407,10 +408,10 @@ pub fn begin_panic<M: Any + Send>(msg: M, file_line_col: &(&'static str, u32, u3
     }
 
     unsafe impl<A: Send + 'static> BoxMeUp for PanicPayload<A> {
-        fn box_me_up(&mut self) -> *mut (dyn Any + Send) {
+        fn take_box(&mut self) -> *mut (dyn Any + Send) {
             let data = match self.inner.take() {
                 Some(a) => Box::new(a) as Box<dyn Any + Send>,
-                None => Box::new(()),
+                None => Box::new(()), // this should never happen: we got called twice
             };
             Box::into_raw(data)
         }
@@ -488,7 +489,7 @@ pub fn update_count_then_panic(msg: Box<dyn Any + Send>) -> ! {
     struct RewrapBox(Box<dyn Any + Send>);
 
     unsafe impl BoxMeUp for RewrapBox {
-        fn box_me_up(&mut self) -> *mut (dyn Any + Send) {
+        fn take_box(&mut self) -> *mut (dyn Any + Send) {
             Box::into_raw(mem::replace(&mut self.0, Box::new(())))
         }