diff options
| author | bors <bors@rust-lang.org> | 2023-08-15 11:42:05 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-08-15 11:42:05 +0000 |
| commit | 11efa0133f9d0b0deafb9c73c4de14154a4e794f (patch) | |
| tree | 77643f0fd4d3f908883b57b003acfa61582aa66f /clippy_lints/src | |
| parent | b5bfd1176b3d0de03e63c8d0b244ef61b30067d8 (diff) | |
| parent | aa8995e589c7f4a433ae6fe27b319ff9898b523a (diff) | |
Auto merge of #11321 - J-ZhengLi:issue11281, r=giraffate
allow calling `to_owned` on borrowed value for [`implicit_clone`] fixes: #11281 a small and simple fix that give up checking for `referenced_value.to_owned()` usage. changelog: 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.rs | 1 |
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(); |
