Fix line lengths

This commit is contained in:
Aaron Hill 2019-12-02 13:19:19 -05:00 committed by Who? Me?!
parent db5de44ebd
commit 971c7fae9c
1 changed files with 8 additions and 5 deletions

View File

@ -4,7 +4,8 @@
There are actually two panic macros - one defined in `libcore`, and one defined in `libstd`. There are actually two panic macros - one defined in `libcore`, and one defined in `libstd`.
This is due to the fact that code in `libcore` can panic. `libcore` is built before `libstd`, This is due to the fact that code in `libcore` can panic. `libcore` is built before `libstd`,
but we want panics to use the same machinery at runtime, whether they originate in `libcore` or `libstd`. but we want panics to use the same machinery at runtime, whether they originate in `libcore`
or `libstd`.
##### libcore definition of panic! ##### libcore definition of panic!
@ -65,12 +66,14 @@ 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 BoxMeUp```,
converted to an `usize`. Let's break this type down: converted to an `usize`. Let's break this type down:
1. `BoxMeUp` is an internal trait. It is implemented for `PanicPayload` (a wrapper around the user-supplied 1. `BoxMeUp` is an internal trait. It is implemented for `PanicPayload`
payload type), and has a method ```fn box_me_up(&mut self) -> *mut (dyn Any + Send)```. (a wrapper around the user-supplied payload type), and has a method
```fn box_me_up(&mut self) -> *mut (dyn Any + Send)```.
This method takes the user-provided payload (`T: Any + Send`), boxes it, and convertes the box to a raw pointer. This method takes the user-provided payload (`T: Any + Send`), boxes it, and convertes the box to a raw pointer.
2. When we call ```__rust_start_panic```, we have an `&mut dyn BoxMeUp`. However, this is a fat pointer 2. When we call ```__rust_start_panic```, we have an `&mut dyn BoxMeUp`.
(twice the size of a `usize`). To pass this to the panic runtime across an FFI boundary, we take a mutable 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 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` (`*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 type (a mutable reference). Therefore, we can convert this thin pointer into a `usize`, which