Ensure std::mem::Discriminant is Send + Sync#45095
Conversation
|
r? @BurntSushi (rust_highfive has picked a reviewer for you, use r? to override) |
|
Tracking issue #24263 |
|
As discussed before on irc, a bit unclear what the correct phantom data really is for this thing. |
`PhantomData<*const T>` has the implication of Send / Syncness following the *const T type, but the discriminant should always be Send and Sync. Use `PhantomData<fn() -> T>` which has the same variance in T, but is Send + Sync
692a18d to
3fff2d9
Compare
|
I am throwing this to @aturon. I don't immediately see anything wrong with this, but I'd like someone else to see it! cc @rust-lang/libs |
dtolnay
left a comment
There was a problem hiding this comment.
What are the tradeoffs of using a screwy PhantomData marker vs unsafe impl Send?
|
Sometimes I wish we had a few additional marker structs so we could do: |
|
Looks good to me! @dtolnay I think the usage of |
|
Just a note that @aturon is on PTO this week so isn't likely to get to it, but it looks like this one is worth waiting for him to take a look. |
|
I'm gonna go ahead and approve this as I think there won't be too much opposition, and we'll have a long time on nightly before this reaches stable as well! |
|
@bors: r+ |
|
📌 Commit 3fff2d9 has been approved by |
…xcrichton Ensure std::mem::Discriminant is Send + Sync `PhantomData<*const T>` has the implication of Send / Syncness following the *const T type, but the discriminant should always be Send and Sync. Use `PhantomData<fn() -> T>` which has the same variance in T, but is Send + Sync
PhantomData<*const T>has the implication of Send / Syncness followingthe *const T type, but the discriminant should always be Send and Sync.
Use
PhantomData<fn() -> T>which has the same variance in T, but is Send + Sync