-
Notifications
You must be signed in to change notification settings - Fork 142
Open
Description
Needed by #497
Could be supported by #1797
A type with the same layout as T (including alignment) but fewer bit validity requirements. Bytes must be initialized if required by T, but they may be uninitialized if permitted by T. This is exactly equivalent to the semantics of the AsInitialized Ptr invariant:
Lines 260 to 291 in 06fd1b2
| /// The byte ranges initialized in `T` are also initialized in | |
| /// the referent. | |
| /// | |
| /// Formally: uninitialized bytes may only be present in | |
| /// `Ptr<T>`'s referent where they are guaranteed to be present | |
| /// in `T`. This is a dynamic property: if, at a particular byte | |
| /// offset, a valid enum discriminant is set, the subsequent | |
| /// bytes may only have uninitialized bytes as specificed by the | |
| /// corresponding enum. | |
| /// | |
| /// Formally, given `len = size_of_val_raw(ptr)`, at every byte | |
| /// offset, `b`, in the range `[0, len)`: | |
| /// - If, in any instance `t: T` of length `len`, the byte at | |
| /// offset `b` in `t` is initialized, then the byte at offset | |
| /// `b` within `*ptr` must be initialized. | |
| /// - Let `c` be the contents of the byte range `[0, b)` in | |
| /// `*ptr`. Let `S` be the subset of valid instances of `T` of | |
| /// length `len` which contain `c` in the offset range `[0, | |
| /// b)`. If, in any instance of `t: T` in `S`, the byte at | |
| /// offset `b` in `t` is initialized, then the byte at offset | |
| /// `b` in `*ptr` must be initialized. | |
| /// | |
| /// Pragmatically, this means that if `*ptr` is guaranteed to | |
| /// contain an enum type at a particular offset, and the enum | |
| /// discriminant stored in `*ptr` corresponds to a valid | |
| /// variant of that enum type, then it is guaranteed that the | |
| /// appropriate bytes of `*ptr` are initialized as defined by | |
| /// that variant's bit validity (although note that the | |
| /// variant may contain another enum type, in which case the | |
| /// same rules apply depending on the state of its | |
| /// discriminant, and so on recursively). | |
| AsInitialized < Initialized | Valid, |
cc @kupiakos
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels