Skip to content

overhaul unnecessary_map_or#16383

Closed
ada4a wants to merge 5 commits intorust-lang:masterfrom
ada4a:unnecessary_map_or
Closed

overhaul unnecessary_map_or#16383
ada4a wants to merge 5 commits intorust-lang:masterfrom
ada4a:unnecessary_map_or

Conversation

@ada4a
Copy link
Copy Markdown
Contributor

@ada4a ada4a commented Jan 11, 2026

Third commit moves .map_or(false, -> .is_some_and( and similar transformations to manual_is_variant_and

Fourth and fifth commits add a new lint, needless_is_variant_and, which transforms .is_some_and(|n| n == 5) into == Some(5)

For further reasoning, please see the documentation on manual_eq_optional.rs.

Diffs best viewed with whitespace ignored and --color-moved

cc @teofr

changelog: [unnecessary_map_or]: move .map_or(false, -> .is_some_and( and similar transformations to manual_is_variant_and
changelog: [needless_is_variant_and]: new lint

ada4a added 3 commits January 11, 2026 18:27
- manual_is_variant_and: create `Flavor` using a function
  - removes one level of `for`
@rustbot rustbot added needs-fcp PRs that add, remove, or rename lints and need an FCP S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Jan 11, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jan 11, 2026

r? @samueltardieu

rustbot has assigned @samueltardieu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 11, 2026

Lintcheck changes for 24e45b7

Lint Added Removed Changed
clippy::manual_is_variant_and 22 0 1
clippy::unnecessary_map_or 0 22 1

This comment will be updated if you push new changes

@ada4a ada4a force-pushed the unnecessary_map_or branch 2 times, most recently from aeb1902 to 9780bdb Compare January 11, 2026 18:14
ada4a added 2 commits January 11, 2026 19:16
to make sure that each commit builds in isolation
NOTE: the changes to `map_unwrap_or_fixable` can't be moved to the
dogfood commit, as at that point `needless_is_variant_and` is still an
unknown lint
@ada4a ada4a force-pushed the unnecessary_map_or branch from 9780bdb to 24e45b7 Compare January 11, 2026 18:23
@samueltardieu
Copy link
Copy Markdown
Member

Those commits (except the dogfood one of course) should be separate PRs that can be judged on their own merit, especially if checks are moved from one lint to another and if a new lint is introduced.

Just make PR 3 depend on PR 1 and 2, and PR 4 (commits 4 and 5) depend on PR 3 if required, or PR 1 and 2 otherwise.

@ada4a
Copy link
Copy Markdown
Contributor Author

ada4a commented Jan 11, 2026

Yeah fair enough.. Though I'm not sure the first commit really deserves to be its own PR? It's just a bunch of clean-up..

@samueltardieu
Copy link
Copy Markdown
Member

It's just a bunch of clean-up..

…which have to be reviewed anyhow. The second commit can get approved much faster IMO in isolation.

@ada4a
Copy link
Copy Markdown
Contributor Author

ada4a commented Jan 12, 2026

Opened the sub-PRs, see the mentions above this comment

@ada4a ada4a closed this Jan 12, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jan 12, 2026
github-merge-queue Bot pushed a commit that referenced this pull request Jan 12, 2026
This is the first commit of
#16383

changelog: none
@ada4a ada4a deleted the unnecessary_map_or branch January 13, 2026 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-fcp PRs that add, remove, or rename lints and need an FCP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Splitting unnecessary_map_or into 2 lints Add x.map_or(true, |n| n > 5) to manual_is_variant_and suggest == Some( for is_some_and if possible

3 participants