diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index 8803c4e3019..8a92e49340f 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -1029,7 +1029,7 @@ fn lint_clone_on_ref_ptr(cx: &LateContext, expr: &hir::Expr, arg: &hir::Expr) { expr.span, "using '.clone()' on a ref-counted pointer", "try this", - format!("{}<{}>::clone(&{})", caller_type, subst.type_at(0), snippet(cx, arg.span, "_")), + format!("{}::<{}>::clone(&{})", caller_type, subst.type_at(0), snippet(cx, arg.span, "_")), ); } } diff --git a/tests/ui/unnecessary_clone.stderr b/tests/ui/unnecessary_clone.stderr index 298a9393486..bb78bfa164e 100644 --- a/tests/ui/unnecessary_clone.stderr +++ b/tests/ui/unnecessary_clone.stderr @@ -16,7 +16,7 @@ error: using '.clone()' on a ref-counted pointer --> $DIR/unnecessary_clone.rs:30:5 | 30 | rc.clone(); - | ^^^^^^^^^^ help: try this: `Rc::clone(&rc)` + | ^^^^^^^^^^ help: try this: `Rc::::clone(&rc)` | = note: `-D clone-on-ref-ptr` implied by `-D warnings` @@ -24,25 +24,25 @@ error: using '.clone()' on a ref-counted pointer --> $DIR/unnecessary_clone.rs:33:5 | 33 | arc.clone(); - | ^^^^^^^^^^^ help: try this: `Arc::clone(&arc)` + | ^^^^^^^^^^^ help: try this: `Arc::::clone(&arc)` error: using '.clone()' on a ref-counted pointer --> $DIR/unnecessary_clone.rs:36:5 | 36 | rcweak.clone(); - | ^^^^^^^^^^^^^^ help: try this: `Weak::clone(&rcweak)` + | ^^^^^^^^^^^^^^ help: try this: `Weak::::clone(&rcweak)` error: using '.clone()' on a ref-counted pointer --> $DIR/unnecessary_clone.rs:39:5 | 39 | arc_weak.clone(); - | ^^^^^^^^^^^^^^^^ help: try this: `Weak::clone(&arc_weak)` + | ^^^^^^^^^^^^^^^^ help: try this: `Weak::::clone(&arc_weak)` error: using '.clone()' on a ref-counted pointer --> $DIR/unnecessary_clone.rs:43:29 | 43 | let _: Arc = x.clone(); - | ^^^^^^^^^ help: try this: `Arc::clone(&x)` + | ^^^^^^^^^ help: try this: `Arc::::clone(&x)` error: using `clone` on a `Copy` type --> $DIR/unnecessary_clone.rs:47:5