rework some unsafe parts

- removed some unsafe
- added some safety comments
- add explicit types to transmute calls
- reworked UntypedArenaPtr -> TypedArenaPtr conversion

might help with mthom/scryer-prolog#2438, I noticed fewer complains from miri after changing the default impl for `ArenaAllocated::alloc`
This commit is contained in:
Bennet Bleßmann
2024-07-05 23:45:02 +02:00
parent a93585080c
commit dd2548453b
5 changed files with 102 additions and 116 deletions

View File

@@ -743,6 +743,13 @@ impl UntypedArenaPtr {
unsafe { self.get_ptr().add(mem::size_of::<ArenaHeader>()) }
}
/// Safety
/// - this UntypedArenaPtr actuall pointee type is T
#[inline]
pub unsafe fn as_typed_ptr<T: ArenaAllocated>(self) -> TypedArenaPtr<T> {
T::typed_ptr(self)
}
#[inline]
pub fn get_mark_bit(self) -> bool {
self.m()