about summary refs log tree commit diff
path: root/library
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-10-27 15:03:55 +0200
committerGitHub <noreply@github.com>2022-10-27 15:03:55 +0200
commit6d43dfb7bb248e3068a97e24b00e85f511fde392 (patch)
treefd7472154d55cb17619c6adb531c26e18d85ea8a /library
parent0da281b6068a7d889ae89a9bd8991284cc9b7535 (diff)
parent73d655e9c2106566f328de28aeff6fd3a8ee8e21 (diff)
Rollup merge of #103110 - RalfJung:manual-send, r=thomcc
remove redundant Send impl for references

Also explain why the other instance is not redundant, move it next to the trait they are implementing, and out of the redundant module. This seems to go back all the way to https://github.com/rust-lang/rust/commit/35ca50bd5676db31a8074a216d1aadad7d434de8, not sure why the module was added.

The instance for `&mut` is the default instance we get anyway, and we don't have anything similar for `Sync`, so IMO we should be consistent and not have the redundant instance here, either.
Diffstat (limited to 'library')
-rw-r--r--library/core/src/marker.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/library/core/src/marker.rs b/library/core/src/marker.rs
index c43c4fff6ae..ae4ebf44442 100644
--- a/library/core/src/marker.rs
+++ b/library/core/src/marker.rs
@@ -44,6 +44,12 @@ impl<T: ?Sized> !Send for *const T {}
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: ?Sized> !Send for *mut T {}
 
+// Most instances arise automatically, but this instance is needed to link up `T: Sync` with
+// `&T: Send` (and it also removes the unsound default instance `T Send` -> `&T: Send` that would
+// otherwise exist).
+#[stable(feature = "rust1", since = "1.0.0")]
+unsafe impl<T: Sync + ?Sized> Send for &T {}
+
 /// Types with a constant size known at compile time.
 ///
 /// All type parameters have an implicit bound of `Sized`. The special syntax
@@ -674,13 +680,6 @@ impl<T: ?Sized> StructuralPartialEq for PhantomData<T> {}
 #[unstable(feature = "structural_match", issue = "31434")]
 impl<T: ?Sized> StructuralEq for PhantomData<T> {}
 
-mod impls {
-    #[stable(feature = "rust1", since = "1.0.0")]
-    unsafe impl<T: Sync + ?Sized> Send for &T {}
-    #[stable(feature = "rust1", since = "1.0.0")]
-    unsafe impl<T: Send + ?Sized> Send for &mut T {}
-}
-
 /// Compiler-internal trait used to indicate the type of enum discriminants.
 ///
 /// This trait is automatically implemented for every type and does not add any