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

add lint [incorrect_clone_impl_on_copy_type] #10925

Merged
merged 2 commits into from
Jun 16, 2023

Conversation

Centri3
Copy link
Member

@Centri3 Centri3 commented Jun 11, 2023

Split off from #10788.

Closes #10700


changelog: new lint [incorrect_clone_impl_on_copy_type]
#10925

@rustbot
Copy link
Collaborator

rustbot commented Jun 11, 2023

r? @xFrednet

(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 Jun 11, 2023
@xFrednet
Copy link
Member

@Centri3, you're on a real PR creation spree, damn! I'll review this one over the coming week :D

@bors
Copy link
Collaborator

bors commented Jun 12, 2023

☔ The latest upstream changes (presumably #10921) made this pull request unmergeable. Please resolve the merge conflicts.

@bors
Copy link
Collaborator

bors commented Jun 12, 2023

☔ The latest upstream changes (presumably #10916) made this pull request unmergeable. Please resolve the merge conflicts.

@bors
Copy link
Collaborator

bors commented Jun 12, 2023

☔ The latest upstream changes (presumably #10827) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Member

@xFrednet xFrednet left a comment

Choose a reason for hiding this comment

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

I have a few smaller comments, but all of them should hopefully be simple to solve :). Please reach out, if you have any questions :)

clippy_lints/src/needless_impls.rs Outdated Show resolved Hide resolved
clippy_lints/src/needless_impls.rs Outdated Show resolved Hide resolved
clippy_lints/src/needless_impls.rs Outdated Show resolved Hide resolved
clippy_lints/src/needless_impls.rs Outdated Show resolved Hide resolved
tests/ui/needless_clone_impl.fixed Outdated Show resolved Hide resolved
tests/ui/needless_clone_impl.rs Outdated Show resolved Hide resolved
@bors
Copy link
Collaborator

bors commented Jun 15, 2023

☔ The latest upstream changes (presumably #10934) made this pull request unmergeable. Please resolve the merge conflicts.

@Centri3
Copy link
Member Author

Centri3 commented Jun 15, 2023

I've looked at ryu's emittance of this lint, and it appears it is indeed correct; it implements Copy but Clone calls Buffer::new.
https:/dtolnay/ryu/blob/6cdb3d1a0aaf62f762acf391d6b03f9a41f56c0e/src/buffer/mod.rs#LL82C1-L89C2
I've tested it with *self instead and there's no difference.

Running miri as well shows nothing out of the ordinary (though it already reported a violation of stacked borrows without such a change). Not sure whether it's slower or not, though.

@xFrednet xFrednet changed the title add lint [needless_clone_impl] add lint [incorrect_clone_impl_on_copy_type] Jun 16, 2023
@xFrednet
Copy link
Member

This looks good to me. Thank you for the new lint!

@bors r+

@bors
Copy link
Collaborator

bors commented Jun 16, 2023

📌 Commit 10cc168 has been approved by xFrednet

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Jun 16, 2023

⌛ Testing commit 10cc168 with merge 87b5f89...

@bors
Copy link
Collaborator

bors commented Jun 16, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: xFrednet
Pushing 87b5f89 to master...

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.

Clone should be *self for types which are always Copy
4 participants