Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for DST coercions (coerce_unsized, unsize) stabilization #27732
Comments
aturon
added
T-lang
T-libs
B-unstable
labels
Aug 12, 2015
This comment has been minimized.
This comment has been minimized.
|
@nrc, what's your sense of the status for these features? Do you feel ready to stabilize after the libs team takes a look? |
This comment has been minimized.
This comment has been minimized.
|
My feeling (and it is really just a feeling, I have no data to back this up) is that DST coercions haven't yet got the use they need to prove themselves for stabilisation. I'd love to be wrong about this - if someone could show me a bunch of code doing stuff with DST coercions I'd be very happy. OTOH, I don't think there is anything fundamentally wrong with them, so it would not be a waste of time for the libs team to take a look. |
This comment has been minimized.
This comment has been minimized.
photino
commented
Sep 24, 2015
|
Why is the marker named |
This comment has been minimized.
This comment has been minimized.
|
It goes the wrong way around - for example, we have |
This comment has been minimized.
This comment has been minimized.
|
Can we move to stabilize this? It's been unchanged for 5 months and I've heard no complaints about it. |
This comment has been minimized.
This comment has been minimized.
|
I don't recall having any issues with this in libstd. The correct way to use this is basically a witchcraft incantation (mostly because these are under-the-covers things one never interacts with in real code), but as far as I know, there's know way to use it dangerously wrong? The whole thing Just Works. I guess one thing I've never really thought about is why one needs to talk about whether the pointed-to value is unsizeable or whatever. Why can't one simply declare that pointer X is an unsizable one, and have all that junk automatic? Is this desirable to have for generic consumers...? |
This comment has been minimized.
This comment has been minimized.
jnicholls
commented
Jan 24, 2016
|
It's desirable for generic consumers of e.g. Arena allocators that allocate a Sized type that implements a trait unknown to the allocator, and the consumer wants to coerce the allocated result to an allocated trait object. See https://gitlab.com/Bastacyclop/rust_arena/blob/master/src/lib.rs in the tests. It's a decent use case. How would you recommend doing this otherwise? |
This comment has been minimized.
This comment has been minimized.
stevenblenkinsop
commented
Jan 29, 2016
|
Is the lack of support for enums deliberate, temporary, or merely overlooked? |
This comment has been minimized.
This comment has been minimized.
|
I'm nominating this for discussion at the next lang team meeting. |
aturon
added
the
I-nominated
label
Feb 1, 2016
This comment has been minimized.
This comment has been minimized.
|
@jnicholls maybe I'm missing something, but just mark the one pointer field that will be Unsized as coercable: https://gitlab.com/Bastacyclop/rust_arena/blob/master/src/lib.rs#L41 It seems to me that all the |
This comment has been minimized.
This comment has been minimized.
jnicholls
commented
Feb 2, 2016
|
@Gankro Sorry I don't follow what you mean. Can you provide an example? |
This comment has been minimized.
This comment has been minimized.
|
Oops, something clobbered my selection, I meant to link to: https://gitlab.com/Bastacyclop/rust_arena/blob/master/src/lib.rs#L59 Basically instead of pub struct Allocated<'a, 'b, T: 'b + ?Sized> {
reference: &'b mut T,
phantom: PhantomData<&'a ()>
}
impl<'a, 'b, T: ?Sized, U: ?Sized> CoerceUnsized<Allocated<'a, 'b, U>> for Allocated<'a, 'b, T>
where U: 'b, T: 'b + Unsize<U> {}You would just do something like: #[coerce_unsized(T)]
pub struct Allocated<'a, 'b, T: 'b + ?Sized> {
reference: &'b mut T,
phantom: PhantomData<&'a ()>
} |
aturon
removed
the
T-libs
label
Feb 18, 2016
This comment has been minimized.
This comment has been minimized.
|
cc @eddyb |
This comment has been minimized.
This comment has been minimized.
|
Removed T-libs tag, but note that we'd like to review the naming conventions here before stabilization. |
This comment has been minimized.
This comment has been minimized.
|
There's room for generalization and a good chance we might want |
This comment has been minimized.
This comment has been minimized.
|
Right now, because |
This comment has been minimized.
This comment has been minimized.
|
I'm not very familiar with how this works, but shouldn't the |
This comment has been minimized.
This comment has been minimized.
|
You implement e.g. impl<'a, T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<&'a mut U> for &'a mut T {} |
aturon
removed
the
I-nominated
label
Feb 26, 2016
alexcrichton
added
T-libs
and removed
T-libs
labels
Mar 7, 2016
This comment has been minimized.
This comment has been minimized.
|
(adding T-libs as this has a library API associated with it which needs stabilization) |
This comment has been minimized.
This comment has been minimized.
|
So at a recent @rust-lang/lang meeting we discussed this. I think everyone felt...somewhat comfortable with the idea of going forward, but we also wanted to do a thorough review of the current status of the code, along with a comparison against the existing specifications, to make sure everything is well aligned. |
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis The problem, though, is that the RFC is intentionally provisional, mostly to get Maybe with specialization we can even encode |
This comment has been minimized.
This comment has been minimized.
|
|
nrc
added
the
B-RFC-implemented
label
Aug 29, 2016
This comment has been minimized.
This comment has been minimized.
|
@nrc triage ping |
This comment has been minimized.
This comment has been minimized.
|
No change. I think we are waiting for some kind of custom DST RFC before moving forward with stabilisation here. |
This comment has been minimized.
This comment has been minimized.
H2CO3
commented
Jun 5, 2017
Mark-Simulacrum
added
the
C-tracking-issue
label
Jul 22, 2017
This comment has been minimized.
This comment has been minimized.
|
What if instead of using
In this case we could implement |
This was referenced Mar 12, 2019
This comment has been minimized.
This comment has been minimized.
Osspial
commented
Apr 3, 2019
|
It's been over a year since anyone's really looked at this. What's stopping this from getting stabilized? |
This comment has been minimized.
This comment has been minimized.
|
The current design is perma-unstable. A new RFC is required for a design that we can consider stabilizing. The So what we should do is generalize Then we can allow even IMO "custom DSTs" was a red herring, as stabilizing |
eddyb
added
the
I-nominated
label
Apr 4, 2019
This comment has been minimized.
This comment has been minimized.
|
Nominating for discussion, regarding splitting this issue into:
|
aturon commentedAug 12, 2015
DST coercions were the last part of DST to land, and are still undergoing some changes.
Before stabilization, at the very least the API surface here needs some scrutiny from the libs team for naming and other conventions issues.
cc @nrc @Gankro