-
Notifications
You must be signed in to change notification settings - Fork 19
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
Replace feature(layout_for_ptr)
with feature(layout_for_meta)
#67
Comments
This seems to assume the size of the object can fully be determined by the metadata, without the object pointer. But don't we want to support custom dynamically sized types in the future, like a thin |
Also, it sounds like this ACP is referencing that lang team design note to say that there are problems with having types that require reading the pointee to get the size, but with my lang hat on, I don't understand how that note implies such problems. |
We discussed this in the libs-api meeting today and decided not to accept this for several reasons:
|
Slight correction: actually this would work with custom DSTs, however the first point still stands so it doesn't make sense to remove the old API. |
Makes enough sense to me. AIUI these API may potentially make sense in addition to the I don't see the requirement of a turbofish as too odd, since the sized I might make a more constrained ACP once I've wrapped up some of my open work (I still think that a type level guarantee of no pointer access is highly useful, i.e. (Notably, |
Proposal
Problem statement
Tracking issue: rust-lang/rust#69835
Current unstable API
Proposed unstable API
(bikeshed away)
Motivation
Per T-lang, these APIs fit nicely into the general story of
ptr_metadata
. The metadata is currently all that is required to calculate pointee layout, and there are potential language issues with allowing layout calculation to access the data pointer.Solution sketches
See above for the proposed unstable API change.
Alternatively, the
ptr_metadata
APIs could all be adjusted to deal in aptr::Metadata<T>
wrapper type (c.f. rust-lang/rust#97052), and thensize_of
/align_of
/layout
methods could be provided like they are forDynMetadata
. Unfortunately, they cannot be made (infallibly) safe, because it is perfectly safe/acceptable to cast raw pointers such that their metadata/type combo describes a pointee larger than the address space.The former is the smaller change. The latter is potentially a more coherent design.
Of course, just providing all of the entry points is also an option.
Links and related work
ptr::Metadata<T>
type for the purpose of coercions, which cannot be provided for<T as Pointee>::Metadata
layout_for_ptr
tracking issueptr_metadata
tracking issueDynSized
lang-team#166 : describes what support for custom pointee layout might look likemetadata -> Layout
conversionWhat happens now?
This issue is part of the libs-api team API change proposal process. Once this issue is filed the libs-api team will review open proposals in its weekly meeting. You should receive feedback within a week or two.
The text was updated successfully, but these errors were encountered: