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

Ensure std::mem::Discriminant is Send + Sync #45095

Merged
merged 1 commit into from Oct 10, 2017

Conversation

Projects
None yet
9 participants
@bluss
Contributor

bluss commented Oct 7, 2017

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

@rust-highfive

This comment has been minimized.

Show comment
Hide comment
@rust-highfive

rust-highfive Oct 7, 2017

Collaborator

r? @BurntSushi

(rust_highfive has picked a reviewer for you, use r? to override)

Collaborator

rust-highfive commented Oct 7, 2017

r? @BurntSushi

(rust_highfive has picked a reviewer for you, use r? to override)

@bluss

This comment has been minimized.

Show comment
Hide comment
@bluss

bluss Oct 7, 2017

Contributor

Tracking issue #24263

Contributor

bluss commented Oct 7, 2017

Tracking issue #24263

@bluss

This comment has been minimized.

Show comment
Hide comment
@bluss

bluss Oct 7, 2017

Contributor

As discussed before on irc, a bit unclear what the correct phantom data really is for this thing.

Contributor

bluss commented Oct 7, 2017

As discussed before on irc, a bit unclear what the correct phantom data really is for this thing.

core: 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
@BurntSushi

This comment has been minimized.

Show comment
Hide comment
@BurntSushi

BurntSushi Oct 8, 2017

Member

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

Member

BurntSushi commented Oct 8, 2017

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

@BurntSushi BurntSushi assigned aturon and unassigned BurntSushi Oct 8, 2017

@dtolnay

What are the tradeoffs of using a screwy PhantomData marker vs unsafe impl Send?

@stjepang

This comment has been minimized.

Show comment
Hide comment
@stjepang

stjepang Oct 8, 2017

Contributor

Sometimes I wish we had a few additional marker structs so we could do:

_marker: PhantomData<Variant<T>>
_marker: PhantomData<Invariant<T>>
_marker: PhantomData<(T, NotSendSync)>
Contributor

stjepang commented Oct 8, 2017

Sometimes I wish we had a few additional marker structs so we could do:

_marker: PhantomData<Variant<T>>
_marker: PhantomData<Invariant<T>>
_marker: PhantomData<(T, NotSendSync)>
@alexcrichton

This comment has been minimized.

Show comment
Hide comment
@alexcrichton

alexcrichton Oct 9, 2017

Member

Looks good to me!

@dtolnay I think the usage of fn() -> T helps avoid the usage of unsafe impl, which seems like a bonus to me!

Member

alexcrichton commented Oct 9, 2017

Looks good to me!

@dtolnay I think the usage of fn() -> T helps avoid the usage of unsafe impl, which seems like a bonus to me!

@carols10cents

This comment has been minimized.

Show comment
Hide comment
@carols10cents

carols10cents Oct 9, 2017

Member

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.

Member

carols10cents commented Oct 9, 2017

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.

@alexcrichton

This comment has been minimized.

Show comment
Hide comment
@alexcrichton

alexcrichton Oct 9, 2017

Member

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!

Member

alexcrichton commented Oct 9, 2017

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!

@alexcrichton

This comment has been minimized.

Show comment
Hide comment
@alexcrichton
Member

alexcrichton commented Oct 9, 2017

@bors: r+

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Oct 9, 2017

Contributor

📌 Commit 3fff2d9 has been approved by alexcrichton

Contributor

bors commented Oct 9, 2017

📌 Commit 3fff2d9 has been approved by alexcrichton

kennytm added a commit to kennytm/rust that referenced this pull request Oct 10, 2017

Rollup merge of rust-lang#45095 - bluss:discriminant-send-sync, r=ale…
…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

bors added a commit that referenced this pull request Oct 10, 2017

Auto merge of #45169 - kennytm:rollup, r=kennytm
Rollup of 10 pull requests

- Successful merges: #44775, #45080, #45089, #45095, #45099, #45101, #45108, #45116, #45135, #45146
- Failed merges:

kennytm added a commit to kennytm/rust that referenced this pull request Oct 10, 2017

Rollup merge of rust-lang#45095 - bluss:discriminant-send-sync, r=ale…
…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

bors added a commit that referenced this pull request Oct 10, 2017

Auto merge of #45169 - kennytm:rollup, r=kennytm
Rollup of 9 pull requests

- Successful merges: #44775, #45089, #45095, #45099, #45101, #45108, #45116, #45135, #45146
- Failed merges:

@bors bors merged commit 3fff2d9 into rust-lang:master Oct 10, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@bluss bluss deleted the bluss:discriminant-send-sync branch Oct 29, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment