Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6253,6 +6253,7 @@ Released 2018-09-13
[`empty_drop`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_drop
[`empty_enum`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_enum
[`empty_enum_variants_with_brackets`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_enum_variants_with_brackets
[`empty_enums`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_enums
[`empty_line_after_doc_comments`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_doc_comments
[`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
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/declared_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ pub static LINTS: &[&::declare_clippy_lint::LintInfo] = &[
crate::duplicate_mod::DUPLICATE_MOD_INFO,
crate::else_if_without_else::ELSE_IF_WITHOUT_ELSE_INFO,
crate::empty_drop::EMPTY_DROP_INFO,
crate::empty_enum::EMPTY_ENUM_INFO,
crate::empty_enums::EMPTY_ENUMS_INFO,
crate::empty_line_after::EMPTY_LINE_AFTER_DOC_COMMENTS_INFO,
crate::empty_line_after::EMPTY_LINE_AFTER_OUTER_ATTR_INFO,
crate::empty_with_brackets::EMPTY_ENUM_VARIANTS_WITH_BRACKETS_INFO,
Expand Down
2 changes: 2 additions & 0 deletions clippy_lints/src/deprecated_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ declare_with_version! { RENAMED(RENAMED_VERSION) = [
("clippy::drop_copy", "dropping_copy_types"),
#[clippy::version = ""]
("clippy::drop_ref", "dropping_references"),
#[clippy::version = "1.92.0"]
("clippy::empty_enum", "clippy::empty_enums"),
#[clippy::version = ""]
("clippy::eval_order_dependence", "clippy::mixed_read_write_in_expression"),
#[clippy::version = "1.53.0"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ declare_clippy_lint! {
/// [newtype]: https://doc.rust-lang.org/book/ch19-04-advanced-types.html#using-the-newtype-pattern-for-type-safety-and-abstraction
/// [visibility]: https://doc.rust-lang.org/reference/visibility-and-privacy.html
#[clippy::version = "pre 1.29.0"]
pub EMPTY_ENUM,
pub EMPTY_ENUMS,
pedantic,
"enum with no variants"
}

declare_lint_pass!(EmptyEnum => [EMPTY_ENUM]);
declare_lint_pass!(EmptyEnums => [EMPTY_ENUMS]);

impl LateLintPass<'_> for EmptyEnum {
impl LateLintPass<'_> for EmptyEnums {
fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) {
if let ItemKind::Enum(.., def) = item.kind
&& def.variants.is_empty()
Expand All @@ -67,7 +67,7 @@ impl LateLintPass<'_> for EmptyEnum {
{
span_lint_and_help(
cx,
EMPTY_ENUM,
EMPTY_ENUMS,
item.span,
"enum with no variants",
None,
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ mod drop_forget_ref;
mod duplicate_mod;
mod else_if_without_else;
mod empty_drop;
mod empty_enum;
mod empty_enums;
mod empty_line_after;
mod empty_with_brackets;
mod endian_bytes;
Expand Down Expand Up @@ -541,7 +541,7 @@ pub fn register_lint_passes(store: &mut rustc_lint::LintStore, conf: &'static Co
store.register_late_pass(|_| Box::new(derive::Derive));
store.register_late_pass(move |_| Box::new(derivable_impls::DerivableImpls::new(conf)));
store.register_late_pass(|_| Box::new(drop_forget_ref::DropForgetRef));
store.register_late_pass(|_| Box::new(empty_enum::EmptyEnum));
store.register_late_pass(|_| Box::new(empty_enums::EmptyEnums));
store.register_late_pass(|_| Box::new(invalid_upcast_comparisons::InvalidUpcastComparisons));
store.register_late_pass(|_| Box::<regex::Regex>::default());
store.register_late_pass(move |tcx| Box::new(ifs::CopyAndPaste::new(tcx, conf)));
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/empty_enum.rs → tests/ui/empty_enums.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![warn(clippy::empty_enum)]
#![warn(clippy::empty_enums)]
// Enable never type to test empty enum lint
#![feature(never_type)]

enum Empty {}
//~^ empty_enum
//~^ empty_enums

mod issue15910 {
enum NotReallyEmpty {
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/empty_enum.stderr → tests/ui/empty_enums.stderr
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
error: enum with no variants
--> tests/ui/empty_enum.rs:5:1
--> tests/ui/empty_enums.rs:5:1
|
LL | enum Empty {}
| ^^^^^^^^^^^^^
|
= help: consider using the uninhabited type `!` (never type) or a wrapper around it to introduce a type which can't be instantiated
= note: `-D clippy::empty-enum` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::empty_enum)]`
= note: `-D clippy::empty-enums` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::empty_enums)]`

error: aborting due to 1 previous error

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@ check-pass

#![warn(clippy::empty_enum)]
#![warn(clippy::empty_enums)]

// `never_type` is not enabled; this test has no stderr file
enum Empty {}
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/rename.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#![allow(drop_bounds)]
#![allow(dropping_copy_types)]
#![allow(dropping_references)]
#![allow(clippy::empty_enums)]
#![allow(clippy::mixed_read_write_in_expression)]
#![allow(clippy::manual_filter_map)]
#![allow(clippy::manual_find_map)]
Expand Down Expand Up @@ -83,6 +84,7 @@
#![warn(drop_bounds)] //~ ERROR: lint `clippy::drop_bounds`
#![warn(dropping_copy_types)] //~ ERROR: lint `clippy::drop_copy`
#![warn(dropping_references)] //~ ERROR: lint `clippy::drop_ref`
#![warn(clippy::empty_enums)] //~ ERROR: lint `clippy::empty_enum`
#![warn(clippy::mixed_read_write_in_expression)] //~ ERROR: lint `clippy::eval_order_dependence`
#![warn(clippy::manual_filter_map)] //~ ERROR: lint `clippy::filter_map`
#![warn(clippy::manual_find_map)] //~ ERROR: lint `clippy::find_map`
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#![allow(drop_bounds)]
#![allow(dropping_copy_types)]
#![allow(dropping_references)]
#![allow(clippy::empty_enums)]
#![allow(clippy::mixed_read_write_in_expression)]
#![allow(clippy::manual_filter_map)]
#![allow(clippy::manual_find_map)]
Expand Down Expand Up @@ -83,6 +84,7 @@
#![warn(clippy::drop_bounds)] //~ ERROR: lint `clippy::drop_bounds`
#![warn(clippy::drop_copy)] //~ ERROR: lint `clippy::drop_copy`
#![warn(clippy::drop_ref)] //~ ERROR: lint `clippy::drop_ref`
#![warn(clippy::empty_enum)] //~ ERROR: lint `clippy::empty_enum`
#![warn(clippy::eval_order_dependence)] //~ ERROR: lint `clippy::eval_order_dependence`
#![warn(clippy::filter_map)] //~ ERROR: lint `clippy::filter_map`
#![warn(clippy::find_map)] //~ ERROR: lint `clippy::find_map`
Expand Down
Loading