-
Notifications
You must be signed in to change notification settings - Fork 12.1k
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
clippy: less aggressive needless_borrows_for_generic_args #124292
Conversation
Current implementation looks for significant drops, that can change the behavior, but that's not enough - value might not have a Drop itself but one of its children might have it. A good example is passing a reference to `PathBuf` to `std::fs::File::open`. There's no benefits to pass `PathBuf` by value, but since clippy can't see `Drop` on `Vec` several layers down it complains forcing pass by value and making it impossible to use the same name later. New implementation only looks at variables and only those that are copy, so existing variable will never be moved but things that take a string reference created and value is created inplace `&"".to_owned()` will make it to suggest to use `"".to_owned()` still. Fixes rust-lang/rust-clippy#12454
e544aac
to
9e29a30
Compare
Oops, included a commit from other pull request by accident. Sorry for the noise, gone now. |
Since this only touches clippy, you open a PR on the clippy repo. Or is there a specific reason this is opened here? |
This comment was marked as duplicate.
This comment was marked as duplicate.
I wasn't sure where to open it :) Will reopen it against clippy. |
The job Click to see the possible cause of the failure (guessed by this bot)
|
Current implementation looks for significant drops, that can change the
behavior, but that's not enough - value might not have a Drop itself but
one of its children might have it.
A good example is passing a reference to
PathBuf
tostd::fs::File::open
.There's no benefits to pass
PathBuf
by value, but since clippy can'tsee
Drop
onVec
several layers down it complains forcing pass byvalue and making it impossible to use the same name later.
New implementation only looks at variables and only those that are copy,
so existing variable will never be moved but things that take a string
reference created and value is created inplace
&"".to_owned()
willmake it to suggest to use
"".to_owned()
still.Fixes rust-lang/rust-clippy#12454