-
Notifications
You must be signed in to change notification settings - Fork 127
Generalize SizeEq to SizeFrom, support shrinking #2472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
joshlf
wants to merge
1
commit into
I46b18b4b1d10507b7e1d2e01b09dc4960cfcdce1
from
I6c793a9620ad75bdc0d26ab7c7cd1a0c7bef1b8b
Closed
Generalize SizeEq to SizeFrom, support shrinking #2472
joshlf
wants to merge
1
commit into
I46b18b4b1d10507b7e1d2e01b09dc4960cfcdce1
from
I6c793a9620ad75bdc0d26ab7c7cd1a0c7bef1b8b
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Mar 28, 2025
9ab2be6 to
c1009fc
Compare
522d450 to
7d3a9b3
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2472 +/- ##
==========================================
+ Coverage 88.91% 88.93% +0.02%
==========================================
Files 20 20
Lines 5313 5316 +3
==========================================
+ Hits 4724 4728 +4
+ Misses 589 588 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
c1009fc to
6338896
Compare
fbb37b8 to
bb9b06d
Compare
6338896 to
2115a6d
Compare
2115a6d to
7b9a12f
Compare
bb9b06d to
38c910a
Compare
7b9a12f to
baf0a15
Compare
38c910a to
454f974
Compare
baf0a15 to
9ac6a2d
Compare
454f974 to
f5fcda2
Compare
Base automatically changed from
Ib4bc62202e0b3b09d155333b525087f7aa8f02c2
to
main
June 3, 2025 19:50
7733216 to
cd6fc04
Compare
cd6fc04 to
674049b
Compare
Base automatically changed from
I910c77e45532313e316ee443f9cf70d0d74cff67
to
main
June 4, 2025 16:17
fa37094 to
97e2096
Compare
97e2096 to
20f0bc3
Compare
9728eab to
5a377c4
Compare
5a377c4 to
7a0c2de
Compare
9d12b2e to
7fbc7b4
Compare
7fbc7b4 to
63fc907
Compare
5774b01 to
30ab41e
Compare
63fc907 to
5d699c7
Compare
077c7bd to
a6f8897
Compare
31b5471 to
291b87b
Compare
Base automatically changed from
I1945c8e554dd80a0475462d0dc5e0ae1eb2e9ac4
to
main
June 9, 2025 18:50
291b87b to
9b25166
Compare
jswrenn
approved these changes
Jun 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
9b25166 to
3d8da5b
Compare
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
3d8da5b to
88213f3
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Generalize
SizeEq, renaming it toSizeFrom, and supporting castswhich shrink rather than preserve referent size.
This requires fairly deep surgery in our transmute taxonomy. We can no
longer rely on
SizeFrom::cast_from_rawpreserving referent size, whichmeans that all pointer transmutes must now reason about two types of
transmutes:
the destination value)
destination value and the destination permits mutation). In an
overwriting transmute, the resulting value is a concatenation of a
valid
Tand the suffix of a validU.(Note that size-preserving transmutes can be viewed as a special case of
size-shrinking transmutes.)
In order to support these semantics, we split
TransmuteFrominto twotraits:
TransmuteFrom(which supports shriking transmutes) andTransmuteOverwrite(which supports overwriting transmutes).While we're here, we simplify the relationship between
TryTransmuteFromPtr,MutationCompatible, andRead. In particular,TryTransmuteFromPtrnow has a single blanket impl which is bounded byMutationCompatible, andMutationCompatiblenow directly supportsthree cases (and no longer delegates to
Read):transmuted into the source type
destination type are
Immutablethe 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]
This PR is on branch transmute-ref-dst.