Skip to content

Commit 6d43dfb

Browse files
authored
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 35ca50b, 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.
2 parents 0da281b + 73d655e commit 6d43dfb

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

library/core/src/marker.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ impl<T: ?Sized> !Send for *const T {}
4444
#[stable(feature = "rust1", since = "1.0.0")]
4545
impl<T: ?Sized> !Send for *mut T {}
4646

47+
// Most instances arise automatically, but this instance is needed to link up `T: Sync` with
48+
// `&T: Send` (and it also removes the unsound default instance `T Send` -> `&T: Send` that would
49+
// otherwise exist).
50+
#[stable(feature = "rust1", since = "1.0.0")]
51+
unsafe impl<T: Sync + ?Sized> Send for &T {}
52+
4753
/// Types with a constant size known at compile time.
4854
///
4955
/// All type parameters have an implicit bound of `Sized`. The special syntax
@@ -674,13 +680,6 @@ impl<T: ?Sized> StructuralPartialEq for PhantomData<T> {}
674680
#[unstable(feature = "structural_match", issue = "31434")]
675681
impl<T: ?Sized> StructuralEq for PhantomData<T> {}
676682

677-
mod impls {
678-
#[stable(feature = "rust1", since = "1.0.0")]
679-
unsafe impl<T: Sync + ?Sized> Send for &T {}
680-
#[stable(feature = "rust1", since = "1.0.0")]
681-
unsafe impl<T: Send + ?Sized> Send for &mut T {}
682-
}
683-
684683
/// Compiler-internal trait used to indicate the type of enum discriminants.
685684
///
686685
/// This trait is automatically implemented for every type and does not add any

src/test/ui/async-await/async-fn-nonsend.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ error: future cannot be sent between threads safely
2727
LL | assert_send(non_sync_with_method_call());
2828
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `non_sync_with_method_call` is not `Send`
2929
|
30-
= help: the trait `Send` is not implemented for `dyn std::fmt::Write`
30+
= help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `dyn std::fmt::Write`
3131
note: future is not `Send` as this value is used across an await
3232
--> $DIR/async-fn-nonsend.rs:46:14
3333
|

0 commit comments

Comments
 (0)