Skip to content

Conversation

ericwu17
Copy link
Contributor

@ericwu17 ericwu17 commented Jan 2, 2023

fixes #10122

As established in issue #9482, it is idiomatic to use a single drop() expression in a match arm to achieve a side-effect of a function while discarding its output. This should also apply to cases where the function returns a reference.

The change to the lint's code was less than 1 line, because all the heavy lifting was done in PR #9491.


changelog: FP: [drop_ref]: No longer lints idiomatic expression in match arms
#10142

@rustbot
Copy link
Collaborator

rustbot commented Jan 2, 2023

r? @llogiq

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jan 2, 2023
@ericwu17
Copy link
Contributor Author

ericwu17 commented Jan 2, 2023

@kraktus Could you please take a look at this PR, since you worked on this code previously?

@ericwu17 ericwu17 force-pushed the drop_ref-FP branch 2 times, most recently from 61a4389 to bd8977a Compare January 2, 2023 00:23
@kraktus
Copy link
Contributor

kraktus commented Jan 2, 2023

Sounds good to me 👍

@llogiq
Copy link
Contributor

llogiq commented Jan 5, 2023

Thank you, that looks like a sensible approach.

@bors r+

@bors
Copy link
Contributor

bors commented Jan 5, 2023

📌 Commit 01a2a9d has been approved by llogiq

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jan 5, 2023

⌛ Testing commit 01a2a9d with merge 4f4c961...

@bors
Copy link
Contributor

bors commented Jan 5, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: llogiq
Pushing 4f4c961 to master...

@bors bors merged commit 4f4c961 into rust-lang:master Jan 5, 2023
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.

drop_ref should not trigger when drop is used in a match branch
5 participants