Skip to content

Commit 86c0ef8

Browse files
committed
Add comments regarding superfluous !Sync impls
1 parent 495322d commit 86c0ef8

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

library/alloc/src/rc.rs

+6
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,12 @@ pub struct Rc<T: ?Sized> {
313313

314314
#[stable(feature = "rust1", since = "1.0.0")]
315315
impl<T: ?Sized> !marker::Send for Rc<T> {}
316+
317+
// Note that this negative impl isn't strictly necessary for correctness,
318+
// as `Rc` transitively contains a `Cell`, which is itself `!Sync`.
319+
// However, given how important `Rc`'s `!Sync`-ness is,
320+
// having an explicit negative impl is nice for documentation purposes
321+
// and results in nicer error messages.
316322
#[stable(feature = "rust1", since = "1.0.0")]
317323
impl<T: ?Sized> !marker::Sync for Rc<T> {}
318324

library/core/src/cell.rs

+5
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ pub struct Cell<T: ?Sized> {
240240
#[stable(feature = "rust1", since = "1.0.0")]
241241
unsafe impl<T: ?Sized> Send for Cell<T> where T: Send {}
242242

243+
// Note that this negative impl isn't strictly necessary for correctness,
244+
// as `Cell` wraps `UnsafeCell`, which is itself `!Sync`.
245+
// However, given how important `Cell`'s `!Sync`-ness is,
246+
// having an explicit negative impl is nice for documentation purposes
247+
// and results in nicer error messages.
243248
#[stable(feature = "rust1", since = "1.0.0")]
244249
impl<T: ?Sized> !Sync for Cell<T> {}
245250

0 commit comments

Comments
 (0)