unit_like_struct_brackets -> empty_structs_with_brackets
This commit is contained in:
parent
37d5a6264c
commit
2953cba116
@ -3263,6 +3263,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
|
||||
@ -3636,7 +3637,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
|
||||
|
@ -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| {
|
@ -54,6 +54,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),
|
||||
@ -301,7 +302,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),
|
||||
|
@ -129,6 +129,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,
|
||||
@ -512,7 +513,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,
|
||||
|
@ -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),
|
||||
|
@ -209,6 +209,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;
|
||||
@ -380,7 +381,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;
|
||||
@ -870,7 +870,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
|
||||
})
|
||||
});
|
||||
store.register_early_pass(|| Box::new(crate_in_macro_def::CrateInMacroDef));
|
||||
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`
|
||||
}
|
||||
|
||||
|
@ -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
|
@ -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
|
@ -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
|
||||
| ^^^
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user