1
Fork 0

Also use mir::Offset for pointer add

This commit is contained in:
Scott McMurray 2023-04-25 22:41:34 -07:00
parent 8bcfc0e597
commit e1da77c76d
11 changed files with 117 additions and 77 deletions

View file

@ -916,8 +916,16 @@ impl<T: ?Sized> *const T {
where
T: Sized,
{
#[cfg(bootstrap)]
// SAFETY: the caller must uphold the safety contract for `offset`.
unsafe { self.offset(count as isize) }
unsafe {
self.offset(count as isize)
}
#[cfg(not(bootstrap))]
// SAFETY: the caller must uphold the safety contract for `offset`.
unsafe {
intrinsics::offset(self, count)
}
}
/// Calculates the offset from a pointer in bytes (convenience for `.byte_offset(count as isize)`).