Skip to content

Conversation

@samueltardieu
Copy link
Member

The case of .to_owned().split(…) is treated specially in the unnecessary_to_owned lint. Test cases check that it works both for slices and for strings, but they missed a corner case: x.to_string().split(…) when x implements AsRef<str> but not Deref<Target = str>. In this case, it is wrong to suggest to remove .to_string() without adding .as_ref() instead.

Fix #12068

changelog: [unnecessary_to_owned]: suggest replacing .to_string() by .as_ref()

@rustbot
Copy link
Collaborator

rustbot commented Jan 4, 2024

r? @Alexendoo

(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 Jan 4, 2024
@Alexendoo
Copy link
Member

Thank you!

@bors r+

@bors
Copy link
Contributor

bors commented Jan 5, 2024

📌 Commit e758413 has been approved by Alexendoo

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jan 5, 2024

⌛ Testing commit e758413 with merge 2d6c238...

@bors
Copy link
Contributor

bors commented Jan 5, 2024

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: Alexendoo
Pushing 2d6c238 to master...

@bors bors merged commit 2d6c238 into rust-lang:master Jan 5, 2024
@samueltardieu samueltardieu deleted the issue-12068 branch January 7, 2024 10:12
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.

Latest nightly issue

4 participants