Replace feature(layout_for_ptr)
with feature(layout_for_meta)
#67
Labels
api-change-proposal
A proposal to add or alter unstable APIs in the standard libraries
T-libs-api
waiting-on-author
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: