diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index 4fb2f0c8530d7..03e33a1ff2bc3 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -313,6 +313,12 @@ pub struct Rc { #[stable(feature = "rust1", since = "1.0.0")] impl !marker::Send for Rc {} + +// 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 !marker::Sync for Rc {} diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs index d154bb3583c2d..06dc5ecf2ffa6 100644 --- a/library/core/src/cell.rs +++ b/library/core/src/cell.rs @@ -240,6 +240,11 @@ pub struct Cell { #[stable(feature = "rust1", since = "1.0.0")] unsafe impl Send for Cell 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 !Sync for Cell {}