We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 8426bdb + 2b52d2f commit b2c44acCopy full SHA for b2c44ac
glib/src/subclass/types.rs
@@ -968,10 +968,9 @@ pub fn register_type<T: ObjectSubclass>() -> Type {
968
// Must not be a dangling pointer so let's create some uninitialized memory
969
let priv_ = std::mem::MaybeUninit::<PrivateStruct<T>>::uninit();
970
let ptr = priv_.as_ptr();
971
- // FIXME: Technically UB but we'd need std::ptr::raw_const for this
972
- let imp_ptr = &(*ptr).imp as *const _ as *const u8;
+ let imp_ptr = std::ptr::addr_of!((*ptr).imp) as *const u8;
973
let ptr = ptr as *const u8;
974
- imp_ptr as isize - ptr as isize
+ imp_ptr.offset_from(ptr)
975
};
976
977
let iface_types = T::Interfaces::iface_infos();
0 commit comments