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

don't suggest to use cloned for Cow in unnecessary_to_owned #13853

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

Conversation

lapla-cogito
Copy link
Contributor

fix #13624

changelog: [unnecessary_to_owned]: don't suggest to use cloned on Cow in unnecessary_to_owned

@rustbot
Copy link
Collaborator

rustbot commented Dec 19, 2024

r? @y21

rustbot has assigned @y21.
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 19, 2024
@lapla-cogito lapla-cogito force-pushed the into_owned_cow branch 2 times, most recently from ebc2dfa to 461c834 Compare December 19, 2024 13:36
@alex-semenyuk
Copy link
Member

@lapla-cogito Could you please take a look failed tests

Comment on lines +595 to +596
LL | cow.into_owned().into_iter()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `cow.into_owned()`
Copy link
Member

Choose a reason for hiding this comment

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

The suggestion works in this specific case, but it doesn't seem like it would work in the general case if the iterator is later used as part of another expression, e.g. for cow.into_owned().into_iter().map(...).collect() the .into_iter() is required. Tbh I don't think we can really suggest anything here for Cow::into_owned and we probably should just not lint at all here?

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.

False positive: cow and into_owned
4 participants