diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index b21c37392659..8c151f2277c1 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -99,14 +99,31 @@ declare_clippy_lint! { /// represents an optional optional value which is logically the same thing as an optional /// value but has an unneeded extra level of wrapping. /// + /// If you have a case where `Some(Some(_))`, `Some(None)` and `None` are distinct cases, + /// consider a custom `enum` instead, with clear names for each case. + /// /// **Known problems:** None. /// /// **Example** /// ```rust - /// fn x() -> Option> { + /// fn get_data() -> Option> { /// None /// } /// ``` + /// + /// Better: + /// + /// ```rust + /// pub enum Contents { + /// Data(Vec), // Was Some(Some(Vec)) + /// NotYetFetched, // Was Some(None) + /// None, // Was None + /// } + /// + /// fn get_data() -> Contents { + /// Contents::None + /// } + /// ``` pub OPTION_OPTION, pedantic, "usage of `Option>`"