diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index d78453cc900bd..53b1d1cd12de3 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -344,18 +344,20 @@ pub trait Copy : Clone { #[stable(feature = "rust1", since = "1.0.0")] #[lang = "sync"] #[rustc_on_unimplemented( - on( - _Self="std::sync::mpsc::Receiver", - label="`{Self}` cannot be shared safely, consider marking the closure `move`" - ), - on( - _Self="std::sync::mpsc::Sender", - label="`{Self}` cannot be shared safely, consider marking the closure `move`" - ), message="`{Self}` cannot be shared between threads safely", label="`{Self}` cannot be shared between threads safely" )] pub unsafe auto trait Sync { + // FIXME(estebank): once support to add notes in `rustc_on_unimplemented` + // lands in beta, and it has been extended to check whether a closure is + // anywhere in the requirement chain, extend it as such (#48534): + // ``` + // on( + // closure, + // note="`{Self}` cannot be shared safely, consider marking the closure `move`" + // ), + // ``` + // Empty } diff --git a/src/test/ui/closure-move-sync.stderr b/src/test/ui/closure-move-sync.stderr index 4b59ef8a4373d..abf07d2cef526 100644 --- a/src/test/ui/closure-move-sync.stderr +++ b/src/test/ui/closure-move-sync.stderr @@ -1,8 +1,8 @@ error[E0277]: `std::sync::mpsc::Receiver<()>` cannot be shared between threads safely --> $DIR/closure-move-sync.rs:16:13 | -16 | let t = thread::spawn(|| { - | ^^^^^^^^^^^^^ `std::sync::mpsc::Receiver<()>` cannot be shared safely, consider marking the closure `move` +LL | let t = thread::spawn(|| { + | ^^^^^^^^^^^^^ `std::sync::mpsc::Receiver<()>` cannot be shared between threads safely | = help: the trait `std::marker::Sync` is not implemented for `std::sync::mpsc::Receiver<()>` = note: required because of the requirements on the impl of `std::marker::Send` for `&std::sync::mpsc::Receiver<()>` @@ -12,8 +12,8 @@ error[E0277]: `std::sync::mpsc::Receiver<()>` cannot be shared between threads s error[E0277]: `std::sync::mpsc::Sender<()>` cannot be shared between threads safely --> $DIR/closure-move-sync.rs:28:5 | -28 | thread::spawn(|| tx.send(()).unwrap()); - | ^^^^^^^^^^^^^ `std::sync::mpsc::Sender<()>` cannot be shared safely, consider marking the closure `move` +LL | thread::spawn(|| tx.send(()).unwrap()); + | ^^^^^^^^^^^^^ `std::sync::mpsc::Sender<()>` cannot be shared between threads safely | = help: the trait `std::marker::Sync` is not implemented for `std::sync::mpsc::Sender<()>` = note: required because of the requirements on the impl of `std::marker::Send` for `&std::sync::mpsc::Sender<()>` @@ -22,3 +22,4 @@ error[E0277]: `std::sync::mpsc::Sender<()>` cannot be shared between threads saf error: aborting due to 2 previous errors +If you want more information on this error, try using "rustc --explain E0277"