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
needless_borrows_for_generic_args: Handle when field operand impl Drop #11900
Conversation
Before this fix, the lint had a false positive, namely when a reference was taken to a field when the field operand implements a custom Drop. The compiler will refuse to partially move a type that implements Drop, because that would put the operand in a weird state. See added regression test.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Manishearth (or someone else) soon. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
@bors r+ |
needless_borrows_for_generic_args: Handle when field operand impl Drop Before this fix, the lint had a false positive, namely when a reference was taken to a field when the field operand implements a custom Drop. The compiler will refuse to partially move a type that implements Drop, because that would put the type in a weird state. ## False Positive Example (Fixed) ```rs struct CustomDrop(String); impl Drop for CustomDrop { fn drop(&mut self) {} } fn check_str<P: AsRef<str>>(_to: P) {} fn test() { let owner = CustomDrop(String::default()); check_str(&owner.0); // Don't lint. `owner` can't be partially moved because it impl Drop } ``` changelog: [`needless_borrows_for_generic_args`]: Handle when field operand impl Drop
💔 Test failed - checks-action_test |
Looks like the same error I'm seeing in my pull request. See #11904 (comment). |
@bors r=Manishearth |
💡 This pull request was already approved, no need to approve it again.
|
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
My [fix](rust-lang/rust-clippy#11900) for the false positive has reached Rust 1.76 stable, so let's remove the annoying `allow`.
My [fix](rust-lang/rust-clippy#11900) for the false positive has reached Rust 1.76 stable, so let's remove the annoying `allow`.
Before this fix, the lint had a false positive, namely when a reference was taken to a field when the field operand implements a custom Drop. The compiler will refuse to partially move a type that implements Drop, because that would put the type in a weird state.
False Positive Example (Fixed)
changelog: [
needless_borrows_for_generic_args
]: Handle when field operand impl Drop