]> git.lizzy.rs Git - rust.git/commitdiff
update panicking comments in libstd
authorRalf Jung <post@ralfj.de>
Sat, 14 Mar 2020 10:36:40 +0000 (11:36 +0100)
committerRalf Jung <post@ralfj.de>
Sat, 14 Mar 2020 10:36:40 +0000 (11:36 +0100)
src/libstd/panicking.rs

index 0be71b52d9edd559d2efadfeec6553c3b332f54c..7bc86650a7324d41168871498f2ad8200e3cd8eb 100644 (file)
@@ -251,21 +251,20 @@ union Data<F, R> {
     //
     // We go through a transition where:
     //
-    // * First, we set the data to be the closure that we're going to call.
+    // * First, we set the data field `f` to be the argumentless closure that we're going to call.
     // * When we make the function call, the `do_call` function below, we take
-    //   ownership of the function pointer. At this point the `Data` union is
+    //   ownership of the function pointer. At this point the `data` union is
     //   entirely uninitialized.
     // * If the closure successfully returns, we write the return value into the
-    //   data's return slot. Note that `ptr::write` is used as it's overwriting
-    //   uninitialized data.
+    //   data's return slot (field `r`).
+    // * If the closure panics (`do_catch` below), we write the panic payload into field `p`.
     // * Finally, when we come back out of the `try` intrinsic we're
     //   in one of two states:
     //
     //      1. The closure didn't panic, in which case the return value was
-    //         filled in. We move it out of `data` and return it.
-    //      2. The closure panicked, in which case the return value wasn't
-    //         filled in. In this case the entire `data` union is invalid, so
-    //         there is no need to drop anything.
+    //         filled in. We move it out of `data.r` and return it.
+    //      2. The closure panicked, in which case the panic payload was
+    //         filled in. We move it out of `data.p` and return it.
     //
     // Once we stack all that together we should have the "most efficient'
     // method of calling a catch panic whilst juggling ownership.