@@ -24,18 +24,15 @@ pub struct Sender<T> {
2424 inner : mpmc:: Sender < T > ,
2525}
2626
27- /// The sending end of the channel can be sent between threads, as long as it is not used to
28- /// receive non-sendable things.
27+ /// SAFETY: Since the only methods in which synchronization must occur take full ownership of the
28+ /// [`Sender`], it is perfectly safe to share a &[`Sender`] between threads (as it is effectively
29+ /// useless without full ownership).
2930#[ unstable( feature = "oneshot_channel" , issue = "143674" ) ]
30- unsafe impl < T : Send > Send for Sender < T > { }
31-
32- /// FIXME: Try to boil down <https://github.com/rust-lang/rust/pull/111087> into a doc comment.
33- #[ unstable( feature = "oneshot_channel" , issue = "143674" ) ]
34- unsafe impl < T : Send > Sync for Sender < T > { }
31+ unsafe impl < T > Sync for Sender < T > { }
3532
3633impl < T > Sender < T > {
3734 /// Attempts to send a value through this channel. This can only fail if the corresponding
38- /// `Receiver<T>` has been dropped.
35+ /// [ `Receiver<T>`] has been dropped.
3936 ///
4037 /// This method is non-blocking (wait-free).
4138 #[ unstable( feature = "oneshot_channel" , issue = "143674" ) ]
@@ -62,19 +59,16 @@ pub struct Receiver<T> {
6259 inner : mpmc:: Receiver < T > ,
6360}
6461
65- /// The receiving end of the channel can be sent between threads, as long as it is not used to
66- /// receive non-sendable things.
67- #[ unstable( feature = "oneshot_channel" , issue = "143674" ) ]
68- unsafe impl < T : Send > Send for Receiver < T > { }
69-
70- /// FIXME: Why is `mpsc::Receiver` !Sync but `mpmc::Receiver` is? Write this in a doc comment.
62+ /// SAFETY: Since the only methods in which synchronization must occur take full ownership of the
63+ /// [`Receiver`], it is perfectly safe to share a &[`Receiver`] between threads (as it is unable to
64+ /// receive any values without full ownership).
7165#[ unstable( feature = "oneshot_channel" , issue = "143674" ) ]
72- impl < T > ! Sync for Receiver < T > { }
66+ unsafe impl < T > Sync for Receiver < T > { }
7367
7468impl < T > Receiver < T > {
7569 /// Receives the value from the sending end, blocking the calling thread until it gets it.
7670 ///
77- /// Can only fail if the corresponding `Sender<T>` has been dropped.
71+ /// Can only fail if the corresponding [ `Sender<T>`] has been dropped.
7872 #[ unstable( feature = "oneshot_channel" , issue = "143674" ) ]
7973 pub fn recv ( self ) -> Result < T , RecvError > {
8074 self . inner . recv ( )
0 commit comments