Skip to content

Commit 7468c30

Browse files
committed
Address some comments
1 parent 97452ca commit 7468c30

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

text/0000-dst-coercion.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- Feature Name: dst-coercions
1+
- Feature Name: dst_coercions
22
- Start Date: 2015-03-16
33
- RFC PR: (leave this empty)
44
- Rust Issue: (leave this empty)
@@ -51,7 +51,7 @@ An example implementation:
5151

5252
```
5353
impl<T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<Rc<U>> for Rc<T> {}
54-
impl<T: ?Sized+CoerceUnsized<U>, U: ?Sized> NonZero<U> for NonZero<T> {}
54+
impl<T: ?Sized+CoerceUnsized<U>, U: ?Sized> CoerceUnsized<NonZero<U>> for NonZero<T> {}
5555
5656
// For reference, the definitions of Rc and NonZero:
5757
pub struct Rc<T: ?Sized> {
@@ -107,15 +107,18 @@ not a general `Coerce` trait.
107107
* If the impl is for a built-in pointer type, we check nothing, otherwise...
108108
* The compiler checks that the `Self` type is a struct or tuple struct and that
109109
the `Target` type is a simple substitution of type parameters from the `Self`
110-
type (one day, with HKT, this could be a regular part of type checking, for now
110+
type (i.e., That `Self` is `Foo<Ts>`, `Target` is `Foo<Us>` and that there exist
111+
`Vs` and `Xs` (where `Xs` are all type parameters) such that `Target = [Vs/Xs]Self`.
112+
One day, with HKT, this could be a regular part of type checking, for now
111113
it must be an ad hoc check). We might enforce that this substitution is of the
112114
form `X/Y` where `X` and `Y` are both formal type parameters of the
113115
implementation (I don't think this is necessary, but it makes checking coercions
114116
easier and is satisfied for all smart pointers).
115117
* The compiler checks each field in the `Self` type against the corresponding field
116118
in the `Target` type. Assuming `Fs` is the type of a field in `Self` and `Ft` is
117119
the type of the corresponding field in `Target`, then either `Ft <: Fs` or
118-
`Fs: CoerceUnsized<Ft>` (note that this includes built-in coercions).
120+
`Fs: CoerceUnsized<Ft>` (note that this includes some built-in coercions, coercions
121+
unrelated to unsizing are excluded, these could probably be added later, if needed).
119122
* There must be only one field that is coerced.
120123
* We record for each impl, the index of the field in the `Self` type which is
121124
coerced.
@@ -156,8 +159,7 @@ all now, since all checking is postponed until trans or relies on traits and imp
156159

157160
# Drawbacks
158161

159-
Not as flexible as the previous proposal. Can't handle pointer-like types like
160-
`Option<Box<T>>`.
162+
Not as flexible as the previous proposal.
161163

162164
# Alternatives
163165

0 commit comments

Comments
 (0)