diff --git a/CHANGELOG.md b/CHANGELOG.md index df3fa2866c2..9a4424f5061 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/clippy_lints/src/lib.mods.rs b/clippy_lints/src/lib.mods.rs index 1d9d2be3443..7fd84783c22 100644 --- a/clippy_lints/src/lib.mods.rs +++ b/clippy_lints/src/lib.mods.rs @@ -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; diff --git a/clippy_lints/src/lib.register_lints.rs b/clippy_lints/src/lib.register_lints.rs index b1cd5aafe4c..28d54246fbb 100644 --- a/clippy_lints/src/lib.register_lints.rs +++ b/clippy_lints/src/lib.register_lints.rs @@ -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, diff --git a/clippy_lints/src/lib.register_nursery.rs b/clippy_lints/src/lib.register_nursery.rs index 56b4f9d2391..32606e570d8 100644 --- a/clippy_lints/src/lib.register_nursery.rs +++ b/clippy_lints/src/lib.register_nursery.rs @@ -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), diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 50b55e5f79a..c3be6db6ffa 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -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] diff --git a/clippy_lints/src/non_send_field_in_send_ty.rs b/clippy_lints/src/non_send_fields_in_send_ty.rs similarity index 97% rename from clippy_lints/src/non_send_field_in_send_ty.rs rename to clippy_lints/src/non_send_fields_in_send_ty.rs index 399b1a929e2..0dbf296c714 100644 --- a/clippy_lints/src/non_send_field_in_send_ty.rs +++ b/clippy_lints/src/non_send_fields_in_send_ty.rs @@ -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`", diff --git a/clippy_lints/src/utils/conf.rs b/clippy_lints/src/utils/conf.rs index e6233f73a57..6cbada4c150 100644 --- a/clippy_lints/src/utils/conf.rs +++ b/clippy_lints/src/utils/conf.rs @@ -284,9 +284,9 @@ define_Conf! { /// /// The list of unicode scripts allowed to be used in the scope. (allowed_scripts: Vec = 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), } diff --git a/tests/ui-toml/strict_non_send_field_in_send_ty/clippy.toml b/tests/ui-toml/strict_non_send_fields_in_send_ty/clippy.toml similarity index 100% rename from tests/ui-toml/strict_non_send_field_in_send_ty/clippy.toml rename to tests/ui-toml/strict_non_send_fields_in_send_ty/clippy.toml diff --git a/tests/ui-toml/strict_non_send_field_in_send_ty/test.rs b/tests/ui-toml/strict_non_send_fields_in_send_ty/test.rs similarity index 94% rename from tests/ui-toml/strict_non_send_field_in_send_ty/test.rs rename to tests/ui-toml/strict_non_send_fields_in_send_ty/test.rs index 6306c9c9f6d..90c2439dc34 100644 --- a/tests/ui-toml/strict_non_send_field_in_send_ty/test.rs +++ b/tests/ui-toml/strict_non_send_fields_in_send_ty/test.rs @@ -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; diff --git a/tests/ui-toml/strict_non_send_field_in_send_ty/test.stderr b/tests/ui-toml/strict_non_send_fields_in_send_ty/test.stderr similarity index 97% rename from tests/ui-toml/strict_non_send_field_in_send_ty/test.stderr rename to tests/ui-toml/strict_non_send_fields_in_send_ty/test.stderr index 74ec93cfa55..b07f9dd3df3 100644 --- a/tests/ui-toml/strict_non_send_field_in_send_ty/test.stderr +++ b/tests/ui-toml/strict_non_send_fields_in_send_ty/test.stderr @@ -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 | diff --git a/tests/ui/non_send_field_in_send_ty.rs b/tests/ui/non_send_fields_in_send_ty.rs similarity index 92% rename from tests/ui/non_send_field_in_send_ty.rs rename to tests/ui/non_send_fields_in_send_ty.rs index f5e7abdecd1..eca7f5e5655 100644 --- a/tests/ui/non_send_field_in_send_ty.rs +++ b/tests/ui/non_send_fields_in_send_ty.rs @@ -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); pub struct AttrTest2 { - #[allow(clippy::non_send_field_in_send_ty)] + #[allow(clippy::non_send_fields_in_send_ty)] field: T, } pub enum AttrTest3 { - #[allow(clippy::non_send_field_in_send_ty)] + #[allow(clippy::non_send_fields_in_send_ty)] Enum1(T), Enum2(T), } diff --git a/tests/ui/non_send_field_in_send_ty.stderr b/tests/ui/non_send_fields_in_send_ty.stderr similarity index 78% rename from tests/ui/non_send_field_in_send_ty.stderr rename to tests/ui/non_send_fields_in_send_ty.stderr index f49a7355b53..8b8a1d16d9b 100644 --- a/tests/ui/non_send_field_in_send_ty.stderr +++ b/tests/ui/non_send_fields_in_send_ty.stderr @@ -1,167 +1,167 @@ error: this implementation is unsound, as some fields in `RingBuffer` 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 Send for RingBuffer {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = 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>, | ^^^^^^^^^^^^^^^^^^^^^^^^ = help: add bounds on type parameter `T` that satisfy `Vec>: Send` error: this implementation is unsound, as some fields in `MvccRwLock` 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 Send for MvccRwLock {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | 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>, | ^^^^^^^^^^^^^^^^^^^ = help: add bounds on type parameter `T` that satisfy `Mutex>: Send` error: this implementation is unsound, as some fields in `ArcGuard` 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 Send for ArcGuard {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | 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, | ^^^^^^^^^^^^^ = help: add bounds on type parameter `RC` that satisfy `Arc: Send` error: this implementation is unsound, as some fields in `DeviceHandle` 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 Send for DeviceHandle {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | 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, | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use a thread-safe type that implements `Send` error: this implementation is unsound, as some fields in `MultiField` 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 Send for MultiField {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | 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` 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 Send for MyOption {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | 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` 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 Send for MultiParam {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | 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), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use a thread-safe type that implements `Send` error: this implementation is unsound, as some fields in `AttrTest3` 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 Send for AttrTest3 {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | 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` 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

Send for Complex {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | 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>` 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 Send for Complex> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | 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, | ^^^^^^^^^