Skip to content

#[allow(clippy::option_option)] not working when paired with #[serde(deserialize_with)] #4298

Closed
@schungx

Description

@schungx

Using: VS Code with RLS, Windows

This produces clippy warning on option_option:

    #[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>>>,
consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases.

However, removing #[serde(deserialize_with ... )] makes it work:

    #[allow(clippy::option_option)]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    #[serde(borrow)]
    foo: Option<Option<Cow<'a, str>>>,

I suspect #[serde(serialize_with ...)] will also trip up this feature. So something about serde's serialize_with and deserialize_with attributes conflict with option_option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: writing testsT-macrosType: Issues with macros and macro expansiongood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions