@@ -8,16 +8,29 @@ 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- /// **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+ ///
1418 ///
1519 /// **Known problems:** None.
1620 ///
1721 /// **Example:**
22+ ///
23+ /// Bad:
1824 /// ```rust
1925 /// enum Test {}
2026 /// ```
27+ ///
28+ /// Good:
29+ /// ```rust
30+ /// #![feature(never_type)]
31+ ///
32+ /// struct Test(!);
33+ /// ```
2134 pub EMPTY_ENUM ,
2235 pedantic,
2336 "enum with no variants"
@@ -35,7 +48,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EmptyEnum {
3548 span_lint_and_then ( cx, EMPTY_ENUM , item. span , "enum with no variants" , |db| {
3649 db. span_help (
3750 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",
3953 ) ;
4054 } ) ;
4155 }
0 commit comments