Skip to content

Commit 73d655e

Browse files
committed
remove redundant Send impls for references
also move them next to the trait they are implementing
1 parent edabf59 commit 73d655e

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
@@ -680,13 +686,6 @@ pub struct PhantomData<T: ?Sized>;
680686

681687
impls! { PhantomData }
682688

683-
mod impls {
684-
#[stable(feature = "rust1", since = "1.0.0")]
685-
unsafe impl<T: Sync + ?Sized> Send for &T {}
686-
#[stable(feature = "rust1", since = "1.0.0")]
687-
unsafe impl<T: Send + ?Sized> Send for &mut T {}
688-
}
689-
690689
/// Compiler-internal trait used to indicate the type of enum discriminants.
691690
///
692691
/// 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)