From 15b9e9f23a3e10ca9cf2364f47ae8e1910df6eff Mon Sep 17 00:00:00 2001 From: Klaus Purer Date: Sun, 16 Dec 2018 14:10:53 +0100 Subject: [PATCH 1/6] chore(moduel_name_repeat): Rename stutter lint to module_name_repeat to avoid ableist language --- clippy_lints/src/enum_variants.rs | 8 ++++---- clippy_lints/src/lib.rs | 2 +- tests/ui/{stutter.rs => module_name_repeat.rs} | 2 +- .../ui/{stutter.stderr => module_name_repeat.stderr} | 12 ++++++------ 4 files changed, 12 insertions(+), 12 deletions(-) rename tests/ui/{stutter.rs => module_name_repeat.rs} (94%) rename tests/ui/{stutter.stderr => module_name_repeat.stderr} (71%) diff --git a/clippy_lints/src/enum_variants.rs b/clippy_lints/src/enum_variants.rs index ae87c4273e92..861e1177296c 100644 --- a/clippy_lints/src/enum_variants.rs +++ b/clippy_lints/src/enum_variants.rs @@ -75,7 +75,7 @@ declare_clippy_lint! { /// } /// ``` declare_clippy_lint! { - pub STUTTER, + pub MODULE_NAME_REPEAT, pedantic, "type names prefixed/postfixed with their containing module's name" } @@ -126,7 +126,7 @@ impl EnumVariantNames { impl LintPass for EnumVariantNames { fn get_lints(&self) -> LintArray { - lint_array!(ENUM_VARIANT_NAMES, PUB_ENUM_VARIANT_NAMES, STUTTER, MODULE_INCEPTION) + lint_array!(ENUM_VARIANT_NAMES, PUB_ENUM_VARIANT_NAMES, MODULE_NAME_REPEAT, MODULE_INCEPTION) } } @@ -277,7 +277,7 @@ impl EarlyLintPass for EnumVariantNames { match item_camel.chars().nth(nchars) { Some(c) if is_word_beginning(c) => span_lint( cx, - STUTTER, + MODULE_NAME_REPEAT, item.span, "item name starts with its containing module's name", ), @@ -287,7 +287,7 @@ impl EarlyLintPass for EnumVariantNames { if rmatching == nchars { span_lint( cx, - STUTTER, + MODULE_NAME_REPEAT, item.span, "item name ends with its containing module's name", ); diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index f4b5edee84c5..1abca1751e86 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -518,7 +518,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { empty_enum::EMPTY_ENUM, enum_glob_use::ENUM_GLOB_USE, enum_variants::PUB_ENUM_VARIANT_NAMES, - enum_variants::STUTTER, + enum_variants::MODULE_NAME_REPEAT, if_not_else::IF_NOT_ELSE, infinite_iter::MAYBE_INFINITE_ITER, items_after_statements::ITEMS_AFTER_STATEMENTS, diff --git a/tests/ui/stutter.rs b/tests/ui/module_name_repeat.rs similarity index 94% rename from tests/ui/stutter.rs rename to tests/ui/module_name_repeat.rs index 922487d671d0..a302eaacccf2 100644 --- a/tests/ui/stutter.rs +++ b/tests/ui/module_name_repeat.rs @@ -7,7 +7,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![warn(clippy::stutter)] +#![warn(clippy::module_name_repeat)] #![allow(dead_code)] mod foo { diff --git a/tests/ui/stutter.stderr b/tests/ui/module_name_repeat.stderr similarity index 71% rename from tests/ui/stutter.stderr rename to tests/ui/module_name_repeat.stderr index 8c2d1d432813..9547fa9fdd6b 100644 --- a/tests/ui/stutter.stderr +++ b/tests/ui/module_name_repeat.stderr @@ -1,31 +1,31 @@ error: item name starts with its containing module's name - --> $DIR/stutter.rs:15:5 + --> $DIR/module_name_repeat.rs:15:5 | 15 | pub fn foo_bar() {} | ^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::stutter` implied by `-D warnings` + = note: `-D clippy::module-name-repeat` implied by `-D warnings` error: item name ends with its containing module's name - --> $DIR/stutter.rs:16:5 + --> $DIR/module_name_repeat.rs:16:5 | 16 | pub fn bar_foo() {} | ^^^^^^^^^^^^^^^^^^^ error: item name starts with its containing module's name - --> $DIR/stutter.rs:17:5 + --> $DIR/module_name_repeat.rs:17:5 | 17 | pub struct FooCake {} | ^^^^^^^^^^^^^^^^^^^^^ error: item name ends with its containing module's name - --> $DIR/stutter.rs:18:5 + --> $DIR/module_name_repeat.rs:18:5 | 18 | pub enum CakeFoo {} | ^^^^^^^^^^^^^^^^^^^ error: item name starts with its containing module's name - --> $DIR/stutter.rs:19:5 + --> $DIR/module_name_repeat.rs:19:5 | 19 | pub struct Foo7Bar; | ^^^^^^^^^^^^^^^^^^^ From 355018d0860c5aba29045c305adb2b02003e9942 Mon Sep 17 00:00:00 2001 From: Klaus Purer Date: Sun, 16 Dec 2018 22:49:46 +0100 Subject: [PATCH 2/6] fix(module_name_repeat): Try to register renamed lint, not valid yet --- CHANGELOG.md | 2 +- clippy_lints/src/lib.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1713fda031f6..d773238597eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -760,6 +760,7 @@ All notable changes to this project will be documented in this file. [`mistyped_literal_suffixes`]: https://rust-lang.github.io/rust-clippy/master/index.html#mistyped_literal_suffixes [`mixed_case_hex_literals`]: https://rust-lang.github.io/rust-clippy/master/index.html#mixed_case_hex_literals [`module_inception`]: https://rust-lang.github.io/rust-clippy/master/index.html#module_inception +[`module_name_repeat`]: https://rust-lang.github.io/rust-clippy/master/index.html#module_name_repeat [`modulo_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#modulo_one [`multiple_crate_versions`]: https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions [`multiple_inherent_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#multiple_inherent_impl @@ -850,7 +851,6 @@ All notable changes to this project will be documented in this file. [`string_extend_chars`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_extend_chars [`string_lit_as_bytes`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_lit_as_bytes [`string_to_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_to_string -[`stutter`]: https://rust-lang.github.io/rust-clippy/master/index.html#stutter [`suspicious_arithmetic_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_arithmetic_impl [`suspicious_assignment_formatting`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_assignment_formatting [`suspicious_else_formatting`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_else_formatting diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 1abca1751e86..8f528ea83e38 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -517,8 +517,8 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { doc::DOC_MARKDOWN, empty_enum::EMPTY_ENUM, enum_glob_use::ENUM_GLOB_USE, - enum_variants::PUB_ENUM_VARIANT_NAMES, enum_variants::MODULE_NAME_REPEAT, + enum_variants::PUB_ENUM_VARIANT_NAMES, if_not_else::IF_NOT_ELSE, infinite_iter::MAYBE_INFINITE_ITER, items_after_statements::ITEMS_AFTER_STATEMENTS, @@ -1028,6 +1028,8 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { unwrap::PANICKING_UNWRAP, unwrap::UNNECESSARY_UNWRAP, ]); + + store.register_renamed("stutter", "module_name_repeat"); } // only exists to let the dogfood integration test works. From 0516c2e04a620493fe92b82c4cdecf32dae2f96a Mon Sep 17 00:00:00 2001 From: flip1995 Date: Mon, 17 Dec 2018 13:58:41 +0100 Subject: [PATCH 3/6] Move renaming to the right place --- clippy_lints/src/lib.rs | 4 +++- src/driver.rs | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 8f528ea83e38..5c1469536f51 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -1028,8 +1028,10 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { unwrap::PANICKING_UNWRAP, unwrap::UNNECESSARY_UNWRAP, ]); +} - store.register_renamed("stutter", "module_name_repeat"); +pub fn register_renamed(ls: &mut rustc::lint::LintStore) { + ls.register_renamed("clippy::stutter", "clippy::module_name_repeat"); } // only exists to let the dogfood integration test works. diff --git a/src/driver.rs b/src/driver.rs index 6b327d08207f..0df2d8988601 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -110,6 +110,7 @@ pub fn main() { ls.register_group(Some(sess), true, name, deprecated_name, to); } clippy_lints::register_pre_expansion_lints(sess, &mut ls, &conf); + clippy_lints::register_renamed(&mut ls); sess.plugin_llvm_passes.borrow_mut().extend(llvm_passes); sess.plugin_attributes.borrow_mut().extend(attributes); From 60cc6b931996b65a053699973bb08487e31bf9f0 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Mon, 17 Dec 2018 13:59:09 +0100 Subject: [PATCH 4/6] Add renaming tests --- tests/ui/rename.rs | 13 +++++++++++++ tests/ui/rename.stderr | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tests/ui/rename.rs create mode 100644 tests/ui/rename.stderr diff --git a/tests/ui/rename.rs b/tests/ui/rename.rs new file mode 100644 index 000000000000..8d76a2d4586d --- /dev/null +++ b/tests/ui/rename.rs @@ -0,0 +1,13 @@ +// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(stutter)] + +#[warn(clippy::stutter)] +fn main() {} diff --git a/tests/ui/rename.stderr b/tests/ui/rename.stderr new file mode 100644 index 000000000000..9aa22eb6c457 --- /dev/null +++ b/tests/ui/rename.stderr @@ -0,0 +1,18 @@ +error: unknown lint: `stutter` + --> $DIR/rename.rs:10:10 + | +10 | #![allow(stutter)] + | ^^^^^^^ + | + = note: `-D unknown-lints` implied by `-D warnings` + +error: lint `clippy::stutter` has been renamed to `clippy::module_name_repeat` + --> $DIR/rename.rs:12:8 + | +12 | #[warn(clippy::stutter)] + | ^^^^^^^^^^^^^^^ help: use the new name: `clippy::module_name_repeat` + | + = note: `-D renamed-and-removed-lints` implied by `-D warnings` + +error: aborting due to 2 previous errors + From a44adaa5edd793da13665734a6de2d46d584e733 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Mon, 17 Dec 2018 14:29:19 +0100 Subject: [PATCH 5/6] Rename lint to MODULE_NAME_REPETITIONS --- clippy_lints/src/enum_variants.rs | 13 +++++++++---- clippy_lints/src/lib.rs | 4 ++-- ...le_name_repeat.rs => module_name_repetitions.rs} | 2 +- ...repeat.stderr => module_name_repetitions.stderr} | 12 ++++++------ tests/ui/rename.stderr | 4 ++-- 5 files changed, 20 insertions(+), 15 deletions(-) rename tests/ui/{module_name_repeat.rs => module_name_repetitions.rs} (94%) rename tests/ui/{module_name_repeat.stderr => module_name_repetitions.stderr} (69%) diff --git a/clippy_lints/src/enum_variants.rs b/clippy_lints/src/enum_variants.rs index 861e1177296c..c6142a168548 100644 --- a/clippy_lints/src/enum_variants.rs +++ b/clippy_lints/src/enum_variants.rs @@ -75,7 +75,7 @@ declare_clippy_lint! { /// } /// ``` declare_clippy_lint! { - pub MODULE_NAME_REPEAT, + pub MODULE_NAME_REPETITIONS, pedantic, "type names prefixed/postfixed with their containing module's name" } @@ -126,7 +126,12 @@ impl EnumVariantNames { impl LintPass for EnumVariantNames { fn get_lints(&self) -> LintArray { - lint_array!(ENUM_VARIANT_NAMES, PUB_ENUM_VARIANT_NAMES, MODULE_NAME_REPEAT, MODULE_INCEPTION) + lint_array!( + ENUM_VARIANT_NAMES, + PUB_ENUM_VARIANT_NAMES, + MODULE_NAME_REPETITIONS, + MODULE_INCEPTION + ) } } @@ -277,7 +282,7 @@ impl EarlyLintPass for EnumVariantNames { match item_camel.chars().nth(nchars) { Some(c) if is_word_beginning(c) => span_lint( cx, - MODULE_NAME_REPEAT, + MODULE_NAME_REPETITIONS, item.span, "item name starts with its containing module's name", ), @@ -287,7 +292,7 @@ impl EarlyLintPass for EnumVariantNames { if rmatching == nchars { span_lint( cx, - MODULE_NAME_REPEAT, + MODULE_NAME_REPETITIONS, item.span, "item name ends with its containing module's name", ); diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 5c1469536f51..8ce5861a939b 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -517,7 +517,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { doc::DOC_MARKDOWN, empty_enum::EMPTY_ENUM, enum_glob_use::ENUM_GLOB_USE, - enum_variants::MODULE_NAME_REPEAT, + enum_variants::MODULE_NAME_REPETITIONS, enum_variants::PUB_ENUM_VARIANT_NAMES, if_not_else::IF_NOT_ELSE, infinite_iter::MAYBE_INFINITE_ITER, @@ -1031,7 +1031,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { } pub fn register_renamed(ls: &mut rustc::lint::LintStore) { - ls.register_renamed("clippy::stutter", "clippy::module_name_repeat"); + ls.register_renamed("clippy::stutter", "clippy::module_name_repetitions"); } // only exists to let the dogfood integration test works. diff --git a/tests/ui/module_name_repeat.rs b/tests/ui/module_name_repetitions.rs similarity index 94% rename from tests/ui/module_name_repeat.rs rename to tests/ui/module_name_repetitions.rs index a302eaacccf2..4db4f56de46f 100644 --- a/tests/ui/module_name_repeat.rs +++ b/tests/ui/module_name_repetitions.rs @@ -7,7 +7,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![warn(clippy::module_name_repeat)] +#![warn(clippy::module_name_repetitions)] #![allow(dead_code)] mod foo { diff --git a/tests/ui/module_name_repeat.stderr b/tests/ui/module_name_repetitions.stderr similarity index 69% rename from tests/ui/module_name_repeat.stderr rename to tests/ui/module_name_repetitions.stderr index 9547fa9fdd6b..e2eca64ba427 100644 --- a/tests/ui/module_name_repeat.stderr +++ b/tests/ui/module_name_repetitions.stderr @@ -1,31 +1,31 @@ error: item name starts with its containing module's name - --> $DIR/module_name_repeat.rs:15:5 + --> $DIR/module_name_repetitions.rs:15:5 | 15 | pub fn foo_bar() {} | ^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::module-name-repeat` implied by `-D warnings` + = note: `-D clippy::module-name-repetitions` implied by `-D warnings` error: item name ends with its containing module's name - --> $DIR/module_name_repeat.rs:16:5 + --> $DIR/module_name_repetitions.rs:16:5 | 16 | pub fn bar_foo() {} | ^^^^^^^^^^^^^^^^^^^ error: item name starts with its containing module's name - --> $DIR/module_name_repeat.rs:17:5 + --> $DIR/module_name_repetitions.rs:17:5 | 17 | pub struct FooCake {} | ^^^^^^^^^^^^^^^^^^^^^ error: item name ends with its containing module's name - --> $DIR/module_name_repeat.rs:18:5 + --> $DIR/module_name_repetitions.rs:18:5 | 18 | pub enum CakeFoo {} | ^^^^^^^^^^^^^^^^^^^ error: item name starts with its containing module's name - --> $DIR/module_name_repeat.rs:19:5 + --> $DIR/module_name_repetitions.rs:19:5 | 19 | pub struct Foo7Bar; | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rename.stderr b/tests/ui/rename.stderr index 9aa22eb6c457..7ad8228fb359 100644 --- a/tests/ui/rename.stderr +++ b/tests/ui/rename.stderr @@ -6,11 +6,11 @@ error: unknown lint: `stutter` | = note: `-D unknown-lints` implied by `-D warnings` -error: lint `clippy::stutter` has been renamed to `clippy::module_name_repeat` +error: lint `clippy::stutter` has been renamed to `clippy::module_name_repetitions` --> $DIR/rename.rs:12:8 | 12 | #[warn(clippy::stutter)] - | ^^^^^^^^^^^^^^^ help: use the new name: `clippy::module_name_repeat` + | ^^^^^^^^^^^^^^^ help: use the new name: `clippy::module_name_repetitions` | = note: `-D renamed-and-removed-lints` implied by `-D warnings` From d74288efce836ad67825b2d25f6c8889b06c7d7a Mon Sep 17 00:00:00 2001 From: flip1995 Date: Mon, 17 Dec 2018 14:33:05 +0100 Subject: [PATCH 6/6] Run update_lints after renaming --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d773238597eb..606f16061ac5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -760,7 +760,7 @@ All notable changes to this project will be documented in this file. [`mistyped_literal_suffixes`]: https://rust-lang.github.io/rust-clippy/master/index.html#mistyped_literal_suffixes [`mixed_case_hex_literals`]: https://rust-lang.github.io/rust-clippy/master/index.html#mixed_case_hex_literals [`module_inception`]: https://rust-lang.github.io/rust-clippy/master/index.html#module_inception -[`module_name_repeat`]: https://rust-lang.github.io/rust-clippy/master/index.html#module_name_repeat +[`module_name_repetitions`]: https://rust-lang.github.io/rust-clippy/master/index.html#module_name_repetitions [`modulo_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#modulo_one [`multiple_crate_versions`]: https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions [`multiple_inherent_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#multiple_inherent_impl