-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Labels
unsound?Unsure if this unsafe code is soundUnsure if this unsafe code is sound
Description
The rebind macro has this definition:
Lines 96 to 102 in 7136b74
| macro_rules! rebind { | |
| ($item:ident, $arena:ident) => { | |
| #[allow(unused_qualifications)] | |
| let bits: $crate::object::RawObj = $item.into(); | |
| let $item = unsafe { $arena.rebind_raw_ptr(bits) }; | |
| }; | |
| } |
We are casting the object into a raw form that removes the lifetime. Then we call an unsafe function to create a new object from that raw pointer
Why this is safe
We are not actually changing the &mut reference to Arena. Instead we are releasing it then reborrowing it immutabley. We make sure to shadow the name so the old binding is no longer available.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
unsound?Unsure if this unsafe code is soundUnsure if this unsafe code is sound