]> git.lizzy.rs Git - rust.git/blobdiff - src/tools/clippy/clippy_lints/src/methods/clone_on_copy.rs
Rollup merge of #105663 - andrewpollack:patch-1, r=tmandry
[rust.git] / src / tools / clippy / clippy_lints / src / methods / clone_on_copy.rs
index 7ab6b84c2074918f39b8f0d5aa67de94d23a914c..7c7938dd2e8b04f5e76fc1f10c4eb654bbcf2f93 100644 (file)
@@ -49,8 +49,7 @@ pub(super) fn check(
                 expr.span,
                 &format!(
                     "using `clone` on a double-reference; \
-                    this will copy the reference of type `{}` instead of cloning the inner type",
-                    ty
+                    this will copy the reference of type `{ty}` instead of cloning the inner type"
                 ),
                 |diag| {
                     if let Some(snip) = sugg::Sugg::hir_opt(cx, arg) {
@@ -62,11 +61,11 @@ pub(super) fn check(
                         }
                         let refs = "&".repeat(n + 1);
                         let derefs = "*".repeat(n);
-                        let explicit = format!("<{}{}>::clone({})", refs, ty, snip);
+                        let explicit = format!("<{refs}{ty}>::clone({snip})");
                         diag.span_suggestion(
                             expr.span,
                             "try dereferencing it",
-                            format!("{}({}{}).clone()", refs, derefs, snip.deref()),
+                            format!("{refs}({derefs}{}).clone()", snip.deref()),
                             Applicability::MaybeIncorrect,
                         );
                         diag.span_suggestion(
@@ -121,16 +120,16 @@ pub(super) fn check(
         let (help, sugg) = if deref_count == 0 {
             ("try removing the `clone` call", snip.into())
         } else if parent_is_suffix_expr {
-            ("try dereferencing it", format!("({}{})", "*".repeat(deref_count), snip))
+            ("try dereferencing it", format!("({}{snip})", "*".repeat(deref_count)))
         } else {
-            ("try dereferencing it", format!("{}{}", "*".repeat(deref_count), snip))
+            ("try dereferencing it", format!("{}{snip}", "*".repeat(deref_count)))
         };
 
         span_lint_and_sugg(
             cx,
             CLONE_ON_COPY,
             expr.span,
-            &format!("using `clone` on type `{}` which implements the `Copy` trait", ty),
+            &format!("using `clone` on type `{ty}` which implements the `Copy` trait"),
             help,
             sugg,
             app,