Skip to content

unnecessary_to_owned: don't lint if map key has extra indirection#16700

Open
zihan0822 wants to merge 1 commit intorust-lang:masterfrom
zihan0822:fix-unnecessary-to-owned
Open

unnecessary_to_owned: don't lint if map key has extra indirection#16700
zihan0822 wants to merge 1 commit intorust-lang:masterfrom
zihan0822:fix-unnecessary-to-owned

Conversation

@zihan0822
Copy link
Copy Markdown
Contributor

@zihan0822 zihan0822 commented Mar 10, 2026

fix #16693

changelog: [unnecessary_to_owned]: don't lint if can't satisfy borrow obligation

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Mar 10, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 10, 2026

r? @Jarcho

rustbot has assigned @Jarcho.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: 7 candidates
  • 7 candidates expanded to 7 candidates
  • Random selection from Jarcho, dswij, llogiq, samueltardieu

@Jarcho
Copy link
Copy Markdown
Contributor

Jarcho commented Mar 24, 2026

Can you just remove the special casing for map types and handle &T parameters. The only way to actually fix all the issues with the current handling is to do the same obligation handling done for the general case for T parameters.

@zihan0822 zihan0822 force-pushed the fix-unnecessary-to-owned branch 3 times, most recently from 688a2da to 0e41aa1 Compare March 27, 2026 09:52
@zihan0822
Copy link
Copy Markdown
Contributor Author

@rustbot ready

Comment thread clippy_lints/src/methods/unnecessary_to_owned.rs Outdated
@zihan0822 zihan0822 force-pushed the fix-unnecessary-to-owned branch from 0e41aa1 to 0046a4b Compare March 28, 2026 09:16
@rustbot

This comment has been minimized.

@zihan0822 zihan0822 force-pushed the fix-unnecessary-to-owned branch from 0046a4b to 4aed26a Compare March 28, 2026 09:28
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 28, 2026

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Check to-owned-like method call receiver can satisfy borrow obligation.
We further extend this lint to support non-std collection with
getter-like apis.

changelog: [`unnecessary_to_owned`]: don't lint if can't satisfy borrow
obligation

Signed-off-by: Zihan <zihanli0822@gmail.com>
@zihan0822 zihan0822 force-pushed the fix-unnecessary-to-owned branch from 4aed26a to cc046dd Compare March 28, 2026 09:43
@zihan0822
Copy link
Copy Markdown
Contributor Author

updated and rebased

@zihan0822
Copy link
Copy Markdown
Contributor Author

ping @Jarcho

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.

unnecessary_to_owned: borrow trait bound is required by method thet gets the &..

3 participants