1
Fork 0

Suggest using Arc on !Send/!Sync types

This commit is contained in:
Esteban Kuber 2021-09-14 15:44:08 +00:00 committed by Esteban Küber
parent 19a647d6d8
commit 9de1a472b6
113 changed files with 223 additions and 13 deletions

View file

@ -76,8 +76,11 @@ macro marker_impls {
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "Send")]
#[rustc_on_unimplemented(
on(_Self = "std::rc::Rc<T, A>", note = "use `std::sync::Arc` instead of `std::rc::Rc`"),
message = "`{Self}` cannot be sent between threads safely",
label = "`{Self}` cannot be sent between threads safely"
label = "`{Self}` cannot be sent between threads safely",
note = "consider using `std::sync::Arc<{Self}>`; for more information visit \
<https://doc.rust-lang.org/book/ch16-03-shared-state.html>"
)]
pub unsafe auto trait Send {
// empty.
@ -628,8 +631,11 @@ impl<T: ?Sized> Copy for &T {}
any(_Self = "core::cell::RefCell<T>", _Self = "std::cell::RefCell<T>"),
note = "if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead",
),
on(_Self = "std::rc::Rc<T, A>", note = "use `std::sync::Arc` instead of `std::rc::Rc`"),
message = "`{Self}` cannot be shared between threads safely",
label = "`{Self}` cannot be shared between threads safely"
label = "`{Self}` cannot be shared between threads safely",
note = "consider using `std::sync::Arc<{Self}>`; for more information visit \
<https://doc.rust-lang.org/book/ch16-03-shared-state.html>"
)]
pub unsafe auto trait Sync {
// FIXME(estebank): once support to add notes in `rustc_on_unimplemented`