-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#[allow(clippy::option_option)] not working when paired with #[serde(deserialize_with)] #4298
Comments
Minimal reproducer: use serde::{Deserialize, Deserializer, Serialize}; // 1.0.94
use std::borrow::Cow;
#[derive(Serialize, Deserialize)]
struct Foo<'a> {
#[allow(clippy::option_option)]
#[serde(deserialize_with = "func")]
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
#[serde(borrow)]
foo: Option<Option<Cow<'a, str>>>,
}
#[allow(clippy::option_option)]
fn func<'a, D>(_: D) -> Result<Option<Option<Cow<'a, str>>>, D::Error>
where
D: Deserializer<'a>,
{
Ok(Some(Some(Cow::Borrowed("hi"))))
}
fn main() {} The warning messages are because of the expansion of |
Seems to be fixed, @flip1995 reproduction example does not trigger any lint. |
Yes, it looks like it fixed itself a while ago. Closing this one. |
The |
@montrivo, do you remember if the error was triggering only in CI or also locally? |
I don't remember anymore. |
Remove `allow` in `option_option` lint test As it is not triggering locally anymore, I propose to remove `#[allow(clippy::option_option)]` from the test. The goal is also to see what happens on CI. closes: #4298 changelog: none
Using: VS Code with RLS, Windows
This produces clippy warning on
option_option
:However, removing
#[serde(deserialize_with ... )]
makes it work:I suspect
#[serde(serialize_with ...)]
will also trip up this feature. So something aboutserde
'sserialize_with
anddeserialize_with
attributes conflict withoption_option
.The text was updated successfully, but these errors were encountered: