about summary refs log tree commit diff
diff options
context:
space:
mode:
authornahuakang <kangnahua@gmail.com>2020-12-28 18:59:35 +0100
committernahuakang <kangnahua@gmail.com>2020-12-28 18:59:35 +0100
commit469281c0dd6abb13b0b0067e0ed977e70145183c (patch)
treec26cfb88e7c5251cc99b6ae21bed266742c5aca0
parent61a3ee79350daf2eb9669999839c05de7a473316 (diff)
downloadrust-469281c0dd6abb13b0b0067e0ed977e70145183c.tar.gz
rust-469281c0dd6abb13b0b0067e0ed977e70145183c.zip
Check if never type feature is enabled by TyCtxt before suggesting empty enum lint
-rw-r--r--clippy_lints/src/empty_enum.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/clippy_lints/src/empty_enum.rs b/clippy_lints/src/empty_enum.rs
index a249117d182..585709660a4 100644
--- a/clippy_lints/src/empty_enum.rs
+++ b/clippy_lints/src/empty_enum.rs
@@ -44,7 +44,9 @@ impl<'tcx> LateLintPass<'tcx> for EmptyEnum {
         if let ItemKind::Enum(..) = item.kind {
             let ty = cx.tcx.type_of(did);
             let adt = ty.ty_adt_def().expect("already checked whether this is an enum");
-            if adt.variants.is_empty() {
+
+            // Only suggest the never type if the feature is enabled
+            if adt.variants.is_empty() && cx.tcx.features().never_type {
                 span_lint_and_help(
                     cx,
                     EMPTY_ENUM,