about summary refs log tree commit diff
path: root/clippy_lints/src
diff options
context:
space:
mode:
authorlapla-cogito <me@lapla.dev>2024-12-19 21:56:49 +0900
committerlapla-cogito <me@lapla.dev>2024-12-27 21:11:25 +0900
commit08d8c4a67fd9a9eea1bad23da92bb614bc6f9966 (patch)
tree441742d03b280e279682a8af07dfdc580e027098 /clippy_lints/src
parent609cd310be44677ae31d452a17b0f8207e1abfe1 (diff)
downloadrust-08d8c4a67fd9a9eea1bad23da92bb614bc6f9966.tar.gz
rust-08d8c4a67fd9a9eea1bad23da92bb614bc6f9966.zip
don't suggest to use cloned for Cow in unnecessary_to_owned
Diffstat (limited to 'clippy_lints/src')
-rw-r--r--clippy_lints/src/methods/unnecessary_to_owned.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/clippy_lints/src/methods/unnecessary_to_owned.rs b/clippy_lints/src/methods/unnecessary_to_owned.rs
index d19064fd57e..12b9d4836e8 100644
--- a/clippy_lints/src/methods/unnecessary_to_owned.rs
+++ b/clippy_lints/src/methods/unnecessary_to_owned.rs
@@ -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 {