about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-07-26 14:32:19 -0400
committerMichael Goulet <michael@errs.io>2024-07-26 14:41:56 -0400
commit91acacf85b9f81aeb41901f8918128bfe02946c8 (patch)
tree24f38bf31ef9f15930e66da7d4e187a73d7ed932
parente7eae5370e304fb1534c1964852a6c127f1f09f8 (diff)
downloadrust-91acacf85b9f81aeb41901f8918128bfe02946c8.tar.gz
rust-91acacf85b9f81aeb41901f8918128bfe02946c8.zip
Peel off explicit (or implicit) deref before suggesting clone on move error in borrowck
-rw-r--r--compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs92
-rw-r--r--compiler/rustc_borrowck/src/diagnostics/move_errors.rs16
-rw-r--r--tests/ui/associated-types/associated-types-outlives.stderr2
-rw-r--r--tests/ui/augmented-assignments.rs1
-rw-r--r--tests/ui/augmented-assignments.stderr7
-rw-r--r--tests/ui/binop/binop-move-semantics.stderr4
-rw-r--r--tests/ui/borrowck/borrow-tuple-fields.stderr10
-rw-r--r--tests/ui/borrowck/borrowck-bad-nested-calls-move.stderr4
-rw-r--r--tests/ui/borrowck/borrowck-field-sensitivity.stderr10
-rw-r--r--tests/ui/borrowck/borrowck-issue-48962.stderr5
-rw-r--r--tests/ui/borrowck/borrowck-loan-blocks-move-cc.stderr10
-rw-r--r--tests/ui/borrowck/borrowck-loan-blocks-move.stderr5
-rw-r--r--tests/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr5
-rw-r--r--tests/ui/borrowck/borrowck-move-mut-base-ptr.stderr2
-rw-r--r--tests/ui/borrowck/borrowck-move-subcomponent.stderr2
-rw-r--r--tests/ui/borrowck/borrowck-multiple-captures.stderr15
-rw-r--r--tests/ui/borrowck/borrowck-overloaded-index-move-index.stderr10
-rw-r--r--tests/ui/borrowck/borrowck-unary-move.stderr2
-rw-r--r--tests/ui/borrowck/clone-on-ref.stderr4
-rw-r--r--tests/ui/borrowck/issue-101119.stderr8
-rw-r--r--tests/ui/btreemap/btreemap_dropck.stderr5
-rw-r--r--tests/ui/dropck/drop-with-active-borrows-1.stderr5
-rw-r--r--tests/ui/error-codes/E0504.stderr2
-rw-r--r--tests/ui/error-codes/E0505.stderr2
-rw-r--r--tests/ui/fn/implied-bounds-unnorm-associated-type-4.stderr5
-rw-r--r--tests/ui/fn/implied-bounds-unnorm-associated-type-5.stderr5
-rw-r--r--tests/ui/fn/implied-bounds-unnorm-associated-type.stderr5
-rw-r--r--tests/ui/moves/move-fn-self-receiver.stderr9
-rw-r--r--tests/ui/nll/closure-access-spans.stderr15
-rw-r--r--tests/ui/nll/issue-27282-move-match-input-into-guard.stderr10
-rw-r--r--tests/ui/nll/issue-27282-move-ref-mut-into-guard.fixed23
-rw-r--r--tests/ui/nll/issue-27282-move-ref-mut-into-guard.rs2
-rw-r--r--tests/ui/nll/issue-27282-move-ref-mut-into-guard.stderr8
-rw-r--r--tests/ui/nll/issue-27282-mutation-in-guard.stderr8
-rw-r--r--tests/ui/nll/issue-52059-report-when-borrow-and-drop-conflict.stderr4
-rw-r--r--tests/ui/nll/match-guards-always-borrow.fixed66
-rw-r--r--tests/ui/nll/match-guards-always-borrow.rs1
-rw-r--r--tests/ui/nll/match-guards-always-borrow.stderr12
-rw-r--r--tests/ui/nll/polonius/polonius-smoke-test.stderr12
-rw-r--r--tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr16
-rw-r--r--tests/ui/span/send-is-not-static-std-sync.stderr6
-rw-r--r--tests/ui/suggestions/borrow-for-loop-head.stderr5
-rw-r--r--tests/ui/try-block/try-block-bad-lifetime.stderr5
-rw-r--r--tests/ui/unop/unop-move-semantics.stderr4
-rw-r--r--tests/ui/variance/variance-issue-20533.stderr13
45 files changed, 111 insertions, 351 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
index a5635344b4a..6515db42b08 100644
--- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
@@ -570,11 +570,11 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
                 } = move_spans
                     && can_suggest_clone
                 {
-                    self.suggest_cloning(err, ty, expr, None, Some(move_spans));
+                    self.suggest_cloning(err, ty, expr, Some(move_spans));
                 } else if self.suggest_hoisting_call_outside_loop(err, expr) && can_suggest_clone {
                     // The place where the type moves would be misleading to suggest clone.
                     // #121466
-                    self.suggest_cloning(err, ty, expr, None, Some(move_spans));
+                    self.suggest_cloning(err, ty, expr, Some(move_spans));
                 }
             }
 
@@ -1236,8 +1236,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
         &self,
         err: &mut Diag<'_>,
         ty: Ty<'tcx>,
-        mut expr: &'tcx hir::Expr<'tcx>,
-        mut other_expr: Option<&'tcx hir::Expr<'tcx>>,
+        expr: &'tcx hir::Expr<'tcx>,
         use_spans: Option<UseSpans<'tcx>>,
     ) {
         if let hir::ExprKind::Struct(_, _, Some(_)) = expr.kind {
@@ -1249,66 +1248,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
             return;
         }
 
-        if let Some(some_other_expr) = other_expr
-            && let Some(parent_binop) =
-                self.infcx.tcx.hir().parent_iter(expr.hir_id).find_map(|n| {
-                    if let (hir_id, hir::Node::Expr(e)) = n
-                        && let hir::ExprKind::AssignOp(_binop, target, _arg) = e.kind
-                        && target.hir_id == expr.hir_id
-                    {
-                        Some(hir_id)
-                    } else {
-                        None
-                    }
-                })
-            && let Some(other_parent_binop) =
-                self.infcx.tcx.hir().parent_iter(some_other_expr.hir_id).find_map(|n| {
-                    if let (hir_id, hir::Node::Expr(expr)) = n
-                        && let hir::ExprKind::AssignOp(..) = expr.kind
-                    {
-                        Some(hir_id)
-                    } else {
-                        None
-                    }
-                })
-            && parent_binop == other_parent_binop
-        {
-            // Explicitly look for `expr += other_expr;` and avoid suggesting
-            // `expr.clone() += other_expr;`, instead suggesting `expr += other_expr.clone();`.
-            other_expr = Some(expr);
-            expr = some_other_expr;
-        }
-        'outer: {
-            if let ty::Ref(..) = ty.kind() {
-                // We check for either `let binding = foo(expr, other_expr);` or
-                // `foo(expr, other_expr);` and if so we don't suggest an incorrect
-                // `foo(expr, other_expr).clone()`
-                if let Some(other_expr) = other_expr
-                    && let Some(parent_let) =
-                        self.infcx.tcx.hir().parent_iter(expr.hir_id).find_map(|n| {
-                            if let (hir_id, hir::Node::LetStmt(_) | hir::Node::Stmt(_)) = n {
-                                Some(hir_id)
-                            } else {
-                                None
-                            }
-                        })
-                    && let Some(other_parent_let) =
-                        self.infcx.tcx.hir().parent_iter(other_expr.hir_id).find_map(|n| {
-                            if let (hir_id, hir::Node::LetStmt(_) | hir::Node::Stmt(_)) = n {
-                                Some(hir_id)
-                            } else {
-                                None
-                            }
-                        })
-                    && parent_let == other_parent_let
-                {
-                    // Explicitly check that we don't have `foo(&*expr, other_expr)`, as cloning the
-                    // result of `foo(...)` won't help.
-                    break 'outer;
-                }
-            }
-        }
-        let ty = ty.peel_refs();
         if self.implements_clone(ty) {
             self.suggest_cloning_inner(err, ty, expr);
         } else if let ty::Adt(def, args) = ty.kind()
