Skip to content
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

specify that CoerceUnsized should ignore PhantomData fields #1234

Merged
merged 3 commits into from
Sep 4, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions text/0982-dst-coercion.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ in the `Target` type. Assuming `Fs` is the type of a field in `Self` and `Ft` is
the type of the corresponding field in `Target`, then either `Ft <: Fs` or
`Fs: CoerceUnsized<Ft>` (note that this includes some built-in coercions, coercions
unrelated to unsizing are excluded, these could probably be added later, if needed).
* There must be only one field that is coerced.
* There must be only one non-PhantomData field that is coerced.
* We record for each impl, the index of the field in the `Self` type which is
coerced.

Expand All @@ -135,7 +135,7 @@ is auto-deref'ed, but not autoref'ed.
### On encountering an adjustment (translation phase)

* In trans (which is post-monomorphisation) we should always be able to find an
impl for any `CoerceUnsized` bound.
impl for any `CoerceUnsized` bound.
* If the impl is for a built-in pointer type, then we use the current coercion
code for the various pointer kinds (`Box<T>` has different behaviour than `&` and
`*` pointers).
Expand Down Expand Up @@ -175,4 +175,14 @@ indicate the field type which is coerced, for example).

# Unresolved questions

None
It is unclear to what extent DST coercions should support multiple fields that
refer to the same type parameter. `PhantomData<T>` should definitely be
supported as an "extra" field that's skipped, but can all zero-sized fields
be skipped? Are there cases where this would enable by-passing the abstractions
that make some API safe?

# Updates since being accepted

Since it was accepted, the RFC has been updated as follows:

1. `CoerceUnsized` was specified to ingore PhantomData fields.