Skip to content

Commit

Permalink
unit_like_struct_brackets -> empty_structs_with_brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
FoseFx committed Mar 28, 2022
1 parent a3ed806 commit 18864d4
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Expand Up @@ -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());

Expand All @@ -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| {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/lib.register_all.rs
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/lib.register_lints.rs
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/lib.register_style.rs
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/lib.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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`
}

Expand Down
@@ -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
Expand Down
@@ -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
Expand Down
@@ -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
| ^^^
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/no_effect.rs
Expand Up @@ -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 {
Expand Down

0 comments on commit 18864d4

Please sign in to comment.