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

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

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

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

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

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 Relevant to the language team, which will review and decide on the RFC. label May 15, 2015
@nikomatsakis
Copy link
Contributor

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

@nrc
Copy link
Member Author

nrc commented May 21, 2015

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

@nikomatsakis
Copy link
Contributor

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

@nikomatsakis nikomatsakis added the final-comment-period Will be merged/postponed/closed in ~10 calendar days unless new substational objections are raised. label May 26, 2015
@nikomatsakis
Copy link
Contributor

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 June 3, 2015 15:44
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 nrc force-pushed the dst-coercions branch from 433245c to 4b99006 Compare June 3, 2015 05:05
@nrc
Copy link
Member Author

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 pull request Jun 3, 2015
@nikomatsakis
Copy link
Contributor

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 Proposals relating to coercions. A-dst Proposals re. DSTs final-comment-period Will be merged/postponed/closed in ~10 calendar days unless new substational objections are raised. T-lang Relevant to the language team, which will review and decide on the RFC.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants