This repository has been archived by the owner on Mar 4, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
glib: Don't store subclass impl/private data in an Option<T>
We don't know the exact memory layout of the Option<T> in relation to T so can't easily go from a *const T to the surrounding *const Option<T>. Since nightly from 2020-02-12 using both pointer types interchangeably causes segmentation faults as their memory layouts are not actually compatible and never were, but due to some compiler changes this actually causes crashes at runtime now. See rust-lang/rust#69102 for details. As an Option<_> was only used for some paranoid runtime checks that are not really needed, simply store T directly as impl/private data of subclasses. This has the side-effect of having zero-sized impl/private data types to actually occupy zero bytes of memory, and in some other cases to save a few bytes of the allocation.
- Loading branch information