Uh oh!
There was an error while loading. Please reload this page.
Implement CoerceUnsized for {Cell, RefCell, UnsafeCell} - #35627
Conversation
eddyb
commented
Aug 12, 2016
LGTM. cc @rust-lang/lang Do we want such impls? While the feature is unstable, they would be usable in coercions from stable code. |
alexcrichton
commented
Aug 12, 2016
Would it be possible to add a few tests to the repo as well ensuring that we don't regress this functionality? |
apasel422
commented
Aug 13, 2016
@alexcrichton Done. |
alexcrichton
commented
Aug 13, 2016
Thanks! I think though that libcore doesn't actually have tests run, so could they be moved to libcoretest? |
apasel422
commented
Aug 13, 2016
@alexcrichton They're not actually tests -- they'll cause compilation to fail if we regress the functionality. This is similar to other assertions that types are covariant or |
alexcrichton
commented
Aug 14, 2016
Oh gah, right! Carry on! |
nrc
commented
Aug 14, 2016
Usually, I'd be cautious about impls that let us skirt stability, but the DST coercions have been around for ages and I don't think there are problems with them, but we could do with more testing, so maybe this would help that? |
bors
commented
Aug 15, 2016
☔ The latest upstream changes (presumably #35666) made this pull request unmergeable. Please resolve the merge conflicts. |
nikomatsakis
commented
Aug 18, 2016
I don't know that these impls make sense for
|
nikomatsakis
commented
Aug 18, 2016
I guess you could copy things in and out if you permitted dynamically sized stack frames (as I sort of want to permit now, in order to generally loosen the rules on DST). But no reason to jump the gun there. :) |
apasel422
commented
Aug 18, 2016
@nikomatsakis See the link in my original post for an example of where this is useful for |
eddyb
commented
Aug 18, 2016
@nikomatsakis What's being added here is the ability to coerce More concretely, |
nikomatsakis
commented
Aug 18, 2016
Ah, right, thanks for the correction. =) In that case, I have no objection. It is sort of nifty that this works. Seems like it'd be a variance error, but since there's no aliasing... |
alexcrichton
commented
Aug 23, 2016
Discussed during @rust-lang/libs triage discussion was also that this is good to merge, thanks @apasel422! @bors: r+ |
bors
commented
Aug 23, 2016
📌 Commit 1fd791a has been approved by |
bors
commented
Aug 23, 2016
⌛ Testing commit 1fd791a with merge 43204ff... |
Implement `CoerceUnsized` for `{Cell, RefCell, UnsafeCell}`
These impls are analogous to the one for `NonZero`. It's occasionally useful to be able to coerce the cell types when they're being used inside another abstraction. See Manishearth/rust-gc#17 for an example.
r? @eddyb
These impls are analogous to the one for
NonZero. It's occasionally useful to be able to coerce the cell types when they're being used inside another abstraction. See Manishearth/rust-gc#17 for an example.r? @eddyb