Skip to content

Comments

add manual_pop_if lint#16582

Open
pbor wants to merge 1 commit intorust-lang:masterfrom
pbor:master
Open

add manual_pop_if lint#16582
pbor wants to merge 1 commit intorust-lang:masterfrom
pbor:master

Conversation

@pbor
Copy link
Contributor

@pbor pbor commented Feb 18, 2026

Add a lint to detect when the recently added Vec::pop_if, VecDeque::pop_front_if, and VecDeque::pop_back_if are manually implemented.

changelog: add [manual_pop_if] lint

@rustbot rustbot added needs-fcp S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Feb 18, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 18, 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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: 7 candidates
  • 7 candidates expanded to 7 candidates
  • Random selection from Jarcho, dswij, llogiq, samueltardieu

@pbor pbor force-pushed the master branch 2 times, most recently from a512585 to 00bcf66 Compare February 18, 2026 13:06
Copy link
Contributor

@ada4a ada4a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very nicely made lint:) Left a couple suggestions, but nothing too major

View changes since this review

@pbor
Copy link
Contributor Author

pbor commented Feb 19, 2026

Thanks for the quick review! I hope I have addressed all the comments

Copy link
Contributor

@ada4a ada4a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is shaping up nicely:) Here's another round of stuff

View changes since this review

@samueltardieu
Copy link
Member

@ada4a Don't hesitate to open an FCP on Zulip when you think this is ready.

@ada4a
Copy link
Contributor

ada4a commented Feb 20, 2026

Thank you @samueltardieu :)

@pbor
Copy link
Contributor Author

pbor commented Feb 20, 2026

I think I have addressed the comments, if there is anything else that stands out let me know, otherwise I would like to start with this and treat the additional cases as future enhancements.

In particular, it would be nice to handle the case where the popped value is, since I believe that is common, but I am not quite sure on how to transform an if into if let Some(val) = pop_if while preserving the logic within the block.

@ada4a
Copy link
Contributor

ada4a commented Feb 20, 2026

In particular, it would be nice to handle the case where the popped value is, since I believe that is common, but I am not quite sure on how to transform an if into if let Some(val) = pop_if while preserving the logic within the block.

I think it could help to look at some real-world examples, see how they would need to be transformed, and implement just those pattern-suggestion pairs, as a start. For this, you could use Lintcheck: you could open a test PR which makes the lint fire on more patterns, like any if-else with the condition containing vec.pop().is_some_and() (you don't need to worry about actually giving any suggestions), and then the Lintcheck diff would show you the new examples caught by the lint

Copy link
Contributor

@ada4a ada4a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say this is pretty much ready:) Just a few notes left

View changes since this review

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Feb 20, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 20, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

Add a lint to detect when the recently added Vec::pop_if,
VecDeque::pop_front_if, and VecDeque::pop_back_if are manually
implemented.

changelog: add [`manual_pop_if`] lint
@rustbot
Copy link
Collaborator

rustbot commented Feb 20, 2026

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@pbor
Copy link
Contributor Author

pbor commented Feb 20, 2026

I hope I fixed all the comments (thanks for the review)!

I will need to look at the LintCheck suggestion next week

@ada4a
Copy link
Contributor

ada4a commented Feb 20, 2026

First of all, let's deal with rustbot:

@rustbot reviewer

Now, let's give this a go:)

FCP started at #clippy > FCP: `manual_pop_if`

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties and removed S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-fcp S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants