Skip to content

False positive for unnecessary_filter_map #4433

@emabee

Description

@emabee

cargo clippy -V
clippy 0.0.212 (e3cb40e 2019-06-25)

A warning is produced from

#[warn(clippy::unnecessary_filter_map)]
let errors: Vec<ServerError> = server_errors
    .into_iter()
    .filter_map(|se| match se.severity() {
        Severity::Warning => {
            self.warnings.push(se);
            None
        }
        _ => Some(se),
    })
    .collect();

The code splits moves some items from one collection into a second. If I'd use filter, as recommended, then I would have to clone the ses, and discard the original instances.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingE-hardCall for participation: This a hard problem and requires more experience or effort to work onI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions