You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Generalize `SizeEq`, renaming it to `SizeFrom`, and supporting casts
which shrink rather than preserve referent size.
This requires fairly deep surgery in our transmute taxonomy. We can no
longer rely on `SizeFrom::cast_from_raw` preserving referent size, which
means that all pointer transmutes must now reason about two types of
transmutes:
- Size-shrinking transmutes (in which the source value is larger than
the destination value)
- Overwriting transmutes (in which the source value is larger than the
destination value *and* the destination permits mutation). In an
overwriting transmute, the resulting value is a concatenation of a
valid `T` and the *suffix* of a valid `U`.
(Note that size-preserving transmutes can be viewed as a special case of
size-shrinking transmutes.)
In order to support these semantics, we split `TransmuteFrom` into two
traits: `TransmuteFrom` (which supports shriking transmutes) and
`TransmuteOverwrite` (which supports overwriting transmutes).
While we're here, we simplify the relationship between
`TryTransmuteFromPtr`, `MutationCompatible`, and `Read`. In particular,
`TryTransmuteFromPtr` now has a single blanket impl which is bounded by
`MutationCompatible`, and `MutationCompatible` now directly supports
three cases (and no longer delegates to `Read`):
- Exclusive reference transmutes in which the destination type may be
transmuted into the source type
- Shared reference transmutes in which both the source and the
destination type are `Immutable`
- Shared reference transmutes which permit interior mutation, in which
the source and destination types may both be transmuted into one
another, and in which the source and destination types support
compatible interior mutation
Makes progress on #1817
Co-authored-by: Jack Wrenn <[email protected]>
gherrit-pr-id: I6c793a9620ad75bdc0d26ab7c7cd1a0c7bef1b8b
0 commit comments