Skip to content

Test and fix Send and Sync traits of BTreeMap artefacts - #76722

Merged
bors merged 1 commit into
rust-lang:masterfrom
ssomers:btree_send_sync
Sep 20, 2020
Merged

Test and fix Send and Sync traits of BTreeMap artefacts#76722
bors merged 1 commit into
rust-lang:masterfrom
ssomers:btree_send_sync

Conversation

@ssomers

Copy link
Copy Markdown
Contributor

Fixes#76686.

I'm not quite sure what all this implies. E.g. comparing with the definitions for NodeRef in node.rs, maybe an extra bound T: 'a is useful for something. The test compiles on stable/beta (apart from drain_filter) so I bet Sync is equally desirable.

r? @Mark-Simulacrum

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 14, 2020
@jyn514jyn514 added the T-libs-api [DEPRECATED; DO NOT USE] label Sep 14, 2020
Comment on lines 19 to 20

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you want &mut T to be Send, not T?

Suggested change
unsafeimpl<'a,T:Sync>SyncforDormantMutRef<'a,T>{}
unsafeimpl<'a,T:Send>SendforDormantMutRef<'a,T>{}
unsafeimpl<'a,T>SyncforDormantMutRef<'a,T>where&'amutT:Sync{}
unsafeimpl<'a,T>SendforDormantMutRef<'a,T>where&'amutT:Send{}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any tangible difference? That implementation is already:

unsafeimpl<T:Send + ?Sized>Sendfor&mutT{}

And I believe Sync for &mut T is auto-implemented for T: Sync.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could have unsafe impl<T> Send for &mut T {}, even if T is not Send.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And in general this is conceptually a &mut T so it makes sense to use the same rules as &mut T for it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think they might match up in practice, but I didn't want to replicate impls when we could just use this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess core could pull that trick, but nobody else:

structFoo(*consti32);unsafeimplSendfor&mutFoo{}
error[E0119]: conflicting implementations of trait `std::marker::Send` for type `&mut Foo`:
--> src/lib.rs:3:1
|
3 | unsafe impl Send for &mut Foo {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: conflicting implementation in crate `core`:
- impl<T> std::marker::Send for &mut T
where T: std::marker::Send, T: ?Sized;
error[E0321]: cross-crate traits with a default impl, like `std::marker::Send`, can only be implemented for a struct/enum type, not `&mut Foo`
--> src/lib.rs:3:1
|
3 | unsafe impl Send for &mut Foo {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type

@Mark-Simulacrum

Copy link
Copy Markdown
Member

@jyn514 is correct, I think, that we want these in terms of &mut T.

r=me with that change made

@ssomers

Copy link
Copy Markdown
ContributorAuthor

Also got more fine grained testing to compile and added newcomers into_keys and into_values.

r= @Mark-Simulacrum

@jyn514

Copy link
Copy Markdown
Member

@bors r=Mark-Simulacrum

@bors

bors commented Sep 15, 2020

Copy link
Copy Markdown
Collaborator

📌 Commit 176956c has been approved by Mark-Simulacrum

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 15, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Sep 16, 2020
…ulacrum
Test and fix Send and Sync traits of BTreeMap artefacts
Fixesrust-lang#76686.
I'm not quite sure what all this implies. E.g. comparing with the definitions for `NodeRef` in node.rs, maybe an extra bound `T: 'a` is useful for something. The test compiles on stable/beta (apart from `drain_filter`) so I bet `Sync` is equally desirable.
r? @Mark-Simulacrum
RalfJung added a commit to RalfJung/rust that referenced this pull request Sep 19, 2020
…ulacrum
Test and fix Send and Sync traits of BTreeMap artefacts
Fixesrust-lang#76686.
I'm not quite sure what all this implies. E.g. comparing with the definitions for `NodeRef` in node.rs, maybe an extra bound `T: 'a` is useful for something. The test compiles on stable/beta (apart from `drain_filter`) so I bet `Sync` is equally desirable.
r? @Mark-Simulacrum
@RalfJungRalfJung mentioned this pull request Sep 19, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Sep 19, 2020
…ulacrum
Test and fix Send and Sync traits of BTreeMap artefacts
Fixesrust-lang#76686.
I'm not quite sure what all this implies. E.g. comparing with the definitions for `NodeRef` in node.rs, maybe an extra bound `T: 'a` is useful for something. The test compiles on stable/beta (apart from `drain_filter`) so I bet `Sync` is equally desirable.
r? @Mark-Simulacrum
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Sep 19, 2020
…ulacrum
Test and fix Send and Sync traits of BTreeMap artefacts
Fixesrust-lang#76686.
I'm not quite sure what all this implies. E.g. comparing with the definitions for `NodeRef` in node.rs, maybe an extra bound `T: 'a` is useful for something. The test compiles on stable/beta (apart from `drain_filter`) so I bet `Sync` is equally desirable.
r? @Mark-Simulacrum
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Sep 20, 2020
…ulacrum
Test and fix Send and Sync traits of BTreeMap artefacts
Fixesrust-lang#76686.
I'm not quite sure what all this implies. E.g. comparing with the definitions for `NodeRef` in node.rs, maybe an extra bound `T: 'a` is useful for something. The test compiles on stable/beta (apart from `drain_filter`) so I bet `Sync` is equally desirable.
r? @Mark-Simulacrum
RalfJung added a commit to RalfJung/rust that referenced this pull request Sep 20, 2020
…ulacrum
Test and fix Send and Sync traits of BTreeMap artefacts
Fixesrust-lang#76686.
I'm not quite sure what all this implies. E.g. comparing with the definitions for `NodeRef` in node.rs, maybe an extra bound `T: 'a` is useful for something. The test compiles on stable/beta (apart from `drain_filter`) so I bet `Sync` is equally desirable.
r? @Mark-Simulacrum
@RalfJungRalfJung mentioned this pull request Sep 20, 2020
@RalfJung

Copy link
Copy Markdown
Member

@bors rollup

@RalfJungRalfJung mentioned this pull request Sep 20, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 20, 2020
Rollup of 15 pull requests
Successful merges:
- rust-lang#76722 (Test and fix Send and Sync traits of BTreeMap artefacts)
- rust-lang#76766 (Extract some intrinsics out of rustc_codegen_llvm)
- rust-lang#76800 (Don't generate bootstrap usage unless it's needed)
- rust-lang#76809 (simplfy condition in ItemLowerer::with_trait_impl_ref())
- rust-lang#76815 (Fix wording in mir doc)
- rust-lang#76818 (Don't compile regex at every function call.)
- rust-lang#76821 (Remove redundant nightly features)
- rust-lang#76823 (black_box: silence unused_mut warning when building with cfg(miri))
- rust-lang#76825 (use `array_windows` instead of `windows` in the compiler)
- rust-lang#76827 (fix array_windows docs)
- rust-lang#76828 (use strip_prefix over starts_with and manual slicing based on pattern length (clippy::manual_strip))
- rust-lang#76840 (Move to intra doc links in core/src/future)
- rust-lang#76845 (Use intra docs links in core::{ascii, option, str, pattern, hash::map})
- rust-lang#76853 (Use intra-doc links in library/core/src/task/wake.rs)
- rust-lang#76871 (support panic=abort in Miri)
Failed merges:
r? `@ghost`
@bors
bors merged commit f5e19a3 into rust-lang:masterSep 20, 2020
@rustbotrustbot added this to the 1.48.0 milestone Sep 20, 2020
@ssomers
ssomers deleted the btree_send_sync branch September 21, 2020 09:14
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-libs-api[DEPRECATED; DO NOT USE]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

btree_map::OccupiedEntry: Send regression

8 participants

@ssomers@Mark-Simulacrum@jyn514@bors@RalfJung@cuviper@rust-highfive@rustbot