about summary refs log tree commit diff
path: root/clippy_lints/src
diff options
context:
space:
mode:
authorJ-ZhengLi <lizheng135@huawei.com>2023-08-15 09:41:15 +0800
committerJ-ZhengLi <lizheng135@huawei.com>2023-08-15 09:41:15 +0800
commitaa8995e589c7f4a433ae6fe27b319ff9898b523a (patch)
tree77643f0fd4d3f908883b57b003acfa61582aa66f /clippy_lints/src
parentb5bfd1176b3d0de03e63c8d0b244ef61b30067d8 (diff)
allow calling `to_owned` with borrowed value for [`implicit_clone`]
Diffstat (limited to 'clippy_lints/src')
-rw-r--r--clippy_lints/src/methods/implicit_clone.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/clippy_lints/src/methods/implicit_clone.rs b/clippy_lints/src/methods/implicit_clone.rs
index 043425300d8..e91ce64d8c8 100644
--- a/clippy_lints/src/methods/implicit_clone.rs
+++ b/clippy_lints/src/methods/implicit_clone.rs
@@ -17,6 +17,7 @@ pub fn check(cx: &LateContext<'_>, method_name: &str, expr: &hir::Expr<'_>, recv
         let return_type = cx.typeck_results().expr_ty(expr);
         let input_type = cx.typeck_results().expr_ty(recv);
         let (input_type, ref_count) = peel_mid_ty_refs(input_type);
+        if !(ref_count > 0 && is_diag_trait_item(cx, method_def_id, sym::ToOwned));
         if let Some(ty_name) = input_type.ty_adt_def().map(|adt_def| cx.tcx.item_name(adt_def.did()));
         if return_type == input_type;
         if let Some(clone_trait) = cx.tcx.lang_items().clone_trait();