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

allow needless_option_take to report for more cases #13684

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ericwu17
Copy link
Contributor

changelog:

changelog: [`needless_option_take`]: now lints for all temporary expressions of type  Option<T>.

fixes #13671

In general, needless_option_take should report whenever take() is called on a temporary value, not just when the temporary value is created by as_ref().

Also, we stop emitting machine applicable fixes in these cases, since sometimes the intention of the user is to actually clear the original option, in cases such as option.as_mut().take().

@rustbot
Copy link
Collaborator

rustbot commented Nov 14, 2024

r? @Centri3

rustbot has assigned @Centri3.
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

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Nov 14, 2024
In general, needless_option_take should report whenever
take() is called on a temporary value, not just when the
temporary value is created by as_ref()
@ericwu17 ericwu17 force-pushed the generalized-needless-option-take branch from a76fdbf to 9a8639e Compare November 14, 2024 04:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

Option::as_mut followed by Option::take is a foot-gun
3 participants