Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New lint: filter_map_identity #6643

Closed
camsteffen opened this issue Jan 26, 2021 · 2 comments · Fixed by #6685
Closed

New lint: filter_map_identity #6643

camsteffen opened this issue Jan 26, 2021 · 2 comments · Fixed by #6685
Assignees
Labels
A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy L-complexity Lint: Belongs in the complexity lint group T-middle Type: Probably requires verifiying types

Comments

@camsteffen
Copy link
Contributor

camsteffen commented Jan 26, 2021

What it does

It's the same as flat_map_identity, but with filter_map.

Example

vec![Some(1)].into_iter().filter_map(|x| x)

Could be written as:

vec![Some(1)].into_iter().flatten()
@camsteffen camsteffen added A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy L-complexity Lint: Belongs in the complexity lint group T-middle Type: Probably requires verifiying types labels Jan 26, 2021
@magurotuna
Copy link
Contributor

Hi! I'm interested in this so I'd like to give it a shot.

@magurotuna
Copy link
Contributor

@rustbot claim

magurotuna added a commit to magurotuna/rust-clippy that referenced this issue Feb 6, 2021
This commit adds a new lint named `filter_map_identity`. This lint is
the same as `flat_map_identity` except that it checks for `filter_map`.

Closes rust-lang#6643
bors added a commit that referenced this issue Feb 7, 2021
Add new lint `filter_map_identity`

<!--
Thank you for making Clippy better!

We're collecting our changelog from pull request descriptions.
If your PR only includes internal changes, you can just write
`changelog: none`. Otherwise, please write a short comment
explaining your change.

If your PR fixes an issue, you can add "fixes #issue_number" into this
PR description. This way the issue will be automatically closed when
your PR is merged.

If you added a new lint, here's a checklist for things that will be
checked during review or continuous integration.

- \[x] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[x] Executed `cargo dev update_lints`
- \[x] Added lint documentation
- \[x] Run `cargo dev fmt`

[lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints

Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.

Delete this line and everything above before opening your PR.
-->

This commit adds a new lint named filter_map_identity.
This lint is the same as `flat_map_identity` except that it checks for the usage of `filter_map`.

---

Closes #6643

changelog: Added a new lint: `filter_map_identity`
@bors bors closed this as completed in a60c143 Feb 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy L-complexity Lint: Belongs in the complexity lint group T-middle Type: Probably requires verifiying types
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants