3

[`unnecessary_to_owned`]: check that the adjusted type matches target by y21 · P...

 1 year ago
source link: https://github.com/rust-lang/rust-clippy/pull/10913
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Conversation

Contributor

Fixes #10033.

Before this change, the lint would assume that removing the .to_string() in f(&x.to_string()) would be ok if x is of some type that implements Deref<Target = str> and f takes a &str.
This turns out to not actually be ok if the to_string call is some method that exists on x directly, which happens if it implements Display/ToString itself.

changelog: [unnecessary_to_owned]: only lint if the adjusted receiver type actually matches


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK