@@ -66,22 +66,22 @@ control passes to `rust_panic_with_hook`. This method is responsible
66
66
for invoking the global panic hook, and checking for double panics. Finally,
67
67
we call ` __rust_start_panic ` , which is provided by the panic runtime.
68
68
69
- The call to ` __rust_start_panic ` is very weird - it is passed a ` *mut &mut dyn BoxMeUp ` ,
69
+ The call to ` __rust_start_panic ` is very weird - it is passed a ` *mut &mut dyn PanicPayload ` ,
70
70
converted to an ` usize ` . Let's break this type down:
71
71
72
- 1 . ` BoxMeUp ` is an internal trait. It is implemented for ` PanicPayload `
72
+ 1 . ` PanicPayload ` is an internal trait. It is implemented for ` PanicPayload `
73
73
(a wrapper around the user-supplied payload type), and has a method
74
- ` fn box_me_up (&mut self) -> *mut (dyn Any + Send) ` .
74
+ ` fn take_box (&mut self) -> *mut (dyn Any + Send) ` .
75
75
This method takes the user-provided payload (` T: Any + Send ` ),
76
76
boxes it, and converts the box to a raw pointer.
77
77
78
- 2 . When we call ` __rust_start_panic ` , we have an ` &mut dyn BoxMeUp ` .
78
+ 2 . When we call ` __rust_start_panic ` , we have an ` &mut dyn PanicPayload ` .
79
79
However, this is a fat pointer (twice the size of a ` usize ` ).
80
80
To pass this to the panic runtime across an FFI boundary, we take a mutable
81
- reference * to this mutable reference* (` &mut &mut dyn BoxMeUp ` ), and convert it to a raw pointer
82
- (` *mut &mut dyn BoxMeUp ` ). The outer raw pointer is a thin pointer, since it points to a ` Sized `
83
- type (a mutable reference). Therefore, we can convert this thin pointer into a ` usize ` , which
84
- is suitable for passing across an FFI boundary.
81
+ reference * to this mutable reference* (` &mut &mut dyn PanicPayload ` ), and convert it to a raw
82
+ pointer (` *mut &mut dyn PanicPayload ` ). The outer raw pointer is a thin pointer, since it points to
83
+ a ` Sized ` type (a mutable reference). Therefore, we can convert this thin pointer into a ` usize ` ,
84
+ which is suitable for passing across an FFI boundary.
85
85
86
86
Finally, we call ` __rust_start_panic ` with this ` usize ` . We have now entered the panic runtime.
87
87
@@ -96,8 +96,8 @@ as you would expect.
96
96
` panic_unwind ` is the more interesting case.
97
97
98
98
In its implementation of ` __rust_start_panic ` , we take the ` usize ` , convert
99
- it back to a ` *mut &mut dyn BoxMeUp ` , dereference it, and call ` box_me_up `
100
- on the ` &mut dyn BoxMeUp ` . At this point, we have a raw pointer to the payload
99
+ it back to a ` *mut &mut dyn PanicPayload ` , dereference it, and call ` take_box `
100
+ on the ` &mut dyn PanicPayload ` . At this point, we have a raw pointer to the payload
101
101
itself (a ` *mut (dyn Send + Any) ` ): that is, a raw pointer to the actual value
102
102
provided by the user who called ` panic! ` .
103
103
0 commit comments