Skip to content

Commit 70de06f

Browse files
committed
clean-up a bit
1 parent 1ecb18a commit 70de06f

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

clippy_lints/src/empty_enum.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,10 @@ declare_lint_pass!(EmptyEnum => [EMPTY_ENUM]);
6262

6363
impl LateLintPass<'_> for EmptyEnum {
6464
fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) {
65-
if let ItemKind::Enum(..) = item.kind
65+
if let ItemKind::Enum(.., def) = item.kind
66+
&& def.variants.is_empty()
6667
// Only suggest the `never_type` if the feature is enabled
6768
&& cx.tcx.features().never_type()
68-
&& let Some(adt) = cx.tcx.type_of(item.owner_id).instantiate_identity().ty_adt_def()
69-
&& adt.variants().is_empty()
7069
{
7170
span_lint_and_help(
7271
cx,

tests/ui/empty_enum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#![allow(dead_code)]
21
#![warn(clippy::empty_enum)]
32
// Enable never type to test empty enum lint
43
#![feature(never_type)]
4+
55
enum Empty {}
66
//~^ empty_enum
77

tests/ui/empty_enum_without_never_type.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//@ check-pass
22

3-
#![allow(dead_code)]
43
#![warn(clippy::empty_enum)]
54

65
// `never_type` is not enabled; this test has no stderr file

0 commit comments

Comments
 (0)