@@ -1575,10 +1514,27 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
             );
         self.suggest_copy_for_type_in_cloned_ref(&mut err, place);
         let typeck_results = self.infcx.tcx.typeck(self.mir_def_id());
-        if let Some(expr) = self.find_expr(borrow_span)
-            && let Some(ty) = typeck_results.node_type_opt(expr.hir_id)
-        {
-            self.suggest_cloning(&mut err, ty, expr, self.find_expr(span), Some(move_spans));
+        if let Some(expr) = self.find_expr(borrow_span) {
+            // This is a borrow span, so we want to suggest cloning the referent.
+            if let hir::ExprKind::AddrOf(_, _, borrowed_expr) = expr.kind
+                && let Some(ty) = typeck_results.expr_ty_opt(borrowed_expr)
+            {
+                self.suggest_cloning(&mut err, ty, borrowed_expr, Some(move_spans));
+            } else if typeck_results.expr_adjustments(expr).first().is_some_and(|adj| {
+                matches!(
+                    adj.kind,
+                    ty::adjustment::Adjust::Borrow(ty::adjustment::AutoBorrow::Ref(
+                        _,
+                        ty::adjustment::AutoBorrowMutability::Not
+                            | ty::adjustment::AutoBorrowMutability::Mut {
+                                allow_two_phase_borrow: ty::adjustment::AllowTwoPhase::No
+                            }
+                    ))
+                )
+            }) && let Some(ty) = typeck_results.expr_ty_opt(expr)
+            {
+                self.suggest_cloning(&mut err, ty, expr, Some(move_spans));
+            }
         }
         self.buffer_error(err);
     }
