Skip to content

Splitting unnecessary_map_or into 2 lints #15999

@teofr

Description

@teofr

Description

unnecessary_map_or is a bit of a complicated lint, #14713 suggested distilling part of its behaviour into a separate lint. That issue together with #15998 would split the behaviour entirely in two:

  • For inequalities, it would lint the same cases x.map_or(true, |n| n > 5) but under a different name
  • For equalities, x.map_or(false, |n| n == 5) it would first lint through manual_is_variant_and into x.is_some_and(|n| n == 5) and then through the lint in suggest == Some( for is_some_and if possible #14713 it would lint into x == Some(5)

After these things are done, I'd consider deprecating the lint all together.

Version

rustc 1.92.0-nightly (57ef8d642 2025-10-15)
binary: rustc
commit-hash: 57ef8d642d21965304bde849bab4f389b4353e27
commit-date: 2025-10-15
host: aarch64-apple-darwin
release: 1.92.0-nightly
LLVM version: 21.1.3

Additional Labels

No response

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