From c3fdd19e43e0e0ecb7d12e15b0892dbe6139798d Mon Sep 17 00:00:00 2001 From: Felix Rabe Date: Wed, 1 Aug 2018 09:42:46 +0200 Subject: [PATCH 1/5] Document #39364 (WIP) --- src/libstd/sync/mpsc/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index 02a96b01cca28..fc0e37f150ec9 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -1247,6 +1247,12 @@ impl Receiver { /// [`SyncSender`]: struct.SyncSender.html /// [`Err`]: ../../../std/result/enum.Result.html#variant.Err /// + /// # Panics + /// + /// Panics due to a known issue ([`#39364`][]). + /// + /// [`#39364`]: https://github.com/rust-lang/rust/issues/39364 + /// /// # Examples /// /// Successfully receiving value before encountering timeout: From b1f47aa8380c8dbe7fbd2d96d685cd1f28cc1a6d Mon Sep 17 00:00:00 2001 From: Felix Rabe Date: Tue, 7 Aug 2018 16:35:03 +0200 Subject: [PATCH 2/5] Document panic in mpsc::Receiver::recv_timeout --- src/libstd/sync/mpsc/mod.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index fc0e37f150ec9..e82f40ff96fe5 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -1249,7 +1249,29 @@ impl Receiver { /// /// # Panics /// - /// Panics due to a known issue ([`#39364`][]). + /// There is currently a known issue with this function ([`#39364`]) that + /// causes `recv_timeout` to panic unexpectedly with the following example: + /// + /// ```no_run + /// use std::sync::mpsc::channel; + /// use std::thread; + /// use std::time::Duration; + /// + /// let (tx, rx) = channel::(); + /// + /// thread::spawn(move || { + /// let d = Duration::from_millis(10); + /// loop { + /// println!("recv"); + /// let _r = rx.recv_timeout(d); + /// } + /// }); + /// + /// thread::sleep(Duration::from_millis(100)); + /// let _c1 = tx.clone(); + /// + /// thread::sleep(Duration::from_secs(1)); + /// ``` /// /// [`#39364`]: https://github.com/rust-lang/rust/issues/39364 /// From c574720d88f9310ed3fc0489c9a8d5c3ef832c2c Mon Sep 17 00:00:00 2001 From: Felix Rabe Date: Tue, 7 Aug 2018 16:38:02 +0200 Subject: [PATCH 3/5] Rephrase --- src/libstd/sync/mpsc/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index e82f40ff96fe5..de55355620741 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -1249,8 +1249,8 @@ impl Receiver { /// /// # Panics /// - /// There is currently a known issue with this function ([`#39364`]) that - /// causes `recv_timeout` to panic unexpectedly with the following example: + /// There is currently a known issue with this `recv_timeout` (see [`#39364`]) + /// that causes it to panic unexpectedly with the following example: /// /// ```no_run /// use std::sync::mpsc::channel; From 6e2051cd084aee3aa5cef0d8ec65fc564f86ed1c Mon Sep 17 00:00:00 2001 From: Felix Rabe Date: Tue, 7 Aug 2018 16:39:09 +0200 Subject: [PATCH 4/5] Less words better than moar words --- src/libstd/sync/mpsc/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index de55355620741..21a6adf5827df 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -1249,8 +1249,8 @@ impl Receiver { /// /// # Panics /// - /// There is currently a known issue with this `recv_timeout` (see [`#39364`]) - /// that causes it to panic unexpectedly with the following example: + /// There is currently a known issue (see [`#39364`]) that causes `recv_timeout` + /// to panic unexpectedly with the following example: /// /// ```no_run /// use std::sync::mpsc::channel; From 025f41f4c0db5ed65ae6a15ec8bb4e5872bc16ff Mon Sep 17 00:00:00 2001 From: Felix Rabe Date: Tue, 7 Aug 2018 17:34:34 +0200 Subject: [PATCH 5/5] "Panics" -> "Known Issues"; rm trailing WS --- src/libstd/sync/mpsc/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index 21a6adf5827df..59cf741487e44 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -1247,7 +1247,7 @@ impl Receiver { /// [`SyncSender`]: struct.SyncSender.html /// [`Err`]: ../../../std/result/enum.Result.html#variant.Err /// - /// # Panics + /// # Known Issues /// /// There is currently a known issue (see [`#39364`]) that causes `recv_timeout` /// to panic unexpectedly with the following example: @@ -1256,7 +1256,7 @@ impl Receiver { /// use std::sync::mpsc::channel; /// use std::thread; /// use std::time::Duration; - /// + /// /// let (tx, rx) = channel::(); /// /// thread::spawn(move || {