diff options
| author | nahuakang <kangnahua@gmail.com> | 2020-12-28 18:59:35 +0100 |
|---|---|---|
| committer | nahuakang <kangnahua@gmail.com> | 2020-12-28 18:59:35 +0100 |
| commit | 469281c0dd6abb13b0b0067e0ed977e70145183c (patch) | |
| tree | c26cfb88e7c5251cc99b6ae21bed266742c5aca0 | |
| parent | 61a3ee79350daf2eb9669999839c05de7a473316 (diff) | |
| download | rust-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.rs | 4 |
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, |
