Skip to content
Open
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 @@ -6251,6 +6251,7 @@ Released 2018-09-13
[`else_if_without_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#else_if_without_else
[`empty_docs`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_docs
[`empty_drop`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_drop
[`empty_drops`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_drops
[`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
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 @@ -134,7 +134,7 @@ pub static LINTS: &[&::declare_clippy_lint::LintInfo] = &[
crate::drop_forget_ref::MEM_FORGET_INFO,
crate::duplicate_mod::DUPLICATE_MOD_INFO,
crate::else_if_without_else::ELSE_IF_WITHOUT_ELSE_INFO,
crate::empty_drop::EMPTY_DROP_INFO,
crate::empty_drops::EMPTY_DROPS_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,
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 @@ -86,6 +86,8 @@ declare_with_version! { RENAMED(RENAMED_VERSION) = [
#[clippy::version = ""]
("clippy::drop_ref", "dropping_references"),
#[clippy::version = "1.92.0"]
("clippy::empty_drop", "clippy::empty_drops"),
#[clippy::version = "1.92.0"]
("clippy::empty_enum", "clippy::empty_enums"),
#[clippy::version = ""]
("clippy::eval_order_dependence", "clippy::mixed_read_write_in_expression"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ declare_clippy_lint! {
/// struct S;
/// ```
#[clippy::version = "1.62.0"]
pub EMPTY_DROP,
pub EMPTY_DROPS,
restriction,
"empty `Drop` implementations"
}
declare_lint_pass!(EmptyDrop => [EMPTY_DROP]);
declare_lint_pass!(EmptyDrops => [EMPTY_DROPS]);

impl LateLintPass<'_> for EmptyDrop {
impl LateLintPass<'_> for EmptyDrops {
fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) {
if let ItemKind::Impl(Impl {
of_trait: Some(of_trait),
Expand All @@ -50,7 +50,7 @@ impl LateLintPass<'_> for EmptyDrop {
&& block.stmts.is_empty()
&& block.expr.is_none()
{
span_lint_and_then(cx, EMPTY_DROP, item.span, "empty drop implementation", |diag| {
span_lint_and_then(cx, EMPTY_DROPS, item.span, "empty drop implementation", |diag| {
diag.span_suggestion_hidden(
item.span,
"try removing this impl",
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 @@ -116,7 +116,7 @@ mod double_parens;
mod drop_forget_ref;
mod duplicate_mod;
mod else_if_without_else;
mod empty_drop;
mod empty_drops;
mod empty_enums;
mod empty_line_after;
mod empty_with_brackets;
Expand Down Expand Up @@ -655,7 +655,7 @@ pub fn register_lint_passes(store: &mut rustc_lint::LintStore, conf: &'static Co
store.register_late_pass(move |tcx| Box::new(disallowed_methods::DisallowedMethods::new(tcx, conf)));
store.register_early_pass(|| Box::new(asm_syntax::InlineAsmX86AttSyntax));
store.register_early_pass(|| Box::new(asm_syntax::InlineAsmX86IntelSyntax));
store.register_late_pass(|_| Box::new(empty_drop::EmptyDrop));
store.register_late_pass(|_| Box::new(empty_drops::EmptyDrops));
store.register_late_pass(|_| Box::new(strings::StrToString));
store.register_late_pass(|_| Box::new(zero_sized_map_values::ZeroSizedMapValues));
store.register_late_pass(|_| Box::<vec_init_then_push::VecInitThenPush>::default());
Expand Down
3 changes: 1 addition & 2 deletions tests/ui/empty_drop.fixed → tests/ui/empty_drops.fixed
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![warn(clippy::empty_drop)]
#![allow(unused)]
#![warn(clippy::empty_drops)]

// should cause an error
struct Foo;
Expand Down
7 changes: 3 additions & 4 deletions tests/ui/empty_drop.rs → tests/ui/empty_drops.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#![warn(clippy::empty_drop)]
#![allow(unused)]
#![warn(clippy::empty_drops)]

// should cause an error
struct Foo;

impl Drop for Foo {
//~^ empty_drop
//~^ empty_drops
fn drop(&mut self) {}
}

Expand All @@ -22,7 +21,7 @@ impl Drop for Bar {
struct Baz;

impl Drop for Baz {
//~^ empty_drop
//~^ empty_drops
fn drop(&mut self) {
{}
}
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/empty_drop.stderr → tests/ui/empty_drops.stderr
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
error: empty drop implementation
--> tests/ui/empty_drop.rs:7:1
--> tests/ui/empty_drops.rs:6:1
|
LL | / impl Drop for Foo {
LL | |
LL | | fn drop(&mut self) {}
LL | | }
| |_^
|
= note: `-D clippy::empty-drop` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::empty_drop)]`
= note: `-D clippy::empty-drops` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::empty_drops)]`
= help: try removing this impl

error: empty drop implementation
--> tests/ui/empty_drop.rs:24:1
--> tests/ui/empty_drops.rs:23:1
|
LL | / impl Drop for Baz {
LL | |
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_drops)]
#![allow(clippy::empty_enums)]
#![allow(clippy::mixed_read_write_in_expression)]
#![allow(clippy::manual_filter_map)]
Expand Down Expand Up @@ -85,6 +86,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_drops)] //~ ERROR: lint `clippy::empty_drop`
#![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`
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_drops)]
#![allow(clippy::empty_enums)]
#![allow(clippy::mixed_read_write_in_expression)]
#![allow(clippy::manual_filter_map)]
Expand Down Expand Up @@ -85,6 +86,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_drop)] //~ ERROR: lint `clippy::empty_drop`
#![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`
Expand Down
Loading