diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index 271891802485..3c43671dd34c 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -1893,7 +1893,7 @@ declare_clippy_lint! { /// and other `to_owned`-like functions. /// /// ### Why is this bad? - /// The unnecessary calls result in unnecessary allocations. + /// The unnecessary calls result in useless allocations. /// /// ### Example /// ```rust diff --git a/clippy_lints/src/methods/unnecessary_to_owned.rs b/clippy_lints/src/methods/unnecessary_to_owned.rs index c5af7483ae6f..c48bacfce0d3 100644 --- a/clippy_lints/src/methods/unnecessary_to_owned.rs +++ b/clippy_lints/src/methods/unnecessary_to_owned.rs @@ -107,21 +107,17 @@ fn check_addr_of_expr( then { let (target_ty, n_target_refs) = peel_mid_ty_refs(target_ty); let (receiver_ty, n_receiver_refs) = peel_mid_ty_refs(receiver_ty); - if_chain! { - if receiver_ty == target_ty; - if n_target_refs >= n_receiver_refs; - then { - span_lint_and_sugg( - cx, - UNNECESSARY_TO_OWNED, - parent.span, - &format!("unnecessary use of `{}`", method_name), - "use", - format!("{:&>width$}{}", "", receiver_snippet, width = n_target_refs - n_receiver_refs), - Applicability::MachineApplicable, - ); - return true; - } + if receiver_ty == target_ty && n_target_refs >= n_receiver_refs { + span_lint_and_sugg( + cx, + UNNECESSARY_TO_OWNED, + parent.span, + &format!("unnecessary use of `{}`", method_name), + "use", + format!("{:&>width$}{}", "", receiver_snippet, width = n_target_refs - n_receiver_refs), + Applicability::MachineApplicable, + ); + return true; } if_chain! { if let Some(deref_trait_id) = cx.tcx.get_diagnostic_item(sym::Deref);