diff --git a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs
index fcf23aa4785..74c6bb88101 100644
--- a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs
@@ -565,9 +565,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
 
     fn add_move_hints(&self, error: GroupedMoveError<'tcx>, err: &mut Diag<'_>, span: Span) {
         match error {
-            GroupedMoveError::MovesFromPlace {
-                mut binds_to, move_from, span: other_span, ..
-            } => {
+            GroupedMoveError::MovesFromPlace { mut binds_to, move_from, .. } => {
                 self.add_borrow_suggestions(err, span);
                 if binds_to.is_empty() {
                     let place_ty = move_from.ty(self.body, self.infcx.tcx).ty;
@@ -577,7 +575,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
                     };
 
                     if let Some(expr) = self.find_expr(span) {
-                        self.suggest_cloning(err, place_ty, expr, self.find_expr(other_span), None);
+                        self.suggest_cloning(err, place_ty, expr, None);
                     }
 
                     err.subdiagnostic(crate::session_diagnostics::TypeNoCopy::Label {
@@ -609,13 +607,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
                 };
 
                 if let Some(expr) = self.find_expr(use_span) {
-                    self.suggest_cloning(
-                        err,
-                        place_ty,
-                        expr,
-                        self.find_expr(span),
-                        Some(use_spans),
-                    );
+                    self.suggest_cloning(err, place_ty, expr, Some(use_spans));
                 }
 
                 err.subdiagnostic(crate::session_diagnostics::TypeNoCopy::Label {
@@ -740,7 +732,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
                 let place_desc = &format!("`{}`", self.local_names[*local].unwrap());
 
                 if let Some(expr) = self.find_expr(binding_span) {
-                    self.suggest_cloning(err, bind_to.ty, expr, None, None);
+                    self.suggest_cloning(err, bind_to.ty, expr, None);
                 }
 
                 err.subdiagnostic(crate::session_diagnostics::TypeNoCopy::Label {
diff --git a/tests/ui/associated-types/associated-types-outlives.stderr b/tests/ui/associated-types/associated-types-outlives.stderr
index 1164869bf19..bd6022fcec6 100644
--- a/tests/ui/associated-types/associated-types-outlives.stderr
+++ b/tests/ui/associated-types/associated-types-outlives.stderr
@@ -18,7 +18,7 @@ LL | pub fn free_and_use<T: for<'a> Foo<'a>,
    |                     ^ consider constraining this type parameter with `Clone`
 ...
 LL |         's: loop { y = denormalise(&x); break }
-   |                                    -- you could clone this value
+   |                                     - you could clone this value
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/augmented-assignments.rs b/tests/ui/augmented-assignments.rs
index 8b263e03593..440a4a7fd65 100644
--- a/tests/ui/augmented-assignments.rs
+++ b/tests/ui/augmented-assignments.rs
@@ -17,7 +17,6 @@ fn main() {
     x;
     //~^ ERROR cannot move out of `x` because it is borrowed
     //~| move out of `x` occurs here
-    //~| HELP consider cloning
 
     let y = Int(2);
     //~^ HELP consider changing this to be mutable
diff --git a/tests/ui/augmented-assignments.stderr b/tests/ui/augmented-assignments.stderr
index 6b2900dd5d1..a4b75cbf6e8 100644
--- a/tests/ui/augmented-assignments.stderr
+++ b/tests/ui/augmented-assignments.stderr
@@ -8,14 +8,9 @@ LL |     x
 ...
 LL |     x;
    |     ^ move out of `x` occurs here
-   |
-help: consider cloning the value if the performance cost is acceptable
-   |
-LL |     x.clone();
-   |      ++++++++
 
 error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable
-  --> $DIR/augmented-assignments.rs:25:5
+  --> $DIR/augmented-assignments.rs:24:5
    |
 LL |     y
    |     ^ cannot borrow as mutable
diff --git a/tests/ui/binop/binop-move-semantics.stderr b/tests/ui/binop/binop-move-semantics.stderr
index 83c27590e90..45c7f110406 100644
--- a/tests/ui/binop/binop-move-semantics.stderr
+++ b/tests/ui/binop/binop-move-semantics.stderr
@@ -65,7 +65,7 @@ help: if `T` implemented `Clone`, you could clone the value
 LL | fn move_borrowed<T: Add<Output=()>>(x: T, mut y: T) {
    |                  ^ consider constraining this type parameter with `Clone`
 LL |     let m = &x;
-   |             -- you could clone this value
+   |              - you could clone this value
 
 error[E0505]: cannot move out of `y` because it is borrowed
   --> $DIR/binop-move-semantics.rs:23:5
@@ -88,7 +88,7 @@ LL | fn move_borrowed<T: Add<Output=()>>(x: T, mut y: T) {
    |                  ^ consider constraining this type parameter with `Clone`
 LL |     let m = &x;
 LL |     let n = &mut y;
-   |             ------ you could clone this value
+   |                  - you could clone this value
 
 error[E0507]: cannot move out of `*m` which is behind a mutable reference
   --> $DIR/binop-move-semantics.rs:30:5
diff --git a/tests/ui/borrowck/borrow-tuple-fields.stderr b/tests/ui/borrowck/borrow-tuple-fields.stderr
index 8ea7a9a4989..277c335cfcc 100644
--- a/tests/ui/borrowck/borrow-tuple-fields.stderr
+++ b/tests/ui/borrowck/borrow-tuple-fields.stderr
@@ -13,9 +13,8 @@ LL |     r.use_ref();
    |
 help: consider cloning the value if the performance cost is acceptable
    |
-LL -     let r = &x.0;
-LL +     let r = x.0.clone();
-   |
+LL |     let r = &x.0.clone();
+   |                 ++++++++
 
 error[E0502]: cannot borrow `x.0` as mutable because it is also borrowed as immutable
   --> $DIR/borrow-tuple-fields.rs:18:13
@@ -51,9 +50,8 @@ LL |     r.use_ref();
    |
 help: consider cloning the value if the performance cost is acceptable
    |
-LL -     let r = &x.0;
-LL +     let r = x.0.clone();
-   |
+LL |     let r = &x.0.clone();
+   |                 ++++++++
 
 error[E0502]: cannot borrow `x.0` as mutable because it is also borrowed as immutable
   --> $DIR/borrow-tuple-fields.rs:33:13
diff --git a/tests/ui/borrowck/borrowck-bad-nested-calls-move.stderr b/tests/ui/borrowck/borrowck-bad-nested-calls-move.stderr
index b96949fbb0e..5e7eee0422e 100644
--- a/tests/ui/borrowck/borrowck-bad-nested-calls-move.stderr
+++ b/tests/ui/borrowck/borrowck-bad-nested-calls-move.stderr
@@ -14,7 +14,7 @@ LL |         a);
 help: consider cloning the value if the performance cost is acceptable
    |
 LL -         &*a,
-LL +         a.clone(),
+LL +         &a.clone(),
    |
 
 error[E0505]: cannot move out of `a` because it is borrowed
@@ -32,7 +32,7 @@ LL |         a);
 help: consider cloning the value if the performance cost is acceptable
    |
 LL -         &*a,
-LL +         a.clone(),
+LL +         &a.clone(),
    |
 
 error: aborting due to 2 previous errors
diff --git a/tests/ui/borrowck/borrowck-field-sensitivity.stderr b/tests/ui/borrowck/borrowck-field-sensitivity.stderr
index ea552ff7820..b30dd144a4d 100644
--- a/tests/ui/borrowck/borrowck-field-sensitivity.stderr
+++ b/tests/ui/borrowck/borrowck-field-sensitivity.stderr
@@ -52,9 +52,8 @@ LL |     drop(**p);
    |
 help: consider cloning the value if the performance cost is acceptable
    |
-LL -     let p = &x.b;
-LL +     let p = x.b.clone();
-   |
+LL |     let p = &x.b.clone();
+   |                 ++++++++
 
 error[E0505]: cannot move out of `x.b` because it is borrowed
   --> $DIR/borrowck-field-sensitivity.rs:41:14
@@ -70,9 +69,8 @@ LL |     drop(**p);
    |
 help: consider cloning the value if the performance cost is acceptable
    |
-LL -     let p = &x.b;
-LL +     let p = x.b.clone();
-   |
+LL |     let p = &x.b.clone();
+   |                 ++++++++
 
 error[E0499]: cannot borrow `x.a` as mutable more than once at a time
   --> $DIR/borrowck-field-sensitivity.rs:48:13
diff --git a/tests/ui/borrowck/borrowck-issue-48962.stderr b/tests/ui/borrowck/borrowck-issue-48962.stderr
index 6e821a4c6b0..ee174f6736e 100644
--- a/tests/ui/borrowck/borrowck-issue-48962.stderr
+++ b/tests/ui/borrowck/borrowck-issue-48962.stderr
@@ -17,11 +17,6 @@ LL |     {src};
    |      --- value moved here
 LL |     src.0 = 66;
    |     ^^^^^^^^^^ value used here after move
-   |
-help: consider cloning the value if the performance cost is acceptable
-   |
-LL |     {src.clone()};
-   |         ++++++++
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/borrowck/borrowck-loan-blocks-move-cc.stderr b/tests/ui/borrowck/borrowck-loan-blocks-move-cc.stderr
index 370ae058f44..d9af5cf7d12 100644
--- a/tests/ui/borrowck/borrowck-loan-blocks-move-cc.stderr
+++ b/tests/ui/borrowck/borrowck-loan-blocks-move-cc.stderr
@@ -16,9 +16,8 @@ LL |     w.use_ref();
    |
 help: consider cloning the value if the performance cost is acceptable
    |
-LL -     let w = &v;
-LL +     let w = v.clone();
-   |
+LL |     let w = &v.clone();
+   |               ++++++++
 
 error[E0505]: cannot move out of `v` because it is borrowed
   --> $DIR/borrowck-loan-blocks-move-cc.rs:24:19
@@ -38,9 +37,8 @@ LL |     w.use_ref();
    |
 help: consider cloning the value if the performance cost is acceptable
    |
-LL -     let w = &v;
-LL +     let w = v.clone();
-   |
+LL |     let w = &v.clone();
+   |               ++++++++
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/borrowck/borrowck-loan-blocks-move.stderr b/tests/ui/borrowck/borrowck-loan-blocks-move.stderr
index 8a8005dbb83..1698035f20f 100644
--- a/tests/ui/borrowck/borrowck-loan-blocks-move.stderr
+++ b/tests/ui/borrowck/borrowck-loan-blocks-move.stderr
@@ -12,9 +12,8 @@ LL |     w.use_ref();
    |
 help: consider cloning the value if the performance cost is acceptable
    |
-LL -     let w = &v;
-LL +     let w = v.clone();
-   |
+LL |     let w = &v.clone();
+   |               ++++++++
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr b/tests/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr
index a23a203d999..b78c374c456 100644
--- a/tests/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr
+++ b/tests/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr
@@ -13,9 +13,8 @@ LL |     b.use_ref();
    |
 help: consider cloning the value if the performance cost is acceptable
    |
-LL -     let b = &a;
-LL +     let b = a.clone();
-   |
+LL |     let b = &a.clone();
+   |               ++++++++
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/borrowck/borrowck-move-mut-base-ptr.stderr b/tests/ui/borrowck/borrowck-move-mut-base-ptr.stderr
index acf426906c3..4b9351b64a0 100644
--- a/tests/ui/borrowck/borrowck-move-mut-base-ptr.stderr
+++ b/tests/ui/borrowck/borrowck-move-mut-base-ptr.stderr
@@ -14,7 +14,7 @@ LL |     p.use_ref();
 help: consider cloning the value if the performance cost is acceptable
    |
 LL -     let p: &isize = &*t0; // Freezes `*t0`
-LL +     let p: &isize = t0.clone(); // Freezes `*t0`
+LL +     let p: &isize = &t0.clone(); // Freezes `*t0`
    |
 
 error: aborting due to 1 previous error
diff --git a/tests/ui/borrowck/borrowck-move-subcomponent.stderr b/tests/ui/borrowck/borrowck-move-subcomponent.stderr
index cc6c3bdeb10..b5dc01f180b 100644
--- a/tests/ui/borrowck/borrowck-move-subcomponent.stderr
+++ b/tests/ui/borrowck/borrowck-move-subcomponent.stderr
@@ -17,7 +17,7 @@ LL | struct S {
    | ^^^^^^^^ consider implementing `Clone` for this type
 ...
 LL |   let pb = &a;
-   |            -- you could clone this value
+   |             - you could clone this value
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/borrowck/borrowck-multiple-captures.stderr b/tests/ui/borrowck/borrowck-multiple-captures.stderr
index fdac4c27cee..01b648ea647 100644
--- a/tests/ui/borrowck/borrowck-multiple-captures.stderr
+++ b/tests/ui/borrowck/borrowck-multiple-captures.stderr
@@ -17,9 +17,8 @@ LL |     borrow(&*p1);
    |
 help: consider cloning the value if the performance cost is acceptable
    |
-LL -     let p1 = &x1;
-LL +     let p1 = x1.clone();
-   |
+LL |     let p1 = &x1.clone();
+   |                 ++++++++
 
 error[E0505]: cannot move out of `x2` because it is borrowed
   --> $DIR/borrowck-multiple-captures.rs:12:19
@@ -39,9 +38,8 @@ LL |     borrow(&*p2);
    |
 help: consider cloning the value if the performance cost is acceptable
    |
-LL -     let p2 = &x2;
-LL +     let p2 = x2.clone();
-   |
+LL |     let p2 = &x2.clone();
+   |                 ++++++++
 
 error[E0382]: use of moved value: `x1`
   --> $DIR/borrowck-multiple-captures.rs:27:19
@@ -108,9 +106,8 @@ LL |     borrow(&*p);
    |
 help: consider cloning the value if the performance cost is acceptable
    |
-LL -     let p = &x;
-LL +     let p = x.clone();
-   |
+LL |     let p = &x.clone();
+   |               ++++++++
 
 error[E0382]: use of moved value: `x`
   --> $DIR/borrowck-multiple-captures.rs:52:14
diff --git a/tests/ui/borrowck/borrowck-overloaded-index-move-index.stderr b/tests/ui/borrowck/borrowck-overloaded-index-move-index.stderr
index 7f8cc74a715..3366853b8e2 100644
--- a/tests/ui/borrowck/borrowck-overloaded-index-move-index.stderr
+++ b/tests/ui/borrowck/borrowck-overloaded-index-move-index.stderr
@@ -11,6 +11,11 @@ LL |     println!("{}", f[s]);
 ...
 LL |     use_mut(rs);
    |             -- borrow later used here
+   |
+help: consider cloning the value if the performance cost is acceptable
+   |
+LL |     let rs = &mut s.clone();
+   |                    ++++++++
 
 error[E0505]: cannot move out of `s` because it is borrowed
   --> $DIR/borrowck-overloaded-index-move-index.rs:53:7
@@ -25,6 +30,11 @@ LL |     f[s] = 10;
 ...
 LL |     use_mut(rs);
    |             -- borrow later used here
+   |
+help: consider cloning the value if the performance cost is acceptable
+   |
+LL |     let rs = &mut s.clone();
+   |                    ++++++++
 
 error[E0382]: use of moved value: `s`
   --> $DIR/borrowck-overloaded-index-move-index.rs:53:7
diff --git a/tests/ui/borrowck/borrowck-unary-move.stderr b/tests/ui/borrowck/borrowck-unary-move.stderr
index 598ecb53778..0aec6d42630 100644
--- a/tests/ui/borrowck/borrowck-unary-move.stderr
+++ b/tests/ui/borrowck/borrowck-unary-move.stderr
@@ -13,7 +13,7 @@ LL |     *y
 help: consider cloning the value if the performance cost is acceptable
    |
 LL -     let y = &*x;
-LL +     let y = x.clone();
+LL +     let y = &x.clone();
    |
 
 error: aborting due to 1 previous error
diff --git a/tests/ui/borrowck/clone-on-ref.stderr b/tests/ui/borrowck/clone-on-ref.stderr
index 19f040556f8..d5d21296a3f 100644
--- a/tests/ui/borrowck/clone-on-ref.stderr
+++ b/tests/ui/borrowck/clone-on-ref.stderr
@@ -38,7 +38,7 @@ help: if `T` implemented `Clone`, you could clone the value
 LL | fn bar<T: std::fmt::Display>(x: T) {
    |        ^ consider constraining this type parameter with `Clone`
 LL |     let a = &x;
-   |             -- you could clone this value
+   |              - you could clone this value
 help: consider further restricting this bound
    |
 LL | fn bar<T: std::fmt::Display + Clone>(x: T) {
@@ -66,7 +66,7 @@ LL | struct A;
    | ^^^^^^^^ consider implementing `Clone` for this type
 LL | fn qux(x: A) {
 LL |     let a = &x;
-   |             -- you could clone this value
+   |              - you could clone this value
 help: consider annotating `A` with `#[derive(Clone)]`
    |
 LL + #[derive(Clone)]
diff --git a/tests/ui/borrowck/issue-101119.stderr b/tests/ui/borrowck/issue-101119.stderr
index a894fa63ace..7fec81b59b3 100644
--- a/tests/ui/borrowck/issue-101119.stderr
+++ b/tests/ui/borrowck/issue-101119.stderr
@@ -18,14 +18,6 @@ LL | fn fill_segment(_: &mut State) {}
    |    ------------    ^^^^^^^^^^ this parameter takes ownership of the value
    |    |
    |    in this function
-note: if `State` implemented `Clone`, you could clone the value
-  --> $DIR/issue-101119.rs:1:1
-   |
-LL | struct State;
-   | ^^^^^^^^^^^^ consider implementing `Clone` for this type
-...
-LL |             fill_segment(state);
-   |                          ----- you could clone this value
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/btreemap/btreemap_dropck.stderr b/tests/ui/btreemap/btreemap_dropck.stderr
index 873f8cf9a01..e8f14552af2 100644
--- a/tests/ui/btreemap/btreemap_dropck.stderr
+++ b/tests/ui/btreemap/btreemap_dropck.stderr
@@ -12,9 +12,8 @@ LL | }
    |
 help: consider cloning the value if the performance cost is acceptable
    |
-LL -     let _map = BTreeMap::from_iter([((), PrintOnDrop(&s))]);
-LL +     let _map = BTreeMap::from_iter([((), PrintOnDrop(s.clone()))]);
-   |
+LL |     let _map = BTreeMap::from_iter([((), PrintOnDrop(&s.clone()))]);
+   |                                                        ++++++++
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/dropck/drop-with-active-borrows-1.stderr b/tests/ui/dropck/drop-with-active-borrows-1.stderr
index 7d1633267f0..229514c6fee 100644
--- a/tests/ui/dropck/drop-with-active-borrows-1.stderr
+++ b/tests/ui/dropck/drop-with-active-borrows-1.stderr
@@ -9,11 +9,6 @@ LL |     drop(a);
    |          ^ move out of `a` occurs here
 LL |     for s in &b {
    |              -- borrow later used here
-   |
-help: consider cloning the value if the performance cost is acceptable
-   |
-LL |     let b: Vec<&str> = a.clone().lines().collect();
-   |                         ++++++++
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/error-codes/E0504.stderr b/tests/ui/error-codes/E0504.stderr
index 343bca9a72e..58266959333 100644
--- a/tests/ui/error-codes/E0504.stderr
+++ b/tests/ui/error-codes/E0504.stderr
@@ -21,7 +21,7 @@ LL | struct FancyNum {
    | ^^^^^^^^^^^^^^^ consider implementing `Clone` for this type
 ...
 LL |     let fancy_ref = &fancy_num;
-   |                     ---------- you could clone this value
+   |                      --------- you could clone this value
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/error-codes/E0505.stderr b/tests/ui/error-codes/E0505.stderr
index 266df9ea32a..3f2913e9fe3 100644
--- a/tests/ui/error-codes/E0505.stderr
+++ b/tests/ui/error-codes/E0505.stderr
@@ -18,7 +18,7 @@ LL | struct Value {}
    | ^^^^^^^^^^^^ consider implementing `Clone` for this type
 ...
 LL |         let _ref_to_val: &Value = &x;
-   |                                   -- you could clone this value
+   |                                    - you could clone this value
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/fn/implied-bounds-unnorm-associated-type-4.stderr b/tests/ui/fn/implied-bounds-unnorm-associated-type-4.stderr
index b8ec2e3b7e7..4e64ed6f482 100644
--- a/tests/ui/fn/implied-bounds-unnorm-associated-type-4.stderr
+++ b/tests/ui/fn/implied-bounds-unnorm-associated-type-4.stderr
@@ -13,9 +13,8 @@ LL |     println!("{}", y);
    |
 help: consider cloning the value if the performance cost is acceptable
    |
-LL -     let y = f(&x, ());
-LL +     let y = f(x.clone(), ());
-   |
+LL |     let y = f(&x.clone(), ());
+   |                 ++++++++
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/fn/implied-bounds-unnorm-associated-type-5.stderr b/tests/ui/fn/implied-bounds-unnorm-associated-type-5.stderr
index 382ab8636a2..b898df0835c 100644
--- a/tests/ui/fn/implied-bounds-unnorm-associated-type-5.stderr
+++ b/tests/ui/fn/implied-bounds-unnorm-associated-type-5.stderr
@@ -30,9 +30,8 @@ LL |     println!("{}", y);
    |
 help: consider cloning the value if the performance cost is acceptable
    |
-LL -     let y = f(&x, ());
-LL +     let y = f(x.clone(), ());
-   |
+LL |     let y = f(&x.clone(), ());
+   |                 ++++++++
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/fn/implied-bounds-unnorm-associated-type.stderr b/tests/ui/fn/implied-bounds-unnorm-associated-type.stderr
index ce97d8527e8..2a7431305fe 100644
--- a/tests/ui/fn/implied-bounds-unnorm-associated-type.stderr
+++ b/tests/ui/fn/implied-bounds-unnorm-associated-type.stderr
@@ -13,9 +13,8 @@ LL |     println!("{}", y);
    |
 help: consider cloning the value if the performance cost is acceptable
    |
-LL -     let y = f(&x, ());
-LL +     let y = f(x.clone(), ());
-   |
+LL |     let y = f(&x.clone(), ());
+   |                 ++++++++
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/moves/move-fn-self-receiver.stderr b/tests/ui/moves/move-fn-self-receiver.stderr
index f2c6008d27e..de19a99d388 100644
--- a/tests/ui/moves/move-fn-self-receiver.stderr
+++ b/tests/ui/moves/move-fn-self-receiver.stderr
@@ -101,15 +101,6 @@ LL |     mut_foo;
    |     ^^^^^^^ move out of `mut_foo` occurs here
 LL |     ret;
    |     --- borrow later used here
-   |
-note: if `Foo` implemented `Clone`, you could clone the value
-  --> $DIR/move-fn-self-receiver.rs:5:1
-   |
-LL | struct Foo;
-   | ^^^^^^^^^^ consider implementing `Clone` for this type
-...
-LL |     let ret = mut_foo.use_mut_self();
-   |               ------- you could clone this value
 
 error[E0382]: use of moved value: `rc_foo`
   --> $DIR/move-fn-self-receiver.rs:55:5
diff --git a/tests/ui/nll/closure-access-spans.stderr b/tests/ui/nll/closure-access-spans.stderr
index f789e5e9f95..a8024a8c20b 100644
--- a/tests/ui/nll/closure-access-spans.stderr
+++ b/tests/ui/nll/closure-access-spans.stderr
@@ -60,9 +60,8 @@ LL |     r.use_ref();
    |
 help: consider cloning the value if the performance cost is acceptable
    |
-LL -     let r = &x;
-LL +     let r = x.clone();
-   |
+LL |     let r = &x.clone();
+   |               ++++++++
 
 error[E0382]: borrow of moved value: `x`
   --> $DIR/closure-access-spans.rs:35:5
@@ -109,11 +108,6 @@ LL |     || *x = String::new();
    |     ^^ -- borrow occurs due to use in closure
    |     |
    |     value borrowed here after move
-   |
-help: consider cloning the value if the performance cost is acceptable
-   |
-LL |     let r = x.clone();
-   |              ++++++++
 
 error[E0382]: use of moved value: `x`
   --> $DIR/closure-access-spans.rs:50:5
@@ -126,11 +120,6 @@ LL |     || x;
    |     ^^ - use occurs due to use in closure
    |     |
    |     value used here after move
-   |
-help: consider cloning the value if the performance cost is acceptable
-   |
-LL |     let r = x.clone();
-   |              ++++++++
 
 error: aborting due to 9 previous errors
 
diff --git a/tests/ui/nll/issue-27282-move-match-input-into-guard.stderr b/tests/ui/nll/issue-27282-move-match-input-into-guard.stderr
index 39ec45b20ea..ae797800457 100644
--- a/tests/ui/nll/issue-27282-move-match-input-into-guard.stderr
+++ b/tests/ui/nll/issue-27282-move-match-input-into-guard.stderr
@@ -10,11 +10,6 @@ LL |         _ if { (|| { let bar = b; *bar = false; })();
    |                 --             - variable moved due to use in closure
    |                 |
    |                 value moved into closure here
-   |
-help: consider cloning the value if the performance cost is acceptable
-   |
-LL |         _ if { (|| { let bar = b.clone(); *bar = false; })();
-   |                                 ++++++++
 
 error[E0382]: use of moved value: `b`
   --> $DIR/issue-27282-move-match-input-into-guard.rs:24:5
@@ -28,11 +23,6 @@ LL |             (|| { let bar = b; *bar = false; })();
    |              --             - variable moved due to use in closure
    |              |
    |              value moved into closure here
-   |
-help: consider cloning the value if the performance cost is acceptable
-   |
-LL |             (|| { let bar = b.clone(); *bar = false; })();
-   |                              ++++++++
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/nll/issue-27282-move-ref-mut-into-guard.fixed b/tests/ui/nll/issue-27282-move-ref-mut-into-guard.fixed
deleted file mode 100644
index 7692be7ccc8..00000000000
--- a/tests/ui/nll/issue-27282-move-ref-mut-into-guard.fixed
+++ /dev/null
@@ -1,23 +0,0 @@
-// Issue 27282: Example 1: This sidesteps the AST checks disallowing
-// mutable borrows in match guards by hiding the mutable borrow in a
-// guard behind a move (of the ref mut pattern id) within a closure.
-//@ run-rustfix
-#![feature(if_let_guard)]
-
-fn main() {
-    match Some(&4) {
-        None => {},
-        ref mut foo
-            if { (|| { let mut bar = foo.clone(); bar.take() })(); false } => {},
-        //~^ ERROR cannot move out of `foo` in pattern guard [E0507]
-        Some(s) => std::process::exit(*s),
-    }
-
-    match Some(&4) {
-        None => {},
-        ref mut foo
-            if let Some(()) = { (|| { let mut bar = foo.clone(); bar.take() })(); None } => {},
-        //~^ ERROR cannot move out of `foo` in pattern guard [E0507]
-        Some(s) => std::process::exit(*s),
-    }
-}
diff --git a/tests/ui/nll/issue-27282-move-ref-mut-into-guard.rs b/tests/ui/nll/issue-27282-move-ref-mut-into-guard.rs
index f3d0a184e03..c3b19886a50 100644
--- a/tests/ui/nll/issue-27282-move-ref-mut-into-guard.rs
+++ b/tests/ui/nll/issue-27282-move-ref-mut-into-guard.rs
@@ -1,7 +1,7 @@
 // Issue 27282: Example 1: This sidesteps the AST checks disallowing
 // mutable borrows in match guards by hiding the mutable borrow in a
 // guard behind a move (of the ref mut pattern id) within a closure.
-//@ run-rustfix
+
 #![feature(if_let_guard)]
 
 fn main() {
diff --git a/tests/ui/nll/issue-27282-move-ref-mut-into-guard.stderr b/tests/ui/nll/issue-27282-move-ref-mut-into-guard.stderr
index 7781e77894b..e790fda4d7c 100644
--- a/tests/ui/nll/issue-27282-move-ref-mut-into-guard.stderr
+++ b/tests/ui/nll/issue-27282-move-ref-mut-into-guard.stderr
@@ -7,10 +7,6 @@ LL |             if { (|| { let mut bar = foo; bar.take() })(); false } => {},
    |                   `foo` is moved here
    |
    = note: variables bound in patterns cannot be moved from until after the end of the pattern guard
-help: consider cloning the value if the performance cost is acceptable
-   |
-LL |             if { (|| { let mut bar = foo.clone(); bar.take() })(); false } => {},
-   |                                         ++++++++
 
 error[E0507]: cannot move out of `foo` in pattern guard
   --> $DIR/issue-27282-move-ref-mut-into-guard.rs:19:34
@@ -21,10 +17,6 @@ LL |             if let Some(()) = { (|| { let mut bar = foo; bar.take() })(); N
    |                                  `foo` is moved here
    |
    = note: variables bound in patterns cannot be moved from until after the end of the pattern guard
-help: consider cloning the value if the performance cost is acceptable
-   |
-LL |             if let Some(()) = { (|| { let mut bar = foo.clone(); bar.take() })(); None } => {},
-   |                                                        ++++++++
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/nll/issue-27282-mutation-in-guard.stderr b/tests/ui/nll/issue-27282-mutation-in-guard.stderr
index f73e4aaa489..0b5d723172c 100644
--- a/tests/ui/nll/issue-27282-mutation-in-guard.stderr
+++ b/tests/ui/nll/issue-27282-mutation-in-guard.stderr
@@ -7,10 +7,6 @@ LL |                 (|| { let bar = foo; bar.take() })();
    |                  `foo` is moved here
    |
    = note: variables bound in patterns cannot be moved from until after the end of the pattern guard
-help: consider cloning the value if the performance cost is acceptable
-   |
-LL |                 (|| { let bar = foo.clone(); bar.take() })();
-   |                                    ++++++++
 
 error[E0507]: cannot move out of `foo` in pattern guard
   --> $DIR/issue-27282-mutation-in-guard.rs:20:18
@@ -21,10 +17,6 @@ LL |                 (|| { let bar = foo; bar.take() })();
    |                  `foo` is moved here
    |
    = note: variables bound in patterns cannot be moved from until after the end of the pattern guard
-help: consider cloning the value if the performance cost is acceptable
-   |
-LL |                 (|| { let bar = foo.clone(); bar.take() })();
-   |                                    ++++++++
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/nll/issue-52059-report-when-borrow-and-drop-conflict.stderr b/tests/ui/nll/issue-52059-report-when-borrow-and-drop-conflict.stderr
index f4e7869bf00..7f9cbc3c30a 100644
--- a/tests/ui/nll/issue-52059-report-when-borrow-and-drop-conflict.stderr
+++ b/tests/ui/nll/issue-52059-report-when-borrow-and-drop-conflict.stderr
@@ -41,10 +41,6 @@ help: consider borrowing here
    |
 LL |     let p = &s.url; p
    |             +
-help: consider cloning the value if the performance cost is acceptable
-   |
-LL |     let p = s.url.clone(); p
-   |                  ++++++++
 
 error: aborting due to 4 previous errors
 
diff --git a/tests/ui/nll/match-guards-always-borrow.fixed b/tests/ui/nll/match-guards-always-borrow.fixed
deleted file mode 100644
index 56e743bf196..00000000000
--- a/tests/ui/nll/match-guards-always-borrow.fixed
+++ /dev/null
@@ -1,66 +0,0 @@
-#![feature(if_let_guard)]
-#![allow(unused_mut)]
-//@ run-rustfix
-
-// Here is arielb1's basic example from rust-lang/rust#27282
-// that AST borrowck is flummoxed by:
-
-fn should_reject_destructive_mutate_in_guard() {
-    match Some(&4) {
-        None => {},
-        ref mut foo if {
-            (|| { let mut bar = foo.clone(); bar.take() })();
-            //~^ ERROR cannot move out of `foo` in pattern guard [E0507]
-            false } => { },
-        Some(s) => std::process::exit(*s),
-    }
-
-    match Some(&4) {
-        None => {},
-        ref mut foo if let Some(()) = {
-            (|| { let mut bar = foo.clone(); bar.take() })();
-            //~^ ERROR cannot move out of `foo` in pattern guard [E0507]
-            None } => { },
-        Some(s) => std::process::exit(*s),
-    }
-}
-
-// Here below is a case that needs to keep working: we only use the
-// binding via immutable-borrow in the guard, and we mutate in the arm
-// body.
-fn allow_mutate_in_arm_body() {
-    match Some(&4) {
-        None => {},
-        ref mut foo if foo.is_some() => { foo.take(); () }
-        Some(s) => std::process::exit(*s),
-    }
-
-    match Some(&4) {
-        None => {},
-        ref mut foo if let Some(_) = foo => { foo.take(); () }
-        Some(s) => std::process::exit(*s),
-    }
-}
-
-// Here below is a case that needs to keep working: we only use the
-// binding via immutable-borrow in the guard, and we move into the arm
-// body.
-fn allow_move_into_arm_body() {
-    match Some(&4) {
-        None => {},
-        mut foo if foo.is_some() => { foo.unwrap(); () }
-        Some(s) => std::process::exit(*s),
-    }
-
-    match Some(&4) {
-        None => {},
-        mut foo if let Some(_) = foo => { foo.unwrap(); () }
-        Some(s) => std::process::exit(*s),
-    }
-}
-
-fn main() {
-    should_reject_destructive_mutate_in_guard();
-    allow_mutate_in_arm_body();
-    allow_move_into_arm_body();
-}
diff --git a/tests/ui/nll/match-guards-always-borrow.rs b/tests/ui/nll/match-guards-always-borrow.rs
index 927d55c42a6..5271e3cfc66 100644
--- a/tests/ui/nll/match-guards-always-borrow.rs
+++ b/tests/ui/nll/match-guards-always-borrow.rs
@@ -1,6 +1,5 @@
 #![feature(if_let_guard)]
 #![allow(unused_mut)]
-//@ run-rustfix
 
 // Here is arielb1's basic example from rust-lang/rust#27282
 // that AST borrowck is flummoxed by:
diff --git a/tests/ui/nll/match-guards-always-borrow.stderr b/tests/ui/nll/match-guards-always-borrow.stderr
index bb0c5bd4c97..71977bd8472 100644
--- a/tests/ui/nll/match-guards-always-borrow.stderr
+++ b/tests/ui/nll/match-guards-always-borrow.stderr
@@ -1,5 +1,5 @@
 error[E0507]: cannot move out of `foo` in pattern guard
-  --> $DIR/match-guards-always-borrow.rs:12:14
+  --> $DIR/match-guards-always-borrow.rs:11:14
    |
 LL |             (|| { let mut bar = foo; bar.take() })();
    |              ^^                 --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait
@@ -7,13 +7,9 @@ LL |             (|| { let mut bar = foo; bar.take() })();
    |              `foo` is moved here
    |
    = note: variables bound in patterns cannot be moved from until after the end of the pattern guard
-help: consider cloning the value if the performance cost is acceptable
-   |
-LL |             (|| { let mut bar = foo.clone(); bar.take() })();
-   |                                    ++++++++
 
 error[E0507]: cannot move out of `foo` in pattern guard
-  --> $DIR/match-guards-always-borrow.rs:21:14
+  --> $DIR/match-guards-always-borrow.rs:20:14
    |
 LL |             (|| { let mut bar = foo; bar.take() })();
    |              ^^                 --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait
@@ -21,10 +17,6 @@ LL |             (|| { let mut bar = foo; bar.take() })();
    |              `foo` is moved here
    |
    = note: variables bound in patterns cannot be moved from until after the end of the pattern guard
-help: consider cloning the value if the performance cost is acceptable
-   |
-LL |             (|| { let mut bar = foo.clone(); bar.take() })();
-   |                                    ++++++++
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/nll/polonius/polonius-smoke-test.stderr b/tests/ui/nll/polonius/polonius-smoke-test.stderr
index 534813b2d9f..a8a8267290d 100644
--- a/tests/ui/nll/polonius/polonius-smoke-test.stderr
+++ b/tests/ui/nll/polonius/polonius-smoke-test.stderr
@@ -27,6 +27,12 @@ LL |     let z = x;
    |             ^ move out of `x` occurs here
 LL |     y
    |     - returning this value requires that `*x` is borrowed for `'1`
+   |
+help: consider cloning the value if the performance cost is acceptable
+   |
+LL -     let y = &mut *x;
+LL +     let y = &mut x.clone();
+   |
 
 error[E0505]: cannot move out of `s` because it is borrowed
   --> $DIR/polonius-smoke-test.rs:42:5
@@ -40,6 +46,12 @@ LL |     s;
    |     ^ move out of `s` occurs here
 LL |     tmp;
    |     --- borrow later used here
+   |
+help: consider cloning the value if the performance cost is acceptable
+   |
+LL -     let r = &mut *s;
+LL +     let r = &mut s.clone();
+   |
 
 error: aborting due to 4 previous errors
 
diff --git a/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr b/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr
index e925fe78f33..9359244c6eb 100644
--- a/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr
+++ b/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr
@@ -333,14 +333,6 @@ LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false
    |                                                                  ^ move occurs because `b` has type `&mut U`, which does not implement the `Copy` trait
    |
    = note: variables bound in patterns cannot be moved from until after the end of the pattern guard
-note: if `U` implemented `Clone`, you could clone the value
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:17:5
-   |
-LL |     struct U;
-   |     ^^^^^^^^ consider implementing `Clone` for this type
-...
-LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {}
-   |                                                                  - you could clone this value
 
 error[E0507]: cannot move out of `b` in pattern guard
   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:103:66
@@ -349,14 +341,6 @@ LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false
    |                                                                  ^ move occurs because `b` has type `&mut U`, which does not implement the `Copy` trait
    |
    = note: variables bound in patterns cannot be moved from until after the end of the pattern guard
-note: if `U` implemented `Clone`, you could clone the value
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:17:5
-   |
-LL |     struct U;
-   |     ^^^^^^^^ consider implementing `Clone` for this type
-...
-LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {}
-   |                                                                  - you could clone this value
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error[E0507]: cannot move out of `a` in pattern guard
diff --git a/tests/ui/span/send-is-not-static-std-sync.stderr b/tests/ui/span/send-is-not-static-std-sync.stderr
index 50b8ffe0114..6bc3ed8d24f 100644
--- a/tests/ui/span/send-is-not-static-std-sync.stderr
+++ b/tests/ui/span/send-is-not-static-std-sync.stderr
@@ -15,7 +15,7 @@ LL |         *lock.lock().unwrap() = &z;
 help: consider cloning the value if the performance cost is acceptable
    |
 LL -     *lock.lock().unwrap() = &*y;
-LL +     *lock.lock().unwrap() = y.clone();
+LL +     *lock.lock().unwrap() = &y.clone();
    |
 
 error[E0597]: `z` does not live long enough
@@ -48,7 +48,7 @@ LL |         *lock.write().unwrap() = &z;
 help: consider cloning the value if the performance cost is acceptable
    |
 LL -     *lock.write().unwrap() = &*y;
-LL +     *lock.write().unwrap() = y.clone();
+LL +     *lock.write().unwrap() = &y.clone();
    |
 
 error[E0597]: `z` does not live long enough
@@ -81,7 +81,7 @@ LL |         tx.send(&z).unwrap();
 help: consider cloning the value if the performance cost is acceptable
    |
 LL -     tx.send(&*y);
-LL +     tx.send(y.clone());
+LL +     tx.send(&y.clone());
    |
 
 error[E0597]: `z` does not live long enough
diff --git a/tests/ui/suggestions/borrow-for-loop-head.stderr b/tests/ui/suggestions/borrow-for-loop-head.stderr
index a8de9986c31..55fcb44168c 100644
--- a/tests/ui/suggestions/borrow-for-loop-head.stderr
+++ b/tests/ui/suggestions/borrow-for-loop-head.stderr
@@ -10,9 +10,8 @@ LL |         for j in a {
    |
 help: consider cloning the value if the performance cost is acceptable
    |
-LL -     for i in &a {
-LL +     for i in a.clone() {
-   |
+LL |     for i in &a.clone() {
+   |                ++++++++
 
 error[E0382]: use of moved value: `a`
   --> $DIR/borrow-for-loop-head.rs:4:18
diff --git a/tests/ui/try-block/try-block-bad-lifetime.stderr b/tests/ui/try-block/try-block-bad-lifetime.stderr
index 6f693295357..28941cb0a9e 100644
--- a/tests/ui/try-block/try-block-bad-lifetime.stderr
+++ b/tests/ui/try-block/try-block-bad-lifetime.stderr
@@ -34,11 +34,6 @@ LL |             Err(k) ?;
 ...
 LL |         ::std::mem::drop(k);
    |                          ^ value used here after move
-   |
-help: consider cloning the value if the performance cost is acceptable
-   |
-LL |             Err(k.clone()) ?;
-   |                  ++++++++
 
 error[E0506]: cannot assign to `i` because it is borrowed
   --> $DIR/try-block-bad-lifetime.rs:32:9
diff --git a/tests/ui/unop/unop-move-semantics.stderr b/tests/ui/unop/unop-move-semantics.stderr
index bc9b3ea9903..0ae918d434a 100644
--- a/tests/ui/unop/unop-move-semantics.stderr
+++ b/tests/ui/unop/unop-move-semantics.stderr
@@ -40,7 +40,7 @@ help: if `T` implemented `Clone`, you could clone the value
 LL | fn move_borrowed<T: Not<Output=T>>(x: T, mut y: T) {
    |                  ^ consider constraining this type parameter with `Clone`
 LL |     let m = &x;
-   |             -- you could clone this value
+   |              - you could clone this value
 
 error[E0505]: cannot move out of `y` because it is borrowed
   --> $DIR/unop-move-semantics.rs:17:6
@@ -63,7 +63,7 @@ LL | fn move_borrowed<T: Not<Output=T>>(x: T, mut y: T) {
    |                  ^ consider constraining this type parameter with `Clone`
 LL |     let m = &x;
 LL |     let n = &mut y;
-   |             ------ you could clone this value
+   |                  - you could clone this value
 
 error[E0507]: cannot move out of `*m` which is behind a mutable reference
   --> $DIR/unop-move-semantics.rs:24:6
diff --git a/tests/ui/variance/variance-issue-20533.stderr b/tests/ui/variance/variance-issue-20533.stderr
index 0a810b7222e..21d8de6ae88 100644
--- a/tests/ui/variance/variance-issue-20533.stderr
+++ b/tests/ui/variance/variance-issue-20533.stderr
@@ -17,7 +17,7 @@ LL | struct AffineU32(u32);
    | ^^^^^^^^^^^^^^^^ consider implementing `Clone` for this type
 ...
 LL |         let x = foo(&a);
-   |                     -- you could clone this value
+   |                      - you could clone this value
 
 error[E0505]: cannot move out of `a` because it is borrowed
   --> $DIR/variance-issue-20533.rs:41:14
@@ -38,7 +38,7 @@ LL | struct AffineU32(u32);
    | ^^^^^^^^^^^^^^^^ consider implementing `Clone` for this type
 ...
 LL |         let x = bar(&a);
-   |                     -- you could clone this value
+   |                      - you could clone this value
 
 error[E0505]: cannot move out of `a` because it is borrowed
   --> $DIR/variance-issue-20533.rs:47:14
@@ -59,7 +59,7 @@ LL | struct AffineU32(u32);
    | ^^^^^^^^^^^^^^^^ consider implementing `Clone` for this type
 ...
 LL |         let x = baz(&a);
-   |                     -- you could clone this value
+   |                      - you could clone this value
 
 error[E0505]: cannot move out of `a` because it is borrowed
   --> $DIR/variance-issue-20533.rs:53:14
@@ -80,7 +80,7 @@ LL | struct AffineU32(u32);
    | ^^^^^^^^^^^^^^^^ consider implementing `Clone` for this type
 ...
 LL |         let x = bat(&a);
-   |                     -- you could clone this value
+   |                      - you could clone this value
 
 error[E0505]: cannot move out of `a` because it is borrowed
   --> $DIR/variance-issue-20533.rs:59:14
@@ -96,9 +96,8 @@ LL |         drop(x);
    |
 help: consider cloning the value if the performance cost is acceptable
    |
-LL -         let x = foo(&a);
-LL +         let x = foo(a.clone());
-   |
+LL |         let x = foo(&a.clone());
+   |                       ++++++++
 
 error: aborting due to 5 previous errors