Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify the purpose of the non_send lint #8075

Merged
merged 3 commits into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix grammar issues
  • Loading branch information
Qwaz committed Dec 7, 2021
commit c0fd250c62abccc0b453677969fa69ddeb6f06d4
4 changes: 2 additions & 2 deletions clippy_lints/src/non_send_fields_in_send_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 17,7 @@ declare_clippy_lint! {
/// contains fields that are not safe to be sent across threads.
/// It tries to detect fields that can cause a soundness issue
/// when sent to another thread (e.g., `Rc`) while allowing `!Send` fields
/// that are expected to exist in a `Send` type such as raw pointers.
/// that are expected to exist in a `Send` type, such as raw pointers.
///
/// ### Why is this bad?
/// Sending the struct to another thread effectively sends all of its fields,
Expand Down Expand Up @@ -124,7 124,7 @@ impl<'tcx> LateLintPass<'tcx> for NonSendFieldInSendTy {
NON_SEND_FIELDS_IN_SEND_TY,
item.span,
&format!(
"there are some fields in `{}` are not safe to be sent to another thread",
"some fields in `{}` are not safe to be sent to another thread",
snippet(cx, hir_impl.self_ty.span, "Unknown")
),
|diag| {
Expand Down
8 changes: 4 additions & 4 deletions tests/ui-toml/strict_non_send_fields_in_send_ty/test.stderr
Original file line number Diff line number Diff line change
@@ -1,4 1,4 @@
error: there are some fields in `NoGeneric` are not safe to be sent to another thread
error: some fields in `NoGeneric` are not safe to be sent to another thread
--> $DIR/test.rs:11:1
|
LL | unsafe impl Send for NoGeneric {}
Expand All @@ -12,7 12,7 @@ LL | rc_is_not_send: Rc<String>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: use a thread-safe type that implements `Send`

error: there are some fields in `MultiField<T>` are not safe to be sent to another thread
error: some fields in `MultiField<T>` are not safe to be sent to another thread
--> $DIR/test.rs:19:1
|
LL | unsafe impl<T> Send for MultiField<T> {}
Expand All @@ -37,7 37,7 @@ LL | field3: T,
| ^^^^^^^^^
= help: add `T: Send` bound in `Send` impl

error: there are some fields in `MyOption<T>` are not safe to be sent to another thread
error: some fields in `MyOption<T>` are not safe to be sent to another thread
--> $DIR/test.rs:26:1
|
LL | unsafe impl<T> Send for MyOption<T> {}
Expand All @@ -50,7 50,7 @@ LL | MySome(T),
| ^
= help: add `T: Send` bound in `Send` impl

error: there are some fields in `HeuristicTest` are not safe to be sent to another thread
error: some fields in `HeuristicTest` are not safe to be sent to another thread
--> $DIR/test.rs:41:1
|
LL | unsafe impl Send for HeuristicTest {}
Expand Down
24 changes: 12 additions & 12 deletions tests/ui/non_send_fields_in_send_ty.stderr
Original file line number Diff line number Diff line change
@@ -1,4 1,4 @@
error: there are some fields in `RingBuffer<T>` are not safe to be sent to another thread
error: some fields in `RingBuffer<T>` are not safe to be sent to another thread
--> $DIR/non_send_fields_in_send_ty.rs:16:1
|
LL | unsafe impl<T> Send for RingBuffer<T> {}
Expand All @@ -12,7 12,7 @@ LL | data: Vec<UnsafeCell<T>>,
| ^^^^^^^^^^^^^^^^^^^^^^^^
= help: add bounds on type parameter `T` that satisfy `Vec<UnsafeCell<T>>: Send`

error: there are some fields in `MvccRwLock<T>` are not safe to be sent to another thread
error: some fields in `MvccRwLock<T>` are not safe to be sent to another thread
--> $DIR/non_send_fields_in_send_ty.rs:24:1
|
LL | unsafe impl<T> Send for MvccRwLock<T> {}
Expand All @@ -25,7 25,7 @@ LL | lock: Mutex<Box<T>>,
| ^^^^^^^^^^^^^^^^^^^
= help: add bounds on type parameter `T` that satisfy `Mutex<Box<T>>: Send`

error: there are some fields in `ArcGuard<RC, T>` are not safe to be sent to another thread
error: some fields in `ArcGuard<RC, T>` are not safe to be sent to another thread
--> $DIR/non_send_fields_in_send_ty.rs:32:1
|
LL | unsafe impl<RC, T: Send> Send for ArcGuard<RC, T> {}
Expand All @@ -38,7 38,7 @@ LL | head: Arc<RC>,
| ^^^^^^^^^^^^^
= help: add bounds on type parameter `RC` that satisfy `Arc<RC>: Send`

error: there are some fields in `DeviceHandle<T>` are not safe to be sent to another thread
error: some fields in `DeviceHandle<T>` are not safe to be sent to another thread
--> $DIR/non_send_fields_in_send_ty.rs:48:1
|
LL | unsafe impl<T: UsbContext> Send for DeviceHandle<T> {}
Expand All @@ -51,7 51,7 @@ LL | context: T,
| ^^^^^^^^^^
= help: add `T: Send` bound in `Send` impl

error: there are some fields in `NoGeneric` are not safe to be sent to another thread
error: some fields in `NoGeneric` are not safe to be sent to another thread
--> $DIR/non_send_fields_in_send_ty.rs:55:1
|
LL | unsafe impl Send for NoGeneric {}
Expand All @@ -64,7 64,7 @@ LL | rc_is_not_send: Rc<String>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: use a thread-safe type that implements `Send`

error: there are some fields in `MultiField<T>` are not safe to be sent to another thread
error: some fields in `MultiField<T>` are not safe to be sent to another thread
--> $DIR/non_send_fields_in_send_ty.rs:63:1
|
LL | unsafe impl<T> Send for MultiField<T> {}
Expand All @@ -89,7 89,7 @@ LL | field3: T,
| ^^^^^^^^^
= help: add `T: Send` bound in `Send` impl

error: there are some fields in `MyOption<T>` are not safe to be sent to another thread
error: some fields in `MyOption<T>` are not safe to be sent to another thread
--> $DIR/non_send_fields_in_send_ty.rs:70:1
|
LL | unsafe impl<T> Send for MyOption<T> {}
Expand All @@ -102,7 102,7 @@ LL | MySome(T),
| ^
= help: add `T: Send` bound in `Send` impl

error: there are some fields in `MultiParam<A, B>` are not safe to be sent to another thread
error: some fields in `MultiParam<A, B>` are not safe to be sent to another thread
--> $DIR/non_send_fields_in_send_ty.rs:82:1
|
LL | unsafe impl<A, B> Send for MultiParam<A, B> {}
Expand All @@ -115,7 115,7 @@ LL | vec: Vec<(A, B)>,
| ^^^^^^^^^^^^^^^^
= help: add bounds on type parameters `A, B` that satisfy `Vec<(A, B)>: Send`

error: there are some fields in `HeuristicTest` are not safe to be sent to another thread
error: some fields in `HeuristicTest` are not safe to be sent to another thread
--> $DIR/non_send_fields_in_send_ty.rs:100:1
|
LL | unsafe impl Send for HeuristicTest {}
Expand All @@ -128,7 128,7 @@ LL | field4: (*const NonSend, Rc<u8>),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: use a thread-safe type that implements `Send`

error: there are some fields in `AttrTest3<T>` are not safe to be sent to another thread
error: some fields in `AttrTest3<T>` are not safe to be sent to another thread
--> $DIR/non_send_fields_in_send_ty.rs:119:1
|
LL | unsafe impl<T> Send for AttrTest3<T> {}
Expand All @@ -141,7 141,7 @@ LL | Enum2(T),
| ^
= help: add `T: Send` bound in `Send` impl

error: there are some fields in `Complex<P, u32>` are not safe to be sent to another thread
error: some fields in `Complex<P, u32>` are not safe to be sent to another thread
--> $DIR/non_send_fields_in_send_ty.rs:127:1
|
LL | unsafe impl<P> Send for Complex<P, u32> {}
Expand All @@ -154,7 154,7 @@ LL | field1: A,
| ^^^^^^^^^
= help: add `P: Send` bound in `Send` impl

error: there are some fields in `Complex<Q, MutexGuard<'static, bool>>` are not safe to be sent to another thread
error: some fields in `Complex<Q, MutexGuard<'static, bool>>` are not safe to be sent to another thread
--> $DIR/non_send_fields_in_send_ty.rs:130:1
|
LL | unsafe impl<Q: Send> Send for Complex<Q, MutexGuard<'static, bool>> {}
Expand Down