1 #![deny(clippy::option_option)]
3 fn input(_: Option<Option<u8>>) {}
5 fn output() -> Option<Option<u8>> {
9 fn output_nested() -> Vec<Option<Option<u8>>> {
13 // The lint only generates one warning for this
14 fn output_nested_nested() -> Option<Option<Option<u8>>> {
19 x: Option<Option<u8>>,
23 fn struct_fn() -> Option<Option<u8>> {
29 fn trait_fn() -> Option<Option<u8>>;
33 Tuple(Option<Option<u8>>),
34 Struct { x: Option<Option<u8>> },
37 // The lint allows this
38 type OptionOption = Option<Option<u32>>;
40 // The lint allows this
41 fn output_type_alias() -> OptionOption {
45 // The line allows this
46 impl Trait for Struct {
47 fn trait_fn() -> Option<Option<u8>> {
57 // The lint allows this
58 let local: Option<Option<u8>> = None;
60 // The lint allows this
61 let expr = Some(Some(true));
66 use serde::{Deserialize, Deserializer, Serialize};
69 #[derive(Serialize, Deserialize)]
71 #[serde(deserialize_with = "func")]
72 #[serde(skip_serializing_if = "Option::is_none")]
75 // FIXME: should not lint here
76 #[allow(clippy::option_option)]
77 foo: Option<Option<Cow<'a, str>>>,
80 #[allow(clippy::option_option)]
81 fn func<'a, D>(_: D) -> Result<Option<Option<Cow<'a, str>>>, D::Error>
85 Ok(Some(Some(Cow::Borrowed("hi"))))