about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-03-14 19:54:23 +0000
committerbors <bors@rust-lang.org>2020-03-14 19:54:23 +0000
commit7cdbc87a49b0b705a41a004a6d486b0952521ae7 (patch)
tree25d94247c97cf08fa81d3f72b247a8d2c0d2d1c4 /src/libstd
parent131772c5e0ba40cd656dedb5e1990d36e3ea31cf (diff)
parentb450e1baf4c35ad4812fba9cb1946ea20d405ad8 (diff)
downloadrust-7cdbc87a49b0b705a41a004a6d486b0952521ae7.tar.gz
rust-7cdbc87a49b0b705a41a004a6d486b0952521ae7.zip
Auto merge of #69999 - RalfJung:miri-unwind, r=oli-obk
adjust Miri to needs of changed unwinding strategy

As expected, https://github.com/rust-lang/rust/pull/67502 broke unwinding in Miri. To fix it we have to adjust parts of the engine and the panic runtime, which this PR does. The Miri-side changes are in https://github.com/rust-lang/miri/pull/1227.

Cc @oli-obk @Aaron1011 @Mark-Simulacrum @Amanieu
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/panicking.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs
index 0be71b52d9e..7bc86650a73 100644
--- a/src/libstd/panicking.rs
+++ b/src/libstd/panicking.rs
@@ -251,21 +251,20 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
     //
     // 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.