Skip to content

Invalid suggestion for single_match #810

Closed
@Keats

Description

@Keats

It gives me the following:

src/lib.rs:112:17: 115:18 warning: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`, #[warn(single_match)] on by default
src/lib.rs:112                 match self.$field_name {
src/lib.rs:113                     Some(ref value) => { d.insert(stringify!($field_name).to_string(), value.to_json()); },
src/lib.rs:114                     None => {},
src/lib.rs:115                 }
src/lib.rs:118:9: 118:24 note: in this expansion of optional! (defined in src/lib.rs)
src/lib.rs:112:17: 115:18 help: try this
src/lib.rs:                    if let Some(ref value) = self.$field_name {
src/lib.rs:                        Some(ref value) => { d.insert(stringify!($field_name).to_string(), value.to_json()); },
src/lib.rs:                        None => {},
src/lib.rs:                    }
src/lib.rs:                )
src/lib.rs:            }

while the suggestion should be (afaik):

                if let Some(ref value) = self.$field_name {
                    d.insert(stringify!($field_name).to_string(), value.to_json());
                }

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions