Skip to content

.zip(None) is always None so it should be linted #17462

Description

@Veykril

What it does

A new lint that checks for calls of the form Option::zip with None as the right hand side. This always yields None and is never going to be correct as one could just write None. rust-lang/rust-analyzer#22924 is an example of a logic bug where the indent was to instead tuple the option with a None.

Advantage

No response

Drawbacks

No response

Example

foo.zip(None)

Could be written as:

None

if intended, or foo.map(|foo| (foo, None)) if the intent was completely different and thus a bug to be written that way.

Comparison with existing lints

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions