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

Improve needless_pass_by_value suggestion #13880

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

Conversation

GuillaumeGomez
Copy link
Member

Fixes #13744.

A simple check to check if the type is an Option allows to improve the suggestion.

changelog: Improve needless_pass_by_value suggestion

@rustbot
Copy link
Collaborator

rustbot commented Dec 26, 2024

r? @dswij

rustbot has assigned @dswij.
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 Dec 26, 2024
@GuillaumeGomez
Copy link
Member Author

r? clippy

@rustbot rustbot assigned Manishearth and unassigned dswij Dec 26, 2024
@@ -29,7 +29,7 @@ error: this argument is passed by value, but not consumed in the function body
--> tests/ui/needless_pass_by_value.rs:56:18
|
LL | fn test_match(x: Option<Option<String>>, y: Option<Option<String>>) {
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&Option<Option<String>>`
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `Option<&Option<String>>`

Choose a reason for hiding this comment

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

Should you run this several times?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was wondering about that. Is it better to propose for the inner most T to be behind a reference or just the direct top child?

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.

poor suggestion on needless_pass_by_value on Option
5 participants