Skip to content

false positive for unnecessary_fold #3069

@Wolvereness

Description

@Wolvereness

When using a boolean fold in a pattern guard (match { ... _ if values.iter().fold(false, |p, v| p || v.f()) =>), it suggests any.

This actually isn't applicable in this edge-case, as any requires a mutable-borrow on the iterator, which is completely unavailable in a pattern guard. fold happens to take the iterator by-value, which means it doesn't actually have any alternatives in a pattern guard.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions