1 #![deny(clippy::option_option)]
2 #![allow(clippy::unnecessary_wraps)]
4 const C: Option<Option<i32>> = None;
5 static S: Option<Option<i32>> = None;
7 fn input(_: Option<Option<u8>>) {}
9 fn output() -> Option<Option<u8>> {
13 fn output_nested() -> Vec<Option<Option<u8>>> {
17 // The lint only generates one warning for this
18 fn output_nested_nested() -> Option<Option<Option<u8>>> {
23 x: Option<Option<u8>>,
27 fn struct_fn() -> Option<Option<u8>> {
33 fn trait_fn() -> Option<Option<u8>>;
37 Tuple(Option<Option<u8>>),
38 Struct { x: Option<Option<u8>> },
41 // The lint allows this
42 type OptionOption = Option<Option<u32>>;
44 // The lint allows this
45 fn output_type_alias() -> OptionOption {
49 // The line allows this
50 impl Trait for Struct {
51 fn trait_fn() -> Option<Option<u8>> {
61 // The lint allows this
62 let local: Option<Option<u8>> = None;
64 // The lint allows this
65 let expr = Some(Some(true));
70 use serde::{Deserialize, Deserializer, Serialize};
73 #[derive(Serialize, Deserialize)]
75 #[serde(deserialize_with = "func")]
76 #[serde(skip_serializing_if = "Option::is_none")]
79 foo: Option<Option<Cow<'a, str>>>,
82 #[allow(clippy::option_option)]
83 fn func<'a, D>(_: D) -> Result<Option<Option<Cow<'a, str>>>, D::Error>
87 Ok(Some(Some(Cow::Borrowed("hi"))))