Add debug asserts to UntypedArenaPtr::build_with, ::get_tag and raw_ptr_as_cell!
These two functions are pretty unsafe, but having these assertions makes it easier to catch UB in testing.
This commit is contained in:
@@ -656,6 +656,7 @@ pub struct UntypedArenaPtr {
|
||||
impl UntypedArenaPtr {
|
||||
#[inline(always)]
|
||||
pub fn build_with(ptr: usize) -> Self {
|
||||
debug_assert!(ptr != 0);
|
||||
UntypedArenaPtr::new().with_ptr(ptr as u64)
|
||||
}
|
||||
}
|
||||
@@ -698,6 +699,7 @@ impl UntypedArenaPtr {
|
||||
#[inline]
|
||||
pub fn get_tag(self) -> ArenaHeaderTag {
|
||||
unsafe {
|
||||
debug_assert!(!self.get_ptr().is_null());
|
||||
let header = *(self.get_ptr() as *const ArenaHeader);
|
||||
header.get_tag()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user