mirror of
https://github.com/openharmony/third_party_rust_memoffset.git
synced 2026-07-19 22:44:17 -04:00
no need to use NonNull
This commit is contained in:
+3
-4
@@ -39,10 +39,9 @@ macro_rules! _memoffset__let_base_ptr {
|
||||
#[doc(hidden)]
|
||||
macro_rules! _memoffset__let_base_ptr {
|
||||
($name:ident, $type:tt) => {
|
||||
// No UB right here, but we will later offset into a field
|
||||
// of this pointer, and that is UB when the pointer is dangling.
|
||||
let non_null = $crate::ptr::NonNull::<$type>::dangling();
|
||||
let $name = non_null.as_ptr() as *const $type;
|
||||
// No UB right here, but we will later dereference this pointer to
|
||||
// offset into a field, and that is UB when the pointer is dangling.
|
||||
let $name = $crate::mem::align_of::<$type>() as *const $type;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user