@@ -8,12 +8,12 @@ use rustc_session::{declare_lint_pass, declare_tool_lint};
88declare_clippy_lint ! {
99 /// **What it does:** Checks for `enum`s with no variants.
1010 ///
11- /// As of this writing, the never type is still a
11+ /// As of this writing, the `never_type` is still a
1212 /// nightly-only experimental API. Therefore, this lint is only triggered
13- /// if the never type is enabled
13+ /// if the `never_type` is enabled.
1414 ///
1515 /// **Why is this bad?** If you want to introduce a type which
16- /// can't be instantiated, you should use `!` (the never type),
16+ /// can't be instantiated, you should use `!` (the primitive type never ),
1717 /// or a wrapper around it, because `!` has more extensive
1818 /// compiler support (type inference, etc...) and wrappers
1919 /// around it are the conventional way to define an uninhabited type.
@@ -44,13 +44,16 @@ declare_lint_pass!(EmptyEnum => [EMPTY_ENUM]);
4444
4545impl < ' tcx > LateLintPass < ' tcx > for EmptyEnum {
4646 fn check_item ( & mut self , cx : & LateContext < ' _ > , item : & Item < ' _ > ) {
47+ // Only suggest the `never_type` if the feature is enabled
48+ if !cx. tcx . features ( ) . never_type {
49+ return ;
50+ }
51+
4752 let did = cx. tcx . hir ( ) . local_def_id ( item. hir_id ) ;
4853 if let ItemKind :: Enum ( ..) = item. kind {
4954 let ty = cx. tcx . type_of ( did) ;
5055 let adt = ty. ty_adt_def ( ) . expect ( "already checked whether this is an enum" ) ;
51-
52- // Only suggest the never type if the feature is enabled
53- if adt. variants . is_empty ( ) && cx. tcx . features ( ) . never_type {
56+ if adt. variants . is_empty ( ) {
5457 span_lint_and_help (
5558 cx,
5659 EMPTY_ENUM ,
0 commit comments