Skip to content

Commit 03cf41a

Browse files
committed
Suggest using Arc on !Send/!Sync types
1 parent 610e2f9 commit 03cf41a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

core/src/marker.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,11 @@ macro marker_impls {
7676
#[stable(feature = "rust1", since = "1.0.0")]
7777
#[cfg_attr(not(test), rustc_diagnostic_item = "Send")]
7878
#[rustc_on_unimplemented(
79+
on(_Self = "std::rc::Rc<T, A>", note = "use `std::sync::Arc` instead of `std::rc::Rc`"),
7980
message = "`{Self}` cannot be sent between threads safely",
80-
label = "`{Self}` cannot be sent between threads safely"
81+
label = "`{Self}` cannot be sent between threads safely",
82+
note = "consider using `std::sync::Arc<{Self}>`; for more information visit \
83+
<https://doc.rust-lang.org/book/ch16-03-shared-state.html>"
8184
)]
8285
pub unsafe auto trait Send {
8386
// empty.
@@ -628,8 +631,11 @@ impl<T: ?Sized> Copy for &T {}
628631
any(_Self = "core::cell::RefCell<T>", _Self = "std::cell::RefCell<T>"),
629632
note = "if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead",
630633
),
634+
on(_Self = "std::rc::Rc<T, A>", note = "use `std::sync::Arc` instead of `std::rc::Rc`"),
631635
message = "`{Self}` cannot be shared between threads safely",
632-
label = "`{Self}` cannot be shared between threads safely"
636+
label = "`{Self}` cannot be shared between threads safely",
637+
note = "consider using `std::sync::Arc<{Self}>`; for more information visit \
638+
<https://doc.rust-lang.org/book/ch16-03-shared-state.html>"
633639
)]
634640
pub unsafe auto trait Sync {
635641
// FIXME(estebank): once support to add notes in `rustc_on_unimplemented`

0 commit comments

Comments
 (0)