@@ -8,16 +8,29 @@ use rustc_session::{declare_lint_pass, declare_tool_lint};
8
8
declare_clippy_lint ! {
9
9
/// **What it does:** Checks for `enum`s with no variants.
10
10
///
11
- /// **Why is this bad?** Enum's with no variants should be replaced with `!`,
12
- /// the uninhabited type,
13
- /// or a wrapper around it.
11
+ /// **Why is this bad?** If you want to introduce a type which
12
+ /// can't be instantiated, you should use `!` (the never type),
13
+ /// or a wrapper around it, because `!` has more extensive
14
+ /// compiler support (type inference, etc...) and wrappers
15
+ /// around it are the conventional way to define an uninhabited type.
16
+ /// For further information visit [never type documentation](https://doc.rust-lang.org/std/primitive.never.html)
17
+ ///
14
18
///
15
19
/// **Known problems:** None.
16
20
///
17
21
/// **Example:**
22
+ ///
23
+ /// Bad:
18
24
/// ```rust
19
25
/// enum Test {}
20
26
/// ```
27
+ ///
28
+ /// Good:
29
+ /// ```rust
30
+ /// #![feature(never_type)]
31
+ ///
32
+ /// struct Test(!);
33
+ /// ```
21
34
pub EMPTY_ENUM ,
22
35
pedantic,
23
36
"enum with no variants"
@@ -35,7 +48,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EmptyEnum {
35
48
span_lint_and_then ( cx, EMPTY_ENUM , item. span , "enum with no variants" , |db| {
36
49
db. span_help (
37
50
item. span ,
38
- "consider using the uninhabited type `!` or a wrapper around it" ,
51
+ "consider using the uninhabited type `!` (never type) or a wrapper \
52
+ around it to introduce a type which can't be instantiated",
39
53
) ;
40
54
} ) ;
41
55
}
0 commit comments