From b7f18916fa46c6ed25aed3b27e149850864b1f0e Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Wed, 17 Nov 2021 07:39:21 +0100 Subject: [PATCH] Pluralize disallowed_type lint This was brought up in [Zulip] and is also mentioned in the lint naming conventions. Since this is still a nursery lint, I think there shouldn't be any problem in renaming it. [Zulip]: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/disallow_type.20vs.20disallowed-types --- CHANGELOG.md | 8 +-- clippy_lints/src/disallowed_type.rs | 14 ++-- clippy_lints/src/lib.register_lints.rs | 2 +- clippy_lints/src/lib.register_nursery.rs | 2 +- clippy_lints/src/lib.rs | 3 +- clippy_lints/src/utils/conf.rs | 4 +- .../conf_disallowed_type.rs | 2 +- .../conf_disallowed_type.stderr | 2 +- tests/ui/rename.fixed | 2 + tests/ui/rename.rs | 2 + tests/ui/rename.stderr | 68 ++++++++++--------- 11 files changed, 60 insertions(+), 49 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6bbcbdad89..e21e550ede2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -174,7 +174,7 @@ Current stable, released 2021-10-21 * [`needless_continue`]: Now also lints in `loop { continue; }` case [#7477](https://github.com/rust-lang/rust-clippy/pull/7477) -* [`disallowed_type`]: Now also primitive types can be disallowed +* [`disallowed_types`]: Now also primitive types can be disallowed [#7488](https://github.com/rust-lang/rust-clippy/pull/7488) * [`manual_swap`]: Now also lints on xor swaps [#7506](https://github.com/rust-lang/rust-clippy/pull/7506) @@ -248,7 +248,7 @@ Released 2021-09-09 [#7403](https://github.com/rust-lang/rust-clippy/pull/7403) * [`disallowed_script_idents`] [#7400](https://github.com/rust-lang/rust-clippy/pull/7400) -* [`disallowed_type`] +* [`disallowed_types`] [#7315](https://github.com/rust-lang/rust-clippy/pull/7315) * [`missing_enforced_import_renames`] [#7300](https://github.com/rust-lang/rust-clippy/pull/7300) @@ -294,7 +294,7 @@ Released 2021-09-09 [#7379](https://github.com/rust-lang/rust-clippy/pull/7379) * [`redundant_closure`]: Suggests `&mut` for `FnMut` [#7437](https://github.com/rust-lang/rust-clippy/pull/7437) -* [`disallowed_method`], [`disallowed_type`]: The configuration values `disallowed-method` and `disallowed-type` +* [`disallowed_method`], [`disallowed_types`]: The configuration values `disallowed-method` and `disallowed-type` no longer require fully qualified paths [#7345](https://github.com/rust-lang/rust-clippy/pull/7345) * [`zst_offset`]: Fixed lint invocation after it was accidentally suppressed @@ -2823,7 +2823,7 @@ Released 2018-09-13 [`derive_ord_xor_partial_ord`]: https://rust-lang.github.io/rust-clippy/master/index.html#derive_ord_xor_partial_ord [`disallowed_method`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_method [`disallowed_script_idents`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_script_idents -[`disallowed_type`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_type +[`disallowed_types`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_types [`diverging_sub_expression`]: https://rust-lang.github.io/rust-clippy/master/index.html#diverging_sub_expression [`doc_markdown`]: https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown [`double_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#double_comparisons diff --git a/clippy_lints/src/disallowed_type.rs b/clippy_lints/src/disallowed_type.rs index 7e784ca2244..eaed4032713 100644 --- a/clippy_lints/src/disallowed_type.rs +++ b/clippy_lints/src/disallowed_type.rs @@ -43,18 +43,18 @@ declare_clippy_lint! { /// use std::collections::HashMap; /// ``` #[clippy::version = "1.55.0"] - pub DISALLOWED_TYPE, + pub DISALLOWED_TYPES, nursery, - "use of a disallowed type" + "use of disallowed types" } #[derive(Clone, Debug)] -pub struct DisallowedType { +pub struct DisallowedTypes { conf_disallowed: Vec, def_ids: FxHashMap>, prim_tys: FxHashMap>, } -impl DisallowedType { +impl DisallowedTypes { pub fn new(conf_disallowed: Vec) -> Self { Self { conf_disallowed, @@ -80,9 +80,9 @@ impl DisallowedType { } } -impl_lint_pass!(DisallowedType => [DISALLOWED_TYPE]); +impl_lint_pass!(DisallowedTypes => [DISALLOWED_TYPES]); -impl<'tcx> LateLintPass<'tcx> for DisallowedType { +impl<'tcx> LateLintPass<'tcx> for DisallowedTypes { fn check_crate(&mut self, cx: &LateContext<'_>) { for conf in &self.conf_disallowed { let (path, reason) = match conf { @@ -125,7 +125,7 @@ impl<'tcx> LateLintPass<'tcx> for DisallowedType { fn emit(cx: &LateContext<'_>, name: &str, span: Span, reason: Option<&str>) { span_lint_and_then( cx, - DISALLOWED_TYPE, + DISALLOWED_TYPES, span, &format!("`{}` is not allowed according to config", name), |diag| { diff --git a/clippy_lints/src/lib.register_lints.rs b/clippy_lints/src/lib.register_lints.rs index d931227765f..4a4fd76da07 100644 --- a/clippy_lints/src/lib.register_lints.rs +++ b/clippy_lints/src/lib.register_lints.rs @@ -99,7 +99,7 @@ store.register_lints(&[ derive::UNSAFE_DERIVE_DESERIALIZE, disallowed_method::DISALLOWED_METHOD, disallowed_script_idents::DISALLOWED_SCRIPT_IDENTS, - disallowed_type::DISALLOWED_TYPE, + disallowed_type::DISALLOWED_TYPES, doc::DOC_MARKDOWN, doc::MISSING_ERRORS_DOC, doc::MISSING_PANICS_DOC, diff --git a/clippy_lints/src/lib.register_nursery.rs b/clippy_lints/src/lib.register_nursery.rs index cc0eb71be69..3adb9881a71 100644 --- a/clippy_lints/src/lib.register_nursery.rs +++ b/clippy_lints/src/lib.register_nursery.rs @@ -7,7 +7,7 @@ store.register_group(true, "clippy::nursery", Some("clippy_nursery"), vec![ LintId::of(cognitive_complexity::COGNITIVE_COMPLEXITY), LintId::of(copies::BRANCHES_SHARING_CODE), LintId::of(disallowed_method::DISALLOWED_METHOD), - LintId::of(disallowed_type::DISALLOWED_TYPE), + LintId::of(disallowed_type::DISALLOWED_TYPES), LintId::of(equatable_if_let::EQUATABLE_IF_LET), LintId::of(fallible_impl_from::FALLIBLE_IMPL_FROM), LintId::of(floating_point_arithmetic::IMPRECISE_FLOPS), diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 2445a0aeed0..d65ef3b8728 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -827,7 +827,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: store.register_early_pass(move || Box::new(module_style::ModStyle)); store.register_late_pass(|| Box::new(unused_async::UnusedAsync)); let disallowed_types = conf.disallowed_types.clone(); - store.register_late_pass(move || Box::new(disallowed_type::DisallowedType::new(disallowed_types.clone()))); + store.register_late_pass(move || Box::new(disallowed_type::DisallowedTypes::new(disallowed_types.clone()))); let import_renames = conf.enforced_import_renames.clone(); store.register_late_pass(move || { Box::new(missing_enforced_import_rename::ImportRename::new( @@ -924,6 +924,7 @@ pub fn register_renamed(ls: &mut rustc_lint::LintStore) { ls.register_renamed("clippy::zero_width_space", "clippy::invisible_characters"); ls.register_renamed("clippy::single_char_push_str", "clippy::single_char_add_str"); ls.register_renamed("clippy::if_let_some_result", "clippy::match_result_ok"); + ls.register_renamed("clippy::disallowed_type", "clippy::disallowed_types"); // uplifted lints ls.register_renamed("clippy::invalid_ref", "invalid_value"); diff --git a/clippy_lints/src/utils/conf.rs b/clippy_lints/src/utils/conf.rs index 1a170807980..18e28cc4ca3 100644 --- a/clippy_lints/src/utils/conf.rs +++ b/clippy_lints/src/utils/conf.rs @@ -23,7 +23,7 @@ pub enum DisallowedMethod { WithReason { path: String, reason: Option }, } -/// A single disallowed type, used by the `DISALLOWED_TYPE` lint. +/// A single disallowed type, used by the `DISALLOWED_TYPES` lint. #[derive(Clone, Debug, Deserialize)] #[serde(untagged)] pub enum DisallowedType { @@ -260,7 +260,7 @@ define_Conf! { /// /// The list of disallowed methods, written as fully qualified paths. (disallowed_methods: Vec = Vec::new()), - /// Lint: DISALLOWED_TYPE. + /// Lint: DISALLOWED_TYPES. /// /// The list of disallowed types, written as fully qualified paths. (disallowed_types: Vec = Vec::new()), diff --git a/tests/ui-toml/toml_disallowed_type/conf_disallowed_type.rs b/tests/ui-toml/toml_disallowed_type/conf_disallowed_type.rs index 410f0765055..7f28efd676f 100644 --- a/tests/ui-toml/toml_disallowed_type/conf_disallowed_type.rs +++ b/tests/ui-toml/toml_disallowed_type/conf_disallowed_type.rs @@ -1,4 +1,4 @@ -#![warn(clippy::disallowed_type)] +#![warn(clippy::disallowed_types)] extern crate quote; extern crate syn; diff --git a/tests/ui-toml/toml_disallowed_type/conf_disallowed_type.stderr b/tests/ui-toml/toml_disallowed_type/conf_disallowed_type.stderr index 08a400a8367..25efd62d0ec 100644 --- a/tests/ui-toml/toml_disallowed_type/conf_disallowed_type.stderr +++ b/tests/ui-toml/toml_disallowed_type/conf_disallowed_type.stderr @@ -4,7 +4,7 @@ error: `std::sync::atomic::AtomicU32` is not allowed according to config LL | use std::sync::atomic::AtomicU32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::disallowed-type` implied by `-D warnings` + = note: `-D clippy::disallowed-types` implied by `-D warnings` error: `std::time::Instant` is not allowed according to config --> $DIR/conf_disallowed_type.rs:8:1 diff --git a/tests/ui/rename.fixed b/tests/ui/rename.fixed index cc295b509bc..2517eeeaa01 100644 --- a/tests/ui/rename.fixed +++ b/tests/ui/rename.fixed @@ -17,6 +17,7 @@ #![allow(clippy::invisible_characters)] #![allow(clippy::single_char_add_str)] #![allow(clippy::match_result_ok)] +#![allow(clippy::disallowed_types)] // uplifted lints #![allow(invalid_value)] #![allow(array_into_iter)] @@ -49,6 +50,7 @@ #![warn(clippy::invisible_characters)] #![warn(clippy::single_char_add_str)] #![warn(clippy::match_result_ok)] +#![warn(clippy::disallowed_types)] // uplifted lints #![warn(invalid_value)] #![warn(array_into_iter)] diff --git a/tests/ui/rename.rs b/tests/ui/rename.rs index 377075c0246..7205ee0da8f 100644 --- a/tests/ui/rename.rs +++ b/tests/ui/rename.rs @@ -17,6 +17,7 @@ #![allow(clippy::invisible_characters)] #![allow(clippy::single_char_add_str)] #![allow(clippy::match_result_ok)] +#![allow(clippy::disallowed_types)] // uplifted lints #![allow(invalid_value)] #![allow(array_into_iter)] @@ -49,6 +50,7 @@ #![warn(clippy::zero_width_space)] #![warn(clippy::single_char_push_str)] #![warn(clippy::if_let_some_result)] +#![warn(clippy::disallowed_type)] // uplifted lints #![warn(clippy::invalid_ref)] #![warn(clippy::into_iter_on_array)] diff --git a/tests/ui/rename.stderr b/tests/ui/rename.stderr index d720f10d117..1449112996f 100644 --- a/tests/ui/rename.stderr +++ b/tests/ui/rename.stderr @@ -1,5 +1,5 @@ error: lint `clippy::stutter` has been renamed to `clippy::module_name_repetitions` - --> $DIR/rename.rs:31:9 + --> $DIR/rename.rs:32:9 | LL | #![warn(clippy::stutter)] | ^^^^^^^^^^^^^^^ help: use the new name: `clippy::module_name_repetitions` @@ -7,178 +7,184 @@ LL | #![warn(clippy::stutter)] = note: `-D renamed-and-removed-lints` implied by `-D warnings` error: lint `clippy::new_without_default_derive` has been renamed to `clippy::new_without_default` - --> $DIR/rename.rs:32:9 + --> $DIR/rename.rs:33:9 | LL | #![warn(clippy::new_without_default_derive)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::new_without_default` error: lint `clippy::const_static_lifetime` has been renamed to `clippy::redundant_static_lifetimes` - --> $DIR/rename.rs:33:9 + --> $DIR/rename.rs:34:9 | LL | #![warn(clippy::const_static_lifetime)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::redundant_static_lifetimes` error: lint `clippy::cyclomatic_complexity` has been renamed to `clippy::cognitive_complexity` - --> $DIR/rename.rs:34:9 + --> $DIR/rename.rs:35:9 | LL | #![warn(clippy::cyclomatic_complexity)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::cognitive_complexity` error: lint `clippy::option_and_then_some` has been renamed to `clippy::bind_instead_of_map` - --> $DIR/rename.rs:35:9 + --> $DIR/rename.rs:36:9 | LL | #![warn(clippy::option_and_then_some)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::bind_instead_of_map` error: lint `clippy::box_vec` has been renamed to `clippy::box_collection` - --> $DIR/rename.rs:36:9 + --> $DIR/rename.rs:37:9 | LL | #![warn(clippy::box_vec)] | ^^^^^^^^^^^^^^^ help: use the new name: `clippy::box_collection` error: lint `clippy::block_in_if_condition_expr` has been renamed to `clippy::blocks_in_if_conditions` - --> $DIR/rename.rs:37:9 + --> $DIR/rename.rs:38:9 | LL | #![warn(clippy::block_in_if_condition_expr)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_if_conditions` error: lint `clippy::block_in_if_condition_stmt` has been renamed to `clippy::blocks_in_if_conditions` - --> $DIR/rename.rs:38:9 + --> $DIR/rename.rs:39:9 | LL | #![warn(clippy::block_in_if_condition_stmt)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_if_conditions` error: lint `clippy::option_map_unwrap_or` has been renamed to `clippy::map_unwrap_or` - --> $DIR/rename.rs:39:9 + --> $DIR/rename.rs:40:9 | LL | #![warn(clippy::option_map_unwrap_or)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or` error: lint `clippy::option_map_unwrap_or_else` has been renamed to `clippy::map_unwrap_or` - --> $DIR/rename.rs:40:9 + --> $DIR/rename.rs:41:9 | LL | #![warn(clippy::option_map_unwrap_or_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or` error: lint `clippy::result_map_unwrap_or_else` has been renamed to `clippy::map_unwrap_or` - --> $DIR/rename.rs:41:9 + --> $DIR/rename.rs:42:9 | LL | #![warn(clippy::result_map_unwrap_or_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or` error: lint `clippy::option_unwrap_used` has been renamed to `clippy::unwrap_used` - --> $DIR/rename.rs:42:9 + --> $DIR/rename.rs:43:9 | LL | #![warn(clippy::option_unwrap_used)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_used` error: lint `clippy::result_unwrap_used` has been renamed to `clippy::unwrap_used` - --> $DIR/rename.rs:43:9 + --> $DIR/rename.rs:44:9 | LL | #![warn(clippy::result_unwrap_used)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_used` error: lint `clippy::option_expect_used` has been renamed to `clippy::expect_used` - --> $DIR/rename.rs:44:9 + --> $DIR/rename.rs:45:9 | LL | #![warn(clippy::option_expect_used)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::expect_used` error: lint `clippy::result_expect_used` has been renamed to `clippy::expect_used` - --> $DIR/rename.rs:45:9 + --> $DIR/rename.rs:46:9 | LL | #![warn(clippy::result_expect_used)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::expect_used` error: lint `clippy::for_loop_over_option` has been renamed to `clippy::for_loops_over_fallibles` - --> $DIR/rename.rs:46:9 + --> $DIR/rename.rs:47:9 | LL | #![warn(clippy::for_loop_over_option)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::for_loops_over_fallibles` error: lint `clippy::for_loop_over_result` has been renamed to `clippy::for_loops_over_fallibles` - --> $DIR/rename.rs:47:9 + --> $DIR/rename.rs:48:9 | LL | #![warn(clippy::for_loop_over_result)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::for_loops_over_fallibles` error: lint `clippy::identity_conversion` has been renamed to `clippy::useless_conversion` - --> $DIR/rename.rs:48:9 + --> $DIR/rename.rs:49:9 | LL | #![warn(clippy::identity_conversion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::useless_conversion` error: lint `clippy::zero_width_space` has been renamed to `clippy::invisible_characters` - --> $DIR/rename.rs:49:9 + --> $DIR/rename.rs:50:9 | LL | #![warn(clippy::zero_width_space)] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::invisible_characters` error: lint `clippy::single_char_push_str` has been renamed to `clippy::single_char_add_str` - --> $DIR/rename.rs:50:9 + --> $DIR/rename.rs:51:9 | LL | #![warn(clippy::single_char_push_str)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::single_char_add_str` error: lint `clippy::if_let_some_result` has been renamed to `clippy::match_result_ok` - --> $DIR/rename.rs:51:9 + --> $DIR/rename.rs:52:9 | LL | #![warn(clippy::if_let_some_result)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::match_result_ok` -error: lint `clippy::invalid_ref` has been renamed to `invalid_value` +error: lint `clippy::disallowed_type` has been renamed to `clippy::disallowed_types` --> $DIR/rename.rs:53:9 | +LL | #![warn(clippy::disallowed_type)] + | ^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_types` + +error: lint `clippy::invalid_ref` has been renamed to `invalid_value` + --> $DIR/rename.rs:55:9 + | LL | #![warn(clippy::invalid_ref)] | ^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_value` error: lint `clippy::into_iter_on_array` has been renamed to `array_into_iter` - --> $DIR/rename.rs:54:9 + --> $DIR/rename.rs:56:9 | LL | #![warn(clippy::into_iter_on_array)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `array_into_iter` error: lint `clippy::unused_label` has been renamed to `unused_labels` - --> $DIR/rename.rs:55:9 + --> $DIR/rename.rs:57:9 | LL | #![warn(clippy::unused_label)] | ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unused_labels` error: lint `clippy::drop_bounds` has been renamed to `drop_bounds` - --> $DIR/rename.rs:56:9 + --> $DIR/rename.rs:58:9 | LL | #![warn(clippy::drop_bounds)] | ^^^^^^^^^^^^^^^^^^^ help: use the new name: `drop_bounds` error: lint `clippy::temporary_cstring_as_ptr` has been renamed to `temporary_cstring_as_ptr` - --> $DIR/rename.rs:57:9 + --> $DIR/rename.rs:59:9 | LL | #![warn(clippy::temporary_cstring_as_ptr)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `temporary_cstring_as_ptr` error: lint `clippy::panic_params` has been renamed to `non_fmt_panics` - --> $DIR/rename.rs:58:9 + --> $DIR/rename.rs:60:9 | LL | #![warn(clippy::panic_params)] | ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `non_fmt_panics` error: lint `clippy::unknown_clippy_lints` has been renamed to `unknown_lints` - --> $DIR/rename.rs:59:9 + --> $DIR/rename.rs:61:9 | LL | #![warn(clippy::unknown_clippy_lints)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unknown_lints` error: lint `clippy::invalid_atomic_ordering` has been renamed to `invalid_atomic_ordering` - --> $DIR/rename.rs:60:9 + --> $DIR/rename.rs:62:9 | LL | #![warn(clippy::invalid_atomic_ordering)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_atomic_ordering` error: lint `clippy::mem_discriminant_non_enum` has been renamed to `enum_intrinsics_non_enums` - --> $DIR/rename.rs:61:9 + --> $DIR/rename.rs:63:9 | LL | #![warn(clippy::mem_discriminant_non_enum)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `enum_intrinsics_non_enums` -error: aborting due to 30 previous errors +error: aborting due to 31 previous errors