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

DST custom coercions. #982

Merged
merged 5 commits into from Jun 3, 2015
Merged

DST custom coercions. #982

merged 5 commits into from Jun 3, 2015

Conversation

nrc
Copy link
Member

@nrc nrc commented Mar 16, 2015

Custom coercions allow smart pointers to fully participate in the DST system.
In particular, they allow practical use of Rc<T> and Arc<T> where T is unsized.

This RFC subsumes part of RFC 401 coercions.

Rendered

[edited to add rendered link]

@nrc nrc self-assigned this Mar 17, 2015

* If the impl is for a built-in pointer type, we check nothing, otherwise...
* The compiler checks that the `Self` type is a struct or tuple struct and that
the `Target` type is a simple substitution of type parameters from the `Self`
Copy link
Contributor

@nikomatsakis nikomatsakis Mar 18, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite know what "simple substitution of type parameters" means... but I think we want to check that both of them are applications of the same base type constructor. e.g. Foo<X> and Foo<Y> are ok, but not Foo<X> and Bar<Y>.

Copy link
Member Author

@nrc nrc Mar 18, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant that there exists some Ts (where Ts = a sequence of T) and some Xs such that Target = [Ts/Xs]Self and Self is not in Xs. Which I think subsumes your requirement, but also precludes some pathalogical cases such as Target = Foo<T1, T2>, Self = Foo<X, X>.

@nikomatsakis
Copy link
Contributor

@nikomatsakis nikomatsakis commented Mar 18, 2015

I read over the revised version -- it seems pretty good to me, I left a few comments.


```
impl<T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<Rc<U>> for Rc<T> {}
impl<T: ?Sized+CoerceUnsized<U>, U: ?Sized> NonZero<U> for NonZero<T> {}
Copy link
Member

@eddyb eddyb Mar 18, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to be implementing CoerceUnsized<NonZero<U>>?

Copy link
Member Author

@nrc nrc Mar 18, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@nrc nrc added the T-lang label May 15, 2015
@nikomatsakis
Copy link
Contributor

@nikomatsakis nikomatsakis commented May 21, 2015

@nrc did you plan to incorporate @eddyb's feedback here?

@nrc
Copy link
Member Author

@nrc nrc commented May 21, 2015

I do, I had forgotten this was not merged yet.

@nikomatsakis
Copy link
Contributor

@nikomatsakis nikomatsakis commented May 26, 2015

Hear ye, hear ye. This RFC is now in final comment period until June 2nd.

@nikomatsakis nikomatsakis added the final-comment-period label May 26, 2015
@nikomatsakis
Copy link
Contributor

@nikomatsakis nikomatsakis commented Jun 2, 2015

This RFC has been accepted. It is not yet merged to allow @nrc to incorporate final comments reflecting the current design. (It has been partially implemented in the meantime.)

-- Language design subteam

nrc added 5 commits Jun 3, 2015
Custom coercions allow smart pointers to fully participate in the DST system.
In particular, they allow practical use of `Rc<T>` and `Arc<T>` where `T` is unsized.

This RFC subsumes part of [RFC 401 coercions](https://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md).
@nrc
Copy link
Member Author

@nrc nrc commented Jun 3, 2015

@nikomatsakis updated

@nikomatsakis nikomatsakis merged commit 4b99006 into rust-lang:master Jun 3, 2015
nikomatsakis added a commit that referenced this issue Jun 3, 2015
@nikomatsakis
Copy link
Contributor

@nikomatsakis nikomatsakis commented Jun 3, 2015

Merged. Tracking issue is rust-lang/rust#18598

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-coercions A-dst final-comment-period T-lang
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants