A lint is certainly a possibility, though I have trouble imagining what rules it could apply. Part of the problem is that the by-value and by-reference versions will generally call different functions or use different
impls, which are all user defined, so I suspect there will either be false positives or a non-exhaustive list of special cases (which could be challenging to create). Curiously, it seems there are no lints along these lines in clippy (the closest thing is replacing
.map(|x| x.clone()) to
.cloned() which is just a style issue), despite numerous lints targeting other kinds of “works but is not as fast as it could be”.
I would love to see such lints regardless of whether
String + String happens. As I said, I’m not even sure if this concern outweighs the ergonomics increase, and there are plenty of other places where unnecessary clones can happen.