don't suggest to use cloned for Cow in unnecessary_to_owned

This commit is contained in:
lapla-cogito 2024-12-19 21:56:49 +09:00
parent 609cd310be
commit 08d8c4a67f
No known key found for this signature in database
GPG key ID: B39C71D9F127FF9F
3 changed files with 15 additions and 0 deletions

View file

@ -217,10 +217,13 @@ fn check_into_iter_call_arg(
&& implements_trait(cx, parent_ty, iterator_trait_id, &[])
&& let Some(item_ty) = get_iterator_item_ty(cx, parent_ty)
&& let Some(receiver_snippet) = receiver.span.get_source_text(cx)
// If the receiver is a `Cow`, we can't remove the `into_owned` generally, see https://github.com/rust-lang/rust-clippy/issues/13624.
&& !is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(receiver), sym::Cow)
{
if unnecessary_iter_cloned::check_for_loop_iter(cx, parent, method_name, receiver, true) {
return true;
}
let cloned_or_copied = if is_copy(cx, item_ty) && msrv.meets(msrvs::ITERATOR_COPIED) {
"copied"
} else {