diff options
| author | Michael Goulet <michael@errs.io> | 2023-06-23 19:47:19 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-23 19:47:19 -0700 |
| commit | 4a01a38466a452c65f124577bcc21af386317bb8 (patch) | |
| tree | 821474e08366f40b3ff2e4fadb77d7f7bad3dfd3 /library/std | |
| parent | 1d67eba6873b1d551a259a0bbc1e2651b4443e12 (diff) | |
| parent | 4ceca095869244ef3026fd90e2c5e10216be3fe7 (diff) | |
| download | rust-4a01a38466a452c65f124577bcc21af386317bb8.tar.gz rust-4a01a38466a452c65f124577bcc21af386317bb8.zip | |
Rollup merge of #111087 - ibraheemdev:patch-15, r=dtolnay
Implement `Sync` for `mpsc::Sender` `mpsc::Sender` is currently `!Sync` because the previous implementation contained an optimization where the channel started out as single-producer and was dynamically upgraded on the first clone, which relied on a unique reference to the sender. This optimization is one of the main reasons the old implementation was so complex and was removed in #93563. `mpsc::Sender` can now soundly implement `Sync`. Note for any potential confusion, this chance does *not* add MPMC behavior. This only affects the already `Send + Clone` *sender*, not *receiver*. It's technically possible to rely on the `!Sync` behavior in the same way as a `PhantomData<*mut T>`, but that seems very unlikely in practice. Either way, this change is insta-stable and needs an FCP. `@rustbot` label +T-libs-api -T-libs
Diffstat (limited to 'library/std')
| -rw-r--r-- | library/std/src/sync/mpsc/mod.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/library/std/src/sync/mpsc/mod.rs b/library/std/src/sync/mpsc/mod.rs index 0e0c87d1c74..71ff4237d00 100644 --- a/library/std/src/sync/mpsc/mod.rs +++ b/library/std/src/sync/mpsc/mod.rs @@ -347,8 +347,8 @@ pub struct Sender<T> { #[stable(feature = "rust1", since = "1.0.0")] unsafe impl<T: Send> Send for Sender<T> {} -#[stable(feature = "rust1", since = "1.0.0")] -impl<T> !Sync for Sender<T> {} +#[stable(feature = "mpsc_sender_sync", since = "CURRENT_RUSTC_VERSION")] +unsafe impl<T: Send> Sync for Sender<T> {} /// The sending-half of Rust's synchronous [`sync_channel`] type. /// |
