Check if never type feature is enabled by TyCtxt before suggesting empty enum lint

This commit is contained in:
nahuakang
2020-12-28 18:59:35 +01:00
parent 61a3ee7935
commit 469281c0dd

View File

@@ -44,7 +44,9 @@ impl<'tcx> LateLintPass<'tcx> for EmptyEnum {
if let ItemKind::Enum(..) = item.kind { if let ItemKind::Enum(..) = item.kind {
let ty = cx.tcx.type_of(did); let ty = cx.tcx.type_of(did);
let adt = ty.ty_adt_def().expect("already checked whether this is an enum"); 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( span_lint_and_help(
cx, cx,
EMPTY_ENUM, EMPTY_ENUM,