mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 13:13:34 +00:00
Update documentation and name for non_send_fields_in_send_ty lint
This commit is contained in:
parent
ef8df9df68
commit
fb0353b28d
12 changed files with 45 additions and 45 deletions
|
@ -2898,7 +2898,7 @@ Released 2018-09-13
|
|||
[`no_effect`]: https://rust-lang.github.io/rust-clippy/master/index.html#no_effect
|
||||
[`non_ascii_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#non_ascii_literal
|
||||
[`non_octal_unix_permissions`]: https://rust-lang.github.io/rust-clippy/master/index.html#non_octal_unix_permissions
|
||||
[`non_send_field_in_send_ty`]: https://rust-lang.github.io/rust-clippy/master/index.html#non_send_field_in_send_ty
|
||||
[`non_send_fields_in_send_ty`]: https://rust-lang.github.io/rust-clippy/master/index.html#non_send_fields_in_send_ty
|
||||
[`nonminimal_bool`]: https://rust-lang.github.io/rust-clippy/master/index.html#nonminimal_bool
|
||||
[`nonsensical_open_options`]: https://rust-lang.github.io/rust-clippy/master/index.html#nonsensical_open_options
|
||||
[`nonstandard_macro_braces`]: https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
|
||||
|
|
|
@ -149,7 +149,7 @@ mod no_effect;
|
|||
mod non_copy_const;
|
||||
mod non_expressive_names;
|
||||
mod non_octal_unix_permissions;
|
||||
mod non_send_field_in_send_ty;
|
||||
mod non_send_fields_in_send_ty;
|
||||
mod nonstandard_macro_braces;
|
||||
mod open_options;
|
||||
mod option_env_unwrap;
|
||||
|
|
|
@ -366,7 +366,7 @@ store.register_lints(&[
|
|||
non_expressive_names::MANY_SINGLE_CHAR_NAMES,
|
||||
non_expressive_names::SIMILAR_NAMES,
|
||||
non_octal_unix_permissions::NON_OCTAL_UNIX_PERMISSIONS,
|
||||
non_send_field_in_send_ty::NON_SEND_FIELD_IN_SEND_TY,
|
||||
non_send_fields_in_send_ty::NON_SEND_FIELDS_IN_SEND_TY,
|
||||
nonstandard_macro_braces::NONSTANDARD_MACRO_BRACES,
|
||||
open_options::NONSENSICAL_OPEN_OPTIONS,
|
||||
option_env_unwrap::OPTION_ENV_UNWRAP,
|
||||
|
|
|
@ -16,7 +16,7 @@ store.register_group(true, "clippy::nursery", Some("clippy_nursery"), vec![
|
|||
LintId::of(missing_const_for_fn::MISSING_CONST_FOR_FN),
|
||||
LintId::of(mutable_debug_assertion::DEBUG_ASSERT_WITH_MUT_CALL),
|
||||
LintId::of(mutex_atomic::MUTEX_INTEGER),
|
||||
LintId::of(non_send_field_in_send_ty::NON_SEND_FIELD_IN_SEND_TY),
|
||||
LintId::of(non_send_fields_in_send_ty::NON_SEND_FIELDS_IN_SEND_TY),
|
||||
LintId::of(nonstandard_macro_braces::NONSTANDARD_MACRO_BRACES),
|
||||
LintId::of(option_if_let_else::OPTION_IF_LET_ELSE),
|
||||
LintId::of(path_buf_push_overwrite::PATH_BUF_PUSH_OVERWRITE),
|
||||
|
|
|
@ -536,7 +536,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
|
|||
store.register_late_pass(move || Box::new(iter_not_returning_iterator::IterNotReturningIterator));
|
||||
store.register_late_pass(move || Box::new(if_then_panic::IfThenPanic));
|
||||
let enable_raw_pointer_heuristic_for_send = conf.enable_raw_pointer_heuristic_for_send;
|
||||
store.register_late_pass(move || Box::new(non_send_field_in_send_ty::NonSendFieldInSendTy::new(enable_raw_pointer_heuristic_for_send)));
|
||||
store.register_late_pass(move || Box::new(non_send_fields_in_send_ty::NonSendFieldInSendTy::new(enable_raw_pointer_heuristic_for_send)));
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
|
|
|
@ -12,7 +12,7 @@ use rustc_span::sym;
|
|||
|
||||
declare_clippy_lint! {
|
||||
/// ### What it does
|
||||
/// Warns about a field in a `Send` struct that is neither `Send` nor `Copy`.
|
||||
/// Warns about fields in struct implementing `Send` that are neither `Send` nor `Copy`.
|
||||
///
|
||||
/// ### Why is this bad?
|
||||
/// Sending the struct to another thread will transfer the ownership to
|
||||
|
@ -43,7 +43,7 @@ declare_clippy_lint! {
|
|||
/// ```
|
||||
/// Use thread-safe types like [`std::sync::Arc`](https://doc.rust-lang.org/std/sync/struct.Arc.html)
|
||||
/// or specify correct bounds on generic type parameters (`T: Send`).
|
||||
pub NON_SEND_FIELD_IN_SEND_TY,
|
||||
pub NON_SEND_FIELDS_IN_SEND_TY,
|
||||
nursery,
|
||||
"there is field that does not implement `Send` in a `Send` struct"
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ impl NonSendFieldInSendTy {
|
|||
}
|
||||
}
|
||||
|
||||
impl_lint_pass!(NonSendFieldInSendTy => [NON_SEND_FIELD_IN_SEND_TY]);
|
||||
impl_lint_pass!(NonSendFieldInSendTy => [NON_SEND_FIELDS_IN_SEND_TY]);
|
||||
|
||||
impl<'tcx> LateLintPass<'tcx> for NonSendFieldInSendTy {
|
||||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
|
||||
|
@ -96,7 +96,7 @@ impl<'tcx> LateLintPass<'tcx> for NonSendFieldInSendTy {
|
|||
.did
|
||||
.as_local()
|
||||
.map(|local_def_id| hir_map.local_def_id_to_hir_id(local_def_id));
|
||||
if !is_lint_allowed(cx, NON_SEND_FIELD_IN_SEND_TY, field_hir_id);
|
||||
if !is_lint_allowed(cx, NON_SEND_FIELDS_IN_SEND_TY, field_hir_id);
|
||||
if let field_ty = field.ty(cx.tcx, impl_trait_substs);
|
||||
if !ty_allowed_in_send(cx, field_ty, send_trait);
|
||||
if let Node::Field(field_def) = hir_map.get(field_hir_id);
|
||||
|
@ -114,7 +114,7 @@ impl<'tcx> LateLintPass<'tcx> for NonSendFieldInSendTy {
|
|||
if !non_send_fields.is_empty() {
|
||||
span_lint_and_then(
|
||||
cx,
|
||||
NON_SEND_FIELD_IN_SEND_TY,
|
||||
NON_SEND_FIELDS_IN_SEND_TY,
|
||||
item.span,
|
||||
&format!(
|
||||
"this implementation is unsound, as some fields in `{}` are `!Send`",
|
|
@ -284,9 +284,9 @@ define_Conf! {
|
|||
///
|
||||
/// The list of unicode scripts allowed to be used in the scope.
|
||||
(allowed_scripts: Vec<String> = vec!["Latin".to_string()]),
|
||||
/// Lint: NON_SEND_FIELD_IN_SEND_TY.
|
||||
/// Lint: NON_SEND_FIELDS_IN_SEND_TY.
|
||||
///
|
||||
/// Whether to apply the raw pointer heuristic in `non_send_field_in_send_ty` lint.
|
||||
/// Whether to apply the raw pointer heuristic to determine if a type is `Send`.
|
||||
(enable_raw_pointer_heuristic_for_send: bool = true),
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![warn(clippy::non_send_field_in_send_ty)]
|
||||
#![warn(clippy::non_send_fields_in_send_ty)]
|
||||
#![feature(extern_types)]
|
||||
|
||||
use std::rc::Rc;
|
|
@ -4,7 +4,7 @@ error: this implementation is unsound, as some fields in `NoGeneric` are `!Send`
|
|||
LL | unsafe impl Send for NoGeneric {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::non-send-field-in-send-ty` implied by `-D warnings`
|
||||
= note: `-D clippy::non-send-fields-in-send-ty` implied by `-D warnings`
|
||||
note: the type of field `rc_is_not_send` is `!Send`
|
||||
--> $DIR/test.rs:8:5
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![warn(clippy::non_send_field_in_send_ty)]
|
||||
#![warn(clippy::non_send_fields_in_send_ty)]
|
||||
#![feature(extern_types)]
|
||||
|
||||
use std::cell::UnsafeCell;
|
||||
|
@ -95,16 +95,16 @@ pub struct HeuristicTest {
|
|||
unsafe impl Send for HeuristicTest {}
|
||||
|
||||
// Test attributes
|
||||
#[allow(clippy::non_send_field_in_send_ty)]
|
||||
#[allow(clippy::non_send_fields_in_send_ty)]
|
||||
pub struct AttrTest1<T>(T);
|
||||
|
||||
pub struct AttrTest2<T> {
|
||||
#[allow(clippy::non_send_field_in_send_ty)]
|
||||
#[allow(clippy::non_send_fields_in_send_ty)]
|
||||
field: T,
|
||||
}
|
||||
|
||||
pub enum AttrTest3<T> {
|
||||
#[allow(clippy::non_send_field_in_send_ty)]
|
||||
#[allow(clippy::non_send_fields_in_send_ty)]
|
||||
Enum1(T),
|
||||
Enum2(T),
|
||||
}
|
|
@ -1,167 +1,167 @@
|
|||
error: this implementation is unsound, as some fields in `RingBuffer<T>` are `!Send`
|
||||
--> $DIR/non_send_field_in_send_ty.rs:16:1
|
||||
--> $DIR/non_send_fields_in_send_ty.rs:16:1
|
||||
|
|
||||
LL | unsafe impl<T> Send for RingBuffer<T> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::non-send-field-in-send-ty` implied by `-D warnings`
|
||||
= note: `-D clippy::non-send-fields-in-send-ty` implied by `-D warnings`
|
||||
note: the type of field `data` is `!Send`
|
||||
--> $DIR/non_send_field_in_send_ty.rs:11:5
|
||||
--> $DIR/non_send_fields_in_send_ty.rs:11:5
|
||||
|
|
||||
LL | data: Vec<UnsafeCell<T>>,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= help: add bounds on type parameter `T` that satisfy `Vec<UnsafeCell<T>>: Send`
|
||||
|
||||
error: this implementation is unsound, as some fields in `MvccRwLock<T>` are `!Send`
|
||||
--> $DIR/non_send_field_in_send_ty.rs:24:1
|
||||
--> $DIR/non_send_fields_in_send_ty.rs:24:1
|
||||
|
|
||||
LL | unsafe impl<T> Send for MvccRwLock<T> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the type of field `lock` is `!Send`
|
||||
--> $DIR/non_send_field_in_send_ty.rs:21:5
|
||||
--> $DIR/non_send_fields_in_send_ty.rs:21:5
|
||||
|
|
||||
LL | lock: Mutex<Box<T>>,
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
= help: add bounds on type parameter `T` that satisfy `Mutex<Box<T>>: Send`
|
||||
|
||||
error: this implementation is unsound, as some fields in `ArcGuard<RC, T>` are `!Send`
|
||||
--> $DIR/non_send_field_in_send_ty.rs:32:1
|
||||
--> $DIR/non_send_fields_in_send_ty.rs:32:1
|
||||
|
|
||||
LL | unsafe impl<RC, T: Send> Send for ArcGuard<RC, T> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the type of field `head` is `!Send`
|
||||
--> $DIR/non_send_field_in_send_ty.rs:29:5
|
||||
--> $DIR/non_send_fields_in_send_ty.rs:29:5
|
||||
|
|
||||
LL | head: Arc<RC>,
|
||||
| ^^^^^^^^^^^^^
|
||||
= help: add bounds on type parameter `RC` that satisfy `Arc<RC>: Send`
|
||||
|
||||
error: this implementation is unsound, as some fields in `DeviceHandle<T>` are `!Send`
|
||||
--> $DIR/non_send_field_in_send_ty.rs:48:1
|
||||
--> $DIR/non_send_fields_in_send_ty.rs:48:1
|
||||
|
|
||||
LL | unsafe impl<T: UsbContext> Send for DeviceHandle<T> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the type of field `context` is `!Send`
|
||||
--> $DIR/non_send_field_in_send_ty.rs:44:5
|
||||
--> $DIR/non_send_fields_in_send_ty.rs:44:5
|
||||
|
|
||||
LL | context: T,
|
||||
| ^^^^^^^^^^
|
||||
= help: add `T: Send` bound in `Send` impl
|
||||
|
||||
error: this implementation is unsound, as some fields in `NoGeneric` are `!Send`
|
||||
--> $DIR/non_send_field_in_send_ty.rs:55:1
|
||||
--> $DIR/non_send_fields_in_send_ty.rs:55:1
|
||||
|
|
||||
LL | unsafe impl Send for NoGeneric {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the type of field `rc_is_not_send` is `!Send`
|
||||
--> $DIR/non_send_field_in_send_ty.rs:52:5
|
||||
--> $DIR/non_send_fields_in_send_ty.rs:52:5
|
||||
|
|
||||
LL | rc_is_not_send: Rc<String>,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= help: use a thread-safe type that implements `Send`
|
||||
|
||||
error: this implementation is unsound, as some fields in `MultiField<T>` are `!Send`
|
||||
--> $DIR/non_send_field_in_send_ty.rs:63:1
|
||||
--> $DIR/non_send_fields_in_send_ty.rs:63:1
|
||||
|
|
||||
LL | unsafe impl<T> Send for MultiField<T> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the type of field `field1` is `!Send`
|
||||
--> $DIR/non_send_field_in_send_ty.rs:58:5
|
||||
--> $DIR/non_send_fields_in_send_ty.rs:58:5
|
||||
|
|
||||
LL | field1: T,
|
||||
| ^^^^^^^^^
|
||||
= help: add `T: Send` bound in `Send` impl
|
||||
note: the type of field `field2` is `!Send`
|
||||
--> $DIR/non_send_field_in_send_ty.rs:59:5
|
||||
--> $DIR/non_send_fields_in_send_ty.rs:59:5
|
||||
|
|
||||
LL | field2: T,
|
||||
| ^^^^^^^^^
|
||||
= help: add `T: Send` bound in `Send` impl
|
||||
note: the type of field `field3` is `!Send`
|
||||
--> $DIR/non_send_field_in_send_ty.rs:60:5
|
||||
--> $DIR/non_send_fields_in_send_ty.rs:60:5
|
||||
|
|
||||
LL | field3: T,
|
||||
| ^^^^^^^^^
|
||||
= help: add `T: Send` bound in `Send` impl
|
||||
|
||||
error: this implementation is unsound, as some fields in `MyOption<T>` are `!Send`
|
||||
--> $DIR/non_send_field_in_send_ty.rs:70:1
|
||||
--> $DIR/non_send_fields_in_send_ty.rs:70:1
|
||||
|
|
||||
LL | unsafe impl<T> Send for MyOption<T> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the type of field `0` is `!Send`
|
||||
--> $DIR/non_send_field_in_send_ty.rs:66:12
|
||||
--> $DIR/non_send_fields_in_send_ty.rs:66:12
|
||||
|
|
||||
LL | MySome(T),
|
||||
| ^
|
||||
= help: add `T: Send` bound in `Send` impl
|
||||
|
||||
error: this implementation is unsound, as some fields in `MultiParam<A, B>` are `!Send`
|
||||
--> $DIR/non_send_field_in_send_ty.rs:77:1
|
||||
--> $DIR/non_send_fields_in_send_ty.rs:77:1
|
||||
|
|
||||
LL | unsafe impl<A, B> Send for MultiParam<A, B> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the type of field `vec` is `!Send`
|
||||
--> $DIR/non_send_field_in_send_ty.rs:74:5
|
||||
--> $DIR/non_send_fields_in_send_ty.rs:74:5
|
||||
|
|
||||
LL | vec: Vec<(A, B)>,
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
= help: add bounds on type parameters `A, B` that satisfy `Vec<(A, B)>: Send`
|
||||
|
||||
error: this implementation is unsound, as some fields in `HeuristicTest` are `!Send`
|
||||
--> $DIR/non_send_field_in_send_ty.rs:95:1
|
||||
--> $DIR/non_send_fields_in_send_ty.rs:95:1
|
||||
|
|
||||
LL | unsafe impl Send for HeuristicTest {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the type of field `field4` is `!Send`
|
||||
--> $DIR/non_send_field_in_send_ty.rs:90:5
|
||||
--> $DIR/non_send_fields_in_send_ty.rs:90:5
|
||||
|
|
||||
LL | field4: (*const NonSend, Rc<u8>),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= help: use a thread-safe type that implements `Send`
|
||||
|
||||
error: this implementation is unsound, as some fields in `AttrTest3<T>` are `!Send`
|
||||
--> $DIR/non_send_field_in_send_ty.rs:114:1
|
||||
--> $DIR/non_send_fields_in_send_ty.rs:114:1
|
||||
|
|
||||
LL | unsafe impl<T> Send for AttrTest3<T> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the type of field `0` is `!Send`
|
||||
--> $DIR/non_send_field_in_send_ty.rs:109:11
|
||||
--> $DIR/non_send_fields_in_send_ty.rs:109:11
|
||||
|
|
||||
LL | Enum2(T),
|
||||
| ^
|
||||
= help: add `T: Send` bound in `Send` impl
|
||||
|
||||
error: this implementation is unsound, as some fields in `Complex<P, u32>` are `!Send`
|
||||
--> $DIR/non_send_field_in_send_ty.rs:122:1
|
||||
--> $DIR/non_send_fields_in_send_ty.rs:122:1
|
||||
|
|
||||
LL | unsafe impl<P> Send for Complex<P, u32> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the type of field `field1` is `!Send`
|
||||
--> $DIR/non_send_field_in_send_ty.rs:118:5
|
||||
--> $DIR/non_send_fields_in_send_ty.rs:118:5
|
||||
|
|
||||
LL | field1: A,
|
||||
| ^^^^^^^^^
|
||||
= help: add `P: Send` bound in `Send` impl
|
||||
|
||||
error: this implementation is unsound, as some fields in `Complex<Q, MutexGuard<'static, bool>>` are `!Send`
|
||||
--> $DIR/non_send_field_in_send_ty.rs:125:1
|
||||
--> $DIR/non_send_fields_in_send_ty.rs:125:1
|
||||
|
|
||||
LL | unsafe impl<Q: Send> Send for Complex<Q, MutexGuard<'static, bool>> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the type of field `field2` is `!Send`
|
||||
--> $DIR/non_send_field_in_send_ty.rs:119:5
|
||||
--> $DIR/non_send_fields_in_send_ty.rs:119:5
|
||||
|
|
||||
LL | field2: B,
|
||||
| ^^^^^^^^^
|
Loading…
Reference in a new issue