]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #88612 - lovasoa:patch-1, r=m-ou-se
authorJubilee <46493976+workingjubilee@users.noreply.github.com>
Fri, 24 Sep 2021 00:31:41 +0000 (17:31 -0700)
committerGitHub <noreply@github.com>
Fri, 24 Sep 2021 00:31:41 +0000 (17:31 -0700)
Add a better error message for #39364

There is a known bug in the implementation of mpsc channels in rust.
This adds a clearer error message when the bug occurs, so that developers don't lose too much time looking for the origin of the bug.
See https://github.com/rust-lang/rust/issues/39364

library/std/src/sync/mpsc/shared.rs

index 0c32e636a563357ce39cac0f6313c422b4915c1c..8487a5f8b50d3215790285d4841ac2ec1021afc4 100644 (file)
@@ -248,7 +248,11 @@ pub fn recv(&self, deadline: Option<Instant>) -> Result<T, Failure> {
     // Returns true if blocking should proceed.
     fn decrement(&self, token: SignalToken) -> StartResult {
         unsafe {
-            assert_eq!(self.to_wake.load(Ordering::SeqCst), 0);
+            assert_eq!(
+                self.to_wake.load(Ordering::SeqCst),
+                0,
+                "This is a known bug in the Rust standard library. See https://github.com/rust-lang/rust/issues/39364"
+            );
             let ptr = token.cast_to_usize();
             self.to_wake.store(ptr, Ordering::SeqCst);