diff options
| author | syvb <me@iter.ca> | 2024-01-29 18:20:45 -0500 |
|---|---|---|
| committer | David Wood <agile.lion3441@fuligin.ink> | 2024-01-30 09:56:43 +0000 |
| commit | 1734d4337435f074a39eec034247426214dc4127 (patch) | |
| tree | 30de6fe76d6135215e98019d32a243ffd6b79653 /src/doc/rustc-dev-guide | |
| parent | d4d56790289f12244377bb61c0fc69569e6b43b2 (diff) | |
| download | rust-1734d4337435f074a39eec034247426214dc4127.tar.gz rust-1734d4337435f074a39eec034247426214dc4127.zip | |
Update uses of renamed BoxMeUp to PanicPayload
Diffstat (limited to 'src/doc/rustc-dev-guide')
| -rw-r--r-- | src/doc/rustc-dev-guide/src/panic-implementation.md | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/doc/rustc-dev-guide/src/panic-implementation.md b/src/doc/rustc-dev-guide/src/panic-implementation.md index 8d1a852c994..c2fe6ebd7b0 100644 --- a/src/doc/rustc-dev-guide/src/panic-implementation.md +++ b/src/doc/rustc-dev-guide/src/panic-implementation.md @@ -66,22 +66,22 @@ control passes to `rust_panic_with_hook`. This method is responsible for invoking the global panic hook, and checking for double panics. Finally, we call `__rust_start_panic`, which is provided by the panic runtime. -The call to `__rust_start_panic` is very weird - it is passed a `*mut &mut dyn BoxMeUp`, +The call to `__rust_start_panic` is very weird - it is passed a `*mut &mut dyn PanicPayload`, converted to an `usize`. Let's break this type down: -1. `BoxMeUp` is an internal trait. It is implemented for `PanicPayload` +1. `PanicPayload` is an internal trait. It is implemented for `PanicPayload` (a wrapper around the user-supplied payload type), and has a method -`fn box_me_up(&mut self) -> *mut (dyn Any + Send)`. +`fn take_box(&mut self) -> *mut (dyn Any + Send)`. This method takes the user-provided payload (`T: Any + Send`), boxes it, and converts the box to a raw pointer. -2. When we call `__rust_start_panic`, we have an `&mut dyn BoxMeUp`. +2. When we call `__rust_start_panic`, we have an `&mut dyn PanicPayload`. However, this is a fat pointer (twice the size of a `usize`). To pass this to the panic runtime across an FFI boundary, we take a mutable -reference *to this mutable reference* (`&mut &mut dyn BoxMeUp`), and convert it to a raw pointer -(`*mut &mut dyn BoxMeUp`). The outer raw pointer is a thin pointer, since it points to a `Sized` -type (a mutable reference). Therefore, we can convert this thin pointer into a `usize`, which -is suitable for passing across an FFI boundary. +reference *to this mutable reference* (`&mut &mut dyn PanicPayload`), and convert it to a raw +pointer (`*mut &mut dyn PanicPayload`). The outer raw pointer is a thin pointer, since it points to +a `Sized` type (a mutable reference). Therefore, we can convert this thin pointer into a `usize`, +which is suitable for passing across an FFI boundary. Finally, we call `__rust_start_panic` with this `usize`. We have now entered the panic runtime. @@ -96,8 +96,8 @@ as you would expect. `panic_unwind` is the more interesting case. In its implementation of `__rust_start_panic`, we take the `usize`, convert -it back to a `*mut &mut dyn BoxMeUp`, dereference it, and call `box_me_up` -on the `&mut dyn BoxMeUp`. At this point, we have a raw pointer to the payload +it back to a `*mut &mut dyn PanicPayload`, dereference it, and call `take_box` +on the `&mut dyn PanicPayload`. At this point, we have a raw pointer to the payload itself (a `*mut (dyn Send + Any)`): that is, a raw pointer to the actual value provided by the user who called `panic!`. |
