about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2021-11-09 22:02:21 +0900
committerGitHub <noreply@github.com>2021-11-09 22:02:21 +0900
commitd638c1d13c8fa82a24ed07e8da9dd7c823cc6f13 (patch)
tree44f6e0b1c4b3238b170e32247fd6a1b39290c1ec
parent214cd1f228a463b59f73ee46c8ae3b30f85de253 (diff)
parent86c0ef8adcf2c60dc21a8a9b8f2d6992f2d7613c (diff)
downloadrust-d638c1d13c8fa82a24ed07e8da9dd7c823cc6f13.tar.gz
rust-d638c1d13c8fa82a24ed07e8da9dd7c823cc6f13.zip
Rollup merge of #87530 - bstrie:commentsync, r=bstrie
Add comments regarding superfluous `!Sync` impls
-rw-r--r--library/alloc/src/rc.rs6
-rw-r--r--library/core/src/cell.rs5
2 files changed, 11 insertions, 0 deletions
diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs
index 4fb2f0c8530..03e33a1ff2b 100644
--- a/library/alloc/src/rc.rs
+++ b/library/alloc/src/rc.rs
@@ -313,6 +313,12 @@ pub struct Rc<T: ?Sized> {
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: ?Sized> !marker::Send for Rc<T> {}
+
+// Note that this negative impl isn't strictly necessary for correctness,
+// as `Rc` transitively contains a `Cell`, which is itself `!Sync`.
+// However, given how important `Rc`'s `!Sync`-ness is,
+// having an explicit negative impl is nice for documentation purposes
+// and results in nicer error messages.
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: ?Sized> !marker::Sync for Rc<T> {}
 
diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs
index d154bb3583c..06dc5ecf2ff 100644
--- a/library/core/src/cell.rs
+++ b/library/core/src/cell.rs
@@ -240,6 +240,11 @@ pub struct Cell<T: ?Sized> {
 #[stable(feature = "rust1", since = "1.0.0")]
 unsafe impl<T: ?Sized> Send for Cell<T> where T: Send {}
 
+// Note that this negative impl isn't strictly necessary for correctness,
+// as `Cell` wraps `UnsafeCell`, which is itself `!Sync`.
+// However, given how important `Cell`'s `!Sync`-ness is,
+// having an explicit negative impl is nice for documentation purposes
+// and results in nicer error messages.
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: ?Sized> !Sync for Cell<T> {}