clean-up a bit
This commit is contained in:
parent
1ecb18a182
commit
70de06f70f
3 changed files with 3 additions and 5 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
//@ check-pass
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![warn(clippy::empty_enum)]
|
||||
|
||||
// `never_type` is not enabled; this test has no stderr file
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue