about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSamuel E. Moelius III <sam@moeli.us>2021-12-14 18:36:19 -0500
committerSamuel E. Moelius III <sam@moeli.us>2021-12-14 18:36:19 -0500
commit3beb6b1908e03bbf645ecdac7d56a772b5d8a8ef (patch)
tree42858636e66594cc99b667be090926b688c02d8e
parentcb609a99044adc07ea4cdb0b4927f4ad461bb4b5 (diff)
downloadrust-3beb6b1908e03bbf645ecdac7d56a772b5d8a8ef.tar.gz
rust-3beb6b1908e03bbf645ecdac7d56a772b5d8a8ef.zip
Address review comments
-rw-r--r--clippy_lints/src/methods/mod.rs2
-rw-r--r--clippy_lints/src/methods/unnecessary_to_owned.rs26
2 files changed, 12 insertions, 16 deletions
diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs
index 27189180248..3c43671dd34 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 c5af7483ae6..c48bacfce0d 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);