rust-clippy icon indicating copy to clipboard operation
rust-clippy copied to clipboard

Add lint recommending using `std::iter::once` and `std::iter::empty`

Open sgued opened this issue 2 years ago • 8 comments

changelog: [`iter_once`]: add new lint
changelog: [`iter_empty`]: add new lint

fixes #9186

  • [ ] Followed lint naming conventions
  • [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

The lint doesn't really follow the naming conventions. I don't have any better idea so I'm open to suggestions.

sgued avatar Jul 16 '22 11:07 sgued

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @flip1995 (or someone else) soon.

Please see the contribution instructions for more information.

rust-highfive avatar Jul 16 '22 11:07 rust-highfive

:umbrella: The latest upstream changes (presumably #9148) made this pull request unmergeable. Please resolve the merge conflicts.

bors avatar Jul 18 '22 13:07 bors

Thanks for doing the analysis (https://github.com/rust-lang/rust-clippy/pull/9187#discussion_r928122711). I nominated this PR for the meeting this evening to figure out if we want to get this lint into pedantic or have it in nursery for starters.

The meeting is at 3pm UTC: https://everytimezone.com/s/deeec323

flip1995 avatar Jul 26 '22 07:07 flip1995

So in the Clippy meeting, we decided to place those lints in nursery for now and lift them up to pedantic once at least the most obvious FPs are addressed. Jarcho left some instructions on how this could be done here. However I don't want to block this PR on this.

flip1995 avatar Jul 26 '22 15:07 flip1995

I see on Zulip you proposed iter_on_empty_collection for the name of iter_empty. I like it. I suggest iter_on_singleton for iter_once

sgued avatar Jul 28 '22 20:07 sgued

I think of something different when I think about singletons. How about iter_on_single_items?

also make sure to use the plural form, so iter_on_empty_collections. That sounds better with allow.

flip1995 avatar Jul 29 '22 08:07 flip1995

Can you squash the commits a bit further, please? Most of those are trivial/one-line changes, that we don't really need in the Clippy history.

flip1995 avatar Aug 01 '22 11:08 flip1995

:umbrella: The latest upstream changes (presumably #9302) made this pull request unmergeable. Please resolve the merge conflicts.

bors avatar Aug 08 '22 08:08 bors

Is it squashed enough now or do you want even more?

sgued avatar Aug 13 '22 16:08 sgued

Commits f30d7c2 and b247594 could also be squashed just looking at the commit message. But that's just me being pedantic, so I won't block this PR on that.

Thanks for squashing. That's how I (almost :yum:) like my commit messages.

@bors r+

flip1995 avatar Aug 14 '22 15:08 flip1995

:pushpin: Commit af4885c0cde76bf1faace76dc8fb53d3d4791422 has been approved by flip1995

It is now in the queue for this repository.

bors avatar Aug 14 '22 15:08 bors

:hourglass: Testing commit af4885c0cde76bf1faace76dc8fb53d3d4791422 with merge 679fa9f2bfbdb65f0eb7732fa20043fd0f6813a8...

bors avatar Aug 14 '22 15:08 bors

:sunny: Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test Approved by: flip1995 Pushing 679fa9f2bfbdb65f0eb7732fa20043fd0f6813a8 to master...

bors avatar Aug 14 '22 16:08 bors