clean-up a bit

This commit is contained in:
Ada Alakbarova 2025-10-20 00:06:51 +02:00
parent 1ecb18a182
commit 70de06f70f
No known key found for this signature in database
3 changed files with 3 additions and 5 deletions

View file

@ -62,11 +62,10 @@ declare_lint_pass!(EmptyEnum => [EMPTY_ENUM]);
impl LateLintPass<'_> for EmptyEnum {
fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) {
if let ItemKind::Enum(..) = item.kind
if let ItemKind::Enum(.., def) = item.kind
&& def.variants.is_empty()
// Only suggest the `never_type` if the feature is enabled
&& cx.tcx.features().never_type()
&& let Some(adt) = cx.tcx.type_of(item.owner_id).instantiate_identity().ty_adt_def()
&& adt.variants().is_empty()
{
span_lint_and_help(
cx,

View file

@ -1,7 +1,7 @@
#![allow(dead_code)]
#![warn(clippy::empty_enum)]
// Enable never type to test empty enum lint
#![feature(never_type)]
enum Empty {}
//~^ empty_enum

View file

@ -1,6 +1,5 @@
//@ check-pass
#![allow(dead_code)]
#![warn(clippy::empty_enum)]
// `never_type` is not enabled; this test has no stderr file