diff --git a/CHANGELOG.md b/CHANGELOG.md index 83a3bfc48708..7d1f39e9cd99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3262,6 +3262,7 @@ Released 2018-09-13 [`empty_enum`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_enum [`empty_line_after_outer_attr`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_outer_attr [`empty_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_loop +[`empty_structs_with_brackets`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_structs_with_brackets [`enum_clike_unportable_variant`]: https://rust-lang.github.io/rust-clippy/master/index.html#enum_clike_unportable_variant [`enum_glob_use`]: https://rust-lang.github.io/rust-clippy/master/index.html#enum_glob_use [`enum_variant_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#enum_variant_names @@ -3635,7 +3636,6 @@ Released 2018-09-13 [`unit_arg`]: https://rust-lang.github.io/rust-clippy/master/index.html#unit_arg [`unit_cmp`]: https://rust-lang.github.io/rust-clippy/master/index.html#unit_cmp [`unit_hash`]: https://rust-lang.github.io/rust-clippy/master/index.html#unit_hash -[`unit_like_struct_brackets`]: https://rust-lang.github.io/rust-clippy/master/index.html#unit_like_struct_brackets [`unit_return_expecting_ord`]: https://rust-lang.github.io/rust-clippy/master/index.html#unit_return_expecting_ord [`unnecessary_cast`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast [`unnecessary_filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_filter_map diff --git a/clippy_lints/src/unit_like_struct_brackets.rs b/clippy_lints/src/empty_structs_with_brackets.rs similarity index 92% rename from clippy_lints/src/unit_like_struct_brackets.rs rename to clippy_lints/src/empty_structs_with_brackets.rs index 6269719e696c..e3f33c1a4a30 100644 --- a/clippy_lints/src/unit_like_struct_brackets.rs +++ b/clippy_lints/src/empty_structs_with_brackets.rs @@ -22,13 +22,13 @@ declare_clippy_lint! { /// struct Cookie; /// ``` #[clippy::version = "1.62.0"] - pub UNIT_LIKE_STRUCT_BRACKETS, + pub EMPTY_STRUCTS_WITH_BRACKETS, style, "finds struct declarations with empty brackets" } -declare_lint_pass!(UnitLikeStructBrackets => [UNIT_LIKE_STRUCT_BRACKETS]); +declare_lint_pass!(EmptyStructsWithBrackets => [EMPTY_STRUCTS_WITH_BRACKETS]); -impl EarlyLintPass for UnitLikeStructBrackets { +impl EarlyLintPass for EmptyStructsWithBrackets { fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) { let span_after_ident = item.span.with_lo(item.ident.span.hi()); @@ -37,7 +37,7 @@ impl EarlyLintPass for UnitLikeStructBrackets { && has_no_fields(cx, var_data, span_after_ident) { span_lint_and_then( cx, - UNIT_LIKE_STRUCT_BRACKETS, + EMPTY_STRUCTS_WITH_BRACKETS, span_after_ident, "found empty brackets on struct declaration", |diagnostic| { diff --git a/clippy_lints/src/lib.register_all.rs b/clippy_lints/src/lib.register_all.rs index 523e21f92dfa..953a1fa61ecf 100644 --- a/clippy_lints/src/lib.register_all.rs +++ b/clippy_lints/src/lib.register_all.rs @@ -53,6 +53,7 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![ LintId::of(drop_forget_ref::FORGET_COPY), LintId::of(drop_forget_ref::FORGET_REF), LintId::of(duration_subsec::DURATION_SUBSEC), + LintId::of(empty_structs_with_brackets::EMPTY_STRUCTS_WITH_BRACKETS), LintId::of(entry::MAP_ENTRY), LintId::of(enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT), LintId::of(enum_variants::ENUM_VARIANT_NAMES), @@ -300,7 +301,6 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![ LintId::of(unicode::INVISIBLE_CHARACTERS), LintId::of(uninit_vec::UNINIT_VEC), LintId::of(unit_hash::UNIT_HASH), - LintId::of(unit_like_struct_brackets::UNIT_LIKE_STRUCT_BRACKETS), LintId::of(unit_return_expecting_ord::UNIT_RETURN_EXPECTING_ORD), LintId::of(unit_types::UNIT_ARG), LintId::of(unit_types::UNIT_CMP), diff --git a/clippy_lints/src/lib.register_lints.rs b/clippy_lints/src/lib.register_lints.rs index 6f1807b479d5..dd5153ba4df0 100644 --- a/clippy_lints/src/lib.register_lints.rs +++ b/clippy_lints/src/lib.register_lints.rs @@ -128,6 +128,7 @@ store.register_lints(&[ duration_subsec::DURATION_SUBSEC, else_if_without_else::ELSE_IF_WITHOUT_ELSE, empty_enum::EMPTY_ENUM, + empty_structs_with_brackets::EMPTY_STRUCTS_WITH_BRACKETS, entry::MAP_ENTRY, enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT, enum_variants::ENUM_VARIANT_NAMES, @@ -511,7 +512,6 @@ store.register_lints(&[ unicode::UNICODE_NOT_NFC, uninit_vec::UNINIT_VEC, unit_hash::UNIT_HASH, - unit_like_struct_brackets::UNIT_LIKE_STRUCT_BRACKETS, unit_return_expecting_ord::UNIT_RETURN_EXPECTING_ORD, unit_types::LET_UNIT_VALUE, unit_types::UNIT_ARG, diff --git a/clippy_lints/src/lib.register_style.rs b/clippy_lints/src/lib.register_style.rs index 89657cfb7842..b2465d1a0cd9 100644 --- a/clippy_lints/src/lib.register_style.rs +++ b/clippy_lints/src/lib.register_style.rs @@ -20,6 +20,7 @@ store.register_group(true, "clippy::style", Some("clippy_style"), vec![ LintId::of(disallowed_types::DISALLOWED_TYPES), LintId::of(doc::MISSING_SAFETY_DOC), LintId::of(doc::NEEDLESS_DOCTEST_MAIN), + LintId::of(empty_structs_with_brackets::EMPTY_STRUCTS_WITH_BRACKETS), LintId::of(enum_variants::ENUM_VARIANT_NAMES), LintId::of(enum_variants::MODULE_INCEPTION), LintId::of(eq_op::OP_REF), @@ -105,7 +106,6 @@ store.register_group(true, "clippy::style", Some("clippy_style"), vec![ LintId::of(single_component_path_imports::SINGLE_COMPONENT_PATH_IMPORTS), LintId::of(tabs_in_doc_comments::TABS_IN_DOC_COMMENTS), LintId::of(to_digit_is_some::TO_DIGIT_IS_SOME), - LintId::of(unit_like_struct_brackets::UNIT_LIKE_STRUCT_BRACKETS), LintId::of(unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME), LintId::of(unused_unit::UNUSED_UNIT), LintId::of(upper_case_acronyms::UPPER_CASE_ACRONYMS), diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 328b68d54d49..45b7e3d18895 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -208,6 +208,7 @@ mod drop_forget_ref; mod duration_subsec; mod else_if_without_else; mod empty_enum; +mod empty_structs_with_brackets; mod entry; mod enum_clike; mod enum_variants; @@ -379,7 +380,6 @@ mod undropped_manually_drops; mod unicode; mod uninit_vec; mod unit_hash; -mod unit_like_struct_brackets; mod unit_return_expecting_ord; mod unit_types; mod unnamed_address; @@ -868,7 +868,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: ignore_publish: cargo_ignore_publish, }) }); - store.register_early_pass(|| Box::new(unit_like_struct_brackets::UnitLikeStructBrackets)); + store.register_early_pass(|| Box::new(empty_structs_with_brackets::EmptyStructsWithBrackets)); // add lints here, do not remove this comment, it's used in `new_lint` } diff --git a/tests/ui/unit_like_struct_brackets.fixed b/tests/ui/empty_structs_with_brackets.fixed similarity index 92% rename from tests/ui/unit_like_struct_brackets.fixed rename to tests/ui/empty_structs_with_brackets.fixed index 2769920c5fe9..80f07603b8d4 100644 --- a/tests/ui/unit_like_struct_brackets.fixed +++ b/tests/ui/empty_structs_with_brackets.fixed @@ -1,5 +1,5 @@ // run-rustfix -#![warn(clippy::unit_like_struct_brackets)] +#![warn(clippy::empty_structs_with_brackets)] #![allow(dead_code)] pub struct MyEmptyStruct; // should trigger lint diff --git a/tests/ui/unit_like_struct_brackets.rs b/tests/ui/empty_structs_with_brackets.rs similarity index 92% rename from tests/ui/unit_like_struct_brackets.rs rename to tests/ui/empty_structs_with_brackets.rs index b20f8516bd11..1d1ed4c76902 100644 --- a/tests/ui/unit_like_struct_brackets.rs +++ b/tests/ui/empty_structs_with_brackets.rs @@ -1,5 +1,5 @@ // run-rustfix -#![warn(clippy::unit_like_struct_brackets)] +#![warn(clippy::empty_structs_with_brackets)] #![allow(dead_code)] pub struct MyEmptyStruct {} // should trigger lint diff --git a/tests/ui/unit_like_struct_brackets.stderr b/tests/ui/empty_structs_with_brackets.stderr similarity index 70% rename from tests/ui/unit_like_struct_brackets.stderr rename to tests/ui/empty_structs_with_brackets.stderr index d3037f5d350a..0308cb5571af 100644 --- a/tests/ui/unit_like_struct_brackets.stderr +++ b/tests/ui/empty_structs_with_brackets.stderr @@ -1,14 +1,14 @@ error: found empty brackets on struct declaration - --> $DIR/unit_like_struct_brackets.rs:5:25 + --> $DIR/empty_structs_with_brackets.rs:5:25 | LL | pub struct MyEmptyStruct {} // should trigger lint | ^^^ | - = note: `-D clippy::unit-like-struct-brackets` implied by `-D warnings` + = note: `-D clippy::empty-structs-with-brackets` implied by `-D warnings` = help: remove the brackets error: found empty brackets on struct declaration - --> $DIR/unit_like_struct_brackets.rs:6:26 + --> $DIR/empty_structs_with_brackets.rs:6:26 | LL | struct MyEmptyTupleStruct(); // should trigger lint | ^^^ diff --git a/tests/ui/no_effect.rs b/tests/ui/no_effect.rs index 291dab4fb314..0847297ade79 100644 --- a/tests/ui/no_effect.rs +++ b/tests/ui/no_effect.rs @@ -68,7 +68,7 @@ impl FnOnce<(&str,)> for GreetStruct1 { } } -#[allow(clippy::unit_like_struct_brackets)] +#[allow(clippy::empty_structs_with_brackets)] struct GreetStruct2(); impl FnOnce<(&str,)> for GreetStruct2 {