about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2024-07-03 21:01:29 +0000
committerEsteban Küber <esteban@kuber.com.ar>2024-07-04 02:02:21 +0000
commit89ecae5d852a7346ee4e8240ae7a1130f1f6f458 (patch)
tree643e792c20fc69961e958b4312d0decba09a6d17
parent140392b0418825c77ba68ab693dc18494ab27405 (diff)
downloadrust-89ecae5d852a7346ee4e8240ae7a1130f1f6f458.tar.gz
rust-89ecae5d852a7346ee4e8240ae7a1130f1f6f458.zip
Better span for "make binding mutable" suggestion
-rw-r--r--compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs25
-rw-r--r--tests/ui/assign-imm-local-twice.rs2
-rw-r--r--tests/ui/assign-imm-local-twice.stderr8
-rw-r--r--tests/ui/async-await/issue-61452.stderr10
-rw-r--r--tests/ui/borrowck/borrowck-match-binding-is-assignment.stderr20
-rw-r--r--tests/ui/borrowck/immutable-arg.stderr7
-rw-r--r--tests/ui/borrowck/issue-45199.rs6
-rw-r--r--tests/ui/borrowck/issue-45199.stderr26
-rw-r--r--tests/ui/borrowck/suggest-ref-mut-issue-118596.stderr8
-rw-r--r--tests/ui/borrowck/tainted-promoteds.stderr10
-rw-r--r--tests/ui/command-line-diagnostics.stderr10
-rw-r--r--tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.stderr7
-rw-r--r--tests/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.stderr32
-rw-r--r--tests/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.rs2
-rw-r--r--tests/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.stderr8
-rw-r--r--tests/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.rs2
-rw-r--r--tests/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.stderr8
-rw-r--r--tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.rs2
-rw-r--r--tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.stderr10
-rw-r--r--tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.rs2
-rw-r--r--tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.stderr10
-rw-r--r--tests/ui/mut/mut-pattern-internal-mutability.stderr4
-rw-r--r--tests/ui/pattern/bindings-after-at/pat-at-same-name-both.stderr4
-rw-r--r--tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr8
-rw-r--r--tests/ui/pattern/mut-ref-mut-2021.stderr4
25 files changed, 134 insertions, 101 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
index 7ef53fa2078..e291ebd9bb8 100644
--- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
@@ -3757,13 +3757,11 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
         assigned_span: Span,
         err_place: Place<'tcx>,
     ) {
-        let (from_arg, local_decl, local_name) = match err_place.as_local() {
-            Some(local) => (
-                self.body.local_kind(local) == LocalKind::Arg,
-                Some(&self.body.local_decls[local]),
-                self.local_names[local],
-            ),
-            None => (false, None, None),
+        let (from_arg, local_decl) = match err_place.as_local() {
+            Some(local) => {
+                (self.body.local_kind(local) == LocalKind::Arg, Some(&self.body.local_decls[local]))
+            }
+            None => (false, None),
         };
 
         // If root local is initialized immediately (everything apart from let
@@ -3795,13 +3793,12 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
             err.span_label(assigned_span, format!("first assignment to {place_description}"));
         }
         if let Some(decl) = local_decl
-            && let Some(name) = local_name
             && decl.can_be_made_mutable()
         {
-            err.span_suggestion(
-                decl.source_info.span,
+            err.span_suggestion_verbose(
+                decl.source_info.span.shrink_to_lo(),
                 "consider making this binding mutable",
-                format!("mut {name}"),
+                "mut ".to_string(),
                 Applicability::MachineApplicable,
             );
             if !from_arg
@@ -3813,10 +3810,10 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
                     }))
                 )
             {
-                err.span_suggestion(
-                    decl.source_info.span,
+                err.span_suggestion_verbose(
+                    decl.source_info.span.shrink_to_lo(),
                     "to modify the original value, take a borrow instead",
-                    format!("ref mut {name}"),
+                    "ref mut ".to_string(),
                     Applicability::MaybeIncorrect,
                 );
             }
diff --git a/tests/ui/assign-imm-local-twice.rs b/tests/ui/assign-imm-local-twice.rs
index b50f6ab5deb..b2dfeb564d9 100644
--- a/tests/ui/assign-imm-local-twice.rs
+++ b/tests/ui/assign-imm-local-twice.rs
@@ -1,7 +1,7 @@
 fn test() {
     let v: isize;
     //~^ HELP consider making this binding mutable
-    //~| SUGGESTION mut v
+    //~| SUGGESTION mut
     v = 1; //~ NOTE first assignment
     println!("v={}", v);
     v = 2; //~ ERROR cannot assign twice to immutable variable
diff --git a/tests/ui/assign-imm-local-twice.stderr b/tests/ui/assign-imm-local-twice.stderr
index d92485de68f..fda3aa3de1b 100644
--- a/tests/ui/assign-imm-local-twice.stderr
+++ b/tests/ui/assign-imm-local-twice.stderr
@@ -1,14 +1,16 @@
 error[E0384]: cannot assign twice to immutable variable `v`
   --> $DIR/assign-imm-local-twice.rs:7:5
    |
-LL |     let v: isize;
-   |         - help: consider making this binding mutable: `mut v`
-...
 LL |     v = 1;
    |     ----- first assignment to `v`
 LL |     println!("v={}", v);
 LL |     v = 2;
    |     ^^^^^ cannot assign twice to immutable variable
+   |
+help: consider making this binding mutable
+   |
+LL |     let mut v: isize;
+   |         +++
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/async-await/issue-61452.stderr b/tests/ui/async-await/issue-61452.stderr
index 3f623ba8ad2..b7b1e380c9e 100644
--- a/tests/ui/async-await/issue-61452.stderr
+++ b/tests/ui/async-await/issue-61452.stderr
@@ -13,12 +13,14 @@ error[E0384]: cannot assign twice to immutable variable `x`
   --> $DIR/issue-61452.rs:9:5
    |
 LL | pub async fn g(x: usize) {
-   |                -
-   |                |
-   |                first assignment to `x`
-   |                help: consider making this binding mutable: `mut x`
+   |                - first assignment to `x`
 LL |     x += 1;
    |     ^^^^^^ cannot assign twice to immutable variable
+   |
+help: consider making this binding mutable
+   |
+LL | pub async fn g(mut x: usize) {
+   |                +++
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/borrowck/borrowck-match-binding-is-assignment.stderr b/tests/ui/borrowck/borrowck-match-binding-is-assignment.stderr
index 98ffa7f6ffa..e164ea44aa4 100644
--- a/tests/ui/borrowck/borrowck-match-binding-is-assignment.stderr
+++ b/tests/ui/borrowck/borrowck-match-binding-is-assignment.stderr
@@ -9,11 +9,11 @@ LL |             x += 1;
 help: consider making this binding mutable
    |
 LL |         mut x => {
-   |         ~~~~~
+   |         +++
 help: to modify the original value, take a borrow instead
    |
 LL |         ref mut x => {
-   |         ~~~~~~~~~
+   |         +++++++
 
 error[E0384]: cannot assign twice to immutable variable `x`
   --> $DIR/borrowck-match-binding-is-assignment.rs:20:13
@@ -26,11 +26,11 @@ LL |             x += 1;
 help: consider making this binding mutable
    |
 LL |         E::Foo(mut x) => {
-   |                ~~~~~
+   |                +++
 help: to modify the original value, take a borrow instead
    |
 LL |         E::Foo(ref mut x) => {
-   |                ~~~~~~~~~
+   |                +++++++
 
 error[E0384]: cannot assign twice to immutable variable `x`
   --> $DIR/borrowck-match-binding-is-assignment.rs:26:13
@@ -43,11 +43,11 @@ LL |             x += 1;
 help: consider making this binding mutable
    |
 LL |         S { bar: mut x } => {
-   |                  ~~~~~
+   |                  +++
 help: to modify the original value, take a borrow instead
    |
 LL |         S { bar: ref mut x } => {
-   |                  ~~~~~~~~~
+   |                  +++++++
 
 error[E0384]: cannot assign twice to immutable variable `x`
   --> $DIR/borrowck-match-binding-is-assignment.rs:32:13
@@ -60,11 +60,11 @@ LL |             x += 1;
 help: consider making this binding mutable
    |
 LL |         (mut x,) => {
-   |          ~~~~~
+   |          +++
 help: to modify the original value, take a borrow instead
    |
 LL |         (ref mut x,) => {
-   |          ~~~~~~~~~
+   |          +++++++
 
 error[E0384]: cannot assign twice to immutable variable `x`
   --> $DIR/borrowck-match-binding-is-assignment.rs:38:13
@@ -77,11 +77,11 @@ LL |             x += 1;
 help: consider making this binding mutable
    |
 LL |         [mut x,_,_] => {
-   |          ~~~~~
+   |          +++
 help: to modify the original value, take a borrow instead
    |
 LL |         [ref mut x,_,_] => {
-   |          ~~~~~~~~~
+   |          +++++++
 
 error: aborting due to 5 previous errors
 
diff --git a/tests/ui/borrowck/immutable-arg.stderr b/tests/ui/borrowck/immutable-arg.stderr
index 84a480f6410..fb75172532f 100644
--- a/tests/ui/borrowck/immutable-arg.stderr
+++ b/tests/ui/borrowck/immutable-arg.stderr
@@ -1,10 +1,13 @@
 error[E0384]: cannot assign to immutable argument `_x`
   --> $DIR/immutable-arg.rs:2:5
    |
-LL | fn foo(_x: u32) {
-   |        -- help: consider making this binding mutable: `mut _x`
 LL |     _x = 4;
    |     ^^^^^^ cannot assign to immutable argument
+   |
+help: consider making this binding mutable
+   |
+LL | fn foo(mut _x: u32) {
+   |        +++
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/borrowck/issue-45199.rs b/tests/ui/borrowck/issue-45199.rs
index ded46e56e34..b38967524fa 100644
--- a/tests/ui/borrowck/issue-45199.rs
+++ b/tests/ui/borrowck/issue-45199.rs
@@ -1,7 +1,7 @@
 fn test_drop_replace() {
     let b: Box<isize>;
     //~^ HELP consider making this binding mutable
-    //~| SUGGESTION mut b
+    //~| SUGGESTION mut
     b = Box::new(1);    //~ NOTE first assignment
     b = Box::new(2);    //~ ERROR cannot assign twice to immutable variable `b`
                         //~| NOTE cannot assign twice to immutable
@@ -10,13 +10,13 @@ fn test_drop_replace() {
 fn test_call() {
     let b = Box::new(1);    //~ NOTE first assignment
                             //~| HELP consider making this binding mutable
-                            //~| SUGGESTION mut b
+                            //~| SUGGESTION mut
     b = Box::new(2);        //~ ERROR cannot assign twice to immutable variable `b`
                             //~| NOTE cannot assign twice to immutable
 }
 
 fn test_args(b: Box<i32>) {  //~ HELP consider making this binding mutable
-                                //~| SUGGESTION mut b
+                                //~| SUGGESTION mut
     b = Box::new(2);            //~ ERROR cannot assign to immutable argument `b`
                                 //~| NOTE cannot assign to immutable argument
 }
diff --git a/tests/ui/borrowck/issue-45199.stderr b/tests/ui/borrowck/issue-45199.stderr
index 47aa3090827..8886e618e18 100644
--- a/tests/ui/borrowck/issue-45199.stderr
+++ b/tests/ui/borrowck/issue-45199.stderr
@@ -1,34 +1,40 @@
 error[E0384]: cannot assign twice to immutable variable `b`
   --> $DIR/issue-45199.rs:6:5
    |
-LL |     let b: Box<isize>;
-   |         - help: consider making this binding mutable: `mut b`
-...
 LL |     b = Box::new(1);
    |     - first assignment to `b`
 LL |     b = Box::new(2);
    |     ^ cannot assign twice to immutable variable
+   |
+help: consider making this binding mutable
+   |
+LL |     let mut b: Box<isize>;
+   |         +++
 
 error[E0384]: cannot assign twice to immutable variable `b`
   --> $DIR/issue-45199.rs:14:5
    |
 LL |     let b = Box::new(1);
-   |         -
-   |         |
-   |         first assignment to `b`
-   |         help: consider making this binding mutable: `mut b`
+   |         - first assignment to `b`
 ...
 LL |     b = Box::new(2);
    |     ^ cannot assign twice to immutable variable
+   |
+help: consider making this binding mutable
+   |
+LL |     let mut b = Box::new(1);
+   |         +++
 
 error[E0384]: cannot assign to immutable argument `b`
   --> $DIR/issue-45199.rs:20:5
    |
-LL | fn test_args(b: Box<i32>) {
-   |              - help: consider making this binding mutable: `mut b`
-LL |
 LL |     b = Box::new(2);
    |     ^ cannot assign to immutable argument
+   |
+help: consider making this binding mutable
+   |
+LL | fn test_args(mut b: Box<i32>) {
+   |              +++
 
 error: aborting due to 3 previous errors
 
diff --git a/tests/ui/borrowck/suggest-ref-mut-issue-118596.stderr b/tests/ui/borrowck/suggest-ref-mut-issue-118596.stderr
index fd2a775a099..aec3d663160 100644
--- a/tests/ui/borrowck/suggest-ref-mut-issue-118596.stderr
+++ b/tests/ui/borrowck/suggest-ref-mut-issue-118596.stderr
@@ -9,11 +9,11 @@ LL |         x = 2;
 help: consider making this binding mutable
    |
 LL |     if let Some(mut x) = y {
-   |                 ~~~~~
+   |                 +++
 help: to modify the original value, take a borrow instead
    |
 LL |     if let Some(ref mut x) = y {
-   |                 ~~~~~~~~~
+   |                 +++++++
 
 error[E0384]: cannot assign twice to immutable variable `x`
   --> $DIR/suggest-ref-mut-issue-118596.rs:9:5
@@ -26,11 +26,11 @@ LL |     x = 0;
 help: consider making this binding mutable
    |
 LL |     let [mut x, ref xs_hold @ ..] = arr;
-   |          ~~~~~
+   |          +++
 help: to modify the original value, take a borrow instead
    |
 LL |     let [ref mut x, ref xs_hold @ ..] = arr;
-   |          ~~~~~~~~~
+   |          +++++++
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/borrowck/tainted-promoteds.stderr b/tests/ui/borrowck/tainted-promoteds.stderr
index a5c448fdcdb..04669a29097 100644
--- a/tests/ui/borrowck/tainted-promoteds.stderr
+++ b/tests/ui/borrowck/tainted-promoteds.stderr
@@ -2,12 +2,14 @@ error[E0384]: cannot assign twice to immutable variable `a`
   --> $DIR/tainted-promoteds.rs:7:5
    |
 LL |     let a = 0;
-   |         -
-   |         |
-   |         first assignment to `a`
-   |         help: consider making this binding mutable: `mut a`
+   |         - first assignment to `a`
 LL |     a = &0 * &1 * &2 * &3;
    |     ^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable
+   |
+help: consider making this binding mutable
+   |
+LL |     let mut a = 0;
+   |         +++
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/command-line-diagnostics.stderr b/tests/ui/command-line-diagnostics.stderr
index b719a00ad5d..6d33fb4172f 100644
--- a/tests/ui/command-line-diagnostics.stderr
+++ b/tests/ui/command-line-diagnostics.stderr
@@ -2,12 +2,14 @@ error[E0384]: cannot assign twice to immutable variable `x`
   --> $DIR/command-line-diagnostics.rs:6:5
    |
 LL |     let x = 42;
-   |         -
-   |         |
-   |         first assignment to `x`
-   |         help: consider making this binding mutable: `mut x`
+   |         - first assignment to `x`
 LL |     x = 43;
    |     ^^^^^^ cannot assign twice to immutable variable
+   |
+help: consider making this binding mutable
+   |
+LL |     let mut x = 42;
+   |         +++
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.stderr b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.stderr
index 0980de92d35..29bf7e62985 100644
--- a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.stderr
+++ b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.stderr
@@ -16,10 +16,13 @@ LL | fn foo<'a>(mut x: Ref<'a, 'a>, y: &'a u32) {
 error[E0384]: cannot assign to immutable argument `y`
   --> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:4:5
    |
-LL | fn foo(mut x: Ref, y: &u32) {
-   |                    - help: consider making this binding mutable: `mut y`
 LL |     y = x.b;
    |     ^^^^^^^ cannot assign to immutable argument
+   |
+help: consider making this binding mutable
+   |
+LL | fn foo(mut x: Ref, mut y: &u32) {
+   |                    +++
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.stderr b/tests/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.stderr
index b47a47d631e..3fbd863467d 100644
--- a/tests/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.stderr
+++ b/tests/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.stderr
@@ -1,45 +1,53 @@
 error[E0384]: cannot assign twice to immutable variable `x`
   --> $DIR/liveness-assign-imm-local-notes.rs:10:9
    |
-LL |     let x;
-   |         - help: consider making this binding mutable: `mut x`
-...
 LL |         x = 2;
    |         ----- first assignment to `x`
 LL |         x = 3;
    |         ^^^^^ cannot assign twice to immutable variable
+   |
+help: consider making this binding mutable
+   |
+LL |     let mut x;
+   |         +++
 
 error[E0384]: cannot assign twice to immutable variable `x`
   --> $DIR/liveness-assign-imm-local-notes.rs:21:13
    |
-LL |         let x;
-   |             - help: consider making this binding mutable: `mut x`
-...
 LL |             x = 2;
    |             ----- first assignment to `x`
 LL |             x = 3;
    |             ^^^^^ cannot assign twice to immutable variable
+   |
+help: consider making this binding mutable
+   |
+LL |         let mut x;
+   |             +++
 
 error[E0384]: cannot assign twice to immutable variable `x`
   --> $DIR/liveness-assign-imm-local-notes.rs:30:13
    |
-LL |     let x;
-   |         - help: consider making this binding mutable: `mut x`
-...
 LL |             x = 1;
    |             ^^^^^ cannot assign twice to immutable variable
+   |
+help: consider making this binding mutable
+   |
+LL |     let mut x;
+   |         +++
 
 error[E0384]: cannot assign twice to immutable variable `x`
   --> $DIR/liveness-assign-imm-local-notes.rs:32:13
    |
-LL |     let x;
-   |         - help: consider making this binding mutable: `mut x`
-...
 LL |             x = 1;
    |             ----- first assignment to `x`
 LL |         } else {
 LL |             x = 2;
    |             ^^^^^ cannot assign twice to immutable variable
+   |
+help: consider making this binding mutable
+   |
+LL |     let mut x;
+   |         +++
 
 error: aborting due to 4 previous errors
 
diff --git a/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.rs b/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.rs
index 08911c5bde7..d2f32a47122 100644
--- a/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.rs
+++ b/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.rs
@@ -1,7 +1,7 @@
 fn test() {
     let v: isize;
     //~^ HELP consider making this binding mutable
-    //~| SUGGESTION mut v
+    //~| SUGGESTION mut
     loop {
         v = 1; //~ ERROR cannot assign twice to immutable variable `v`
                //~| NOTE cannot assign twice to immutable variable
diff --git a/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.stderr b/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.stderr
index f0174560fd5..e8c0721b903 100644
--- a/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.stderr
+++ b/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.stderr
@@ -1,11 +1,13 @@
 error[E0384]: cannot assign twice to immutable variable `v`
   --> $DIR/liveness-assign-imm-local-in-loop.rs:6:9
    |
-LL |     let v: isize;
-   |         - help: consider making this binding mutable: `mut v`
-...
 LL |         v = 1;
    |         ^^^^^ cannot assign twice to immutable variable
+   |
+help: consider making this binding mutable
+   |
+LL |     let mut v: isize;
+   |         +++
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.rs b/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.rs
index 1752d969086..fd6b4bcdf84 100644
--- a/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.rs
+++ b/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.rs
@@ -1,7 +1,7 @@
 fn test() {
     let v: isize;
     //~^ HELP consider making this binding mutable
-    //~| SUGGESTION mut v
+    //~| SUGGESTION mut
     v = 2;  //~ NOTE first assignment
     v += 1; //~ ERROR cannot assign twice to immutable variable `v`
             //~| NOTE cannot assign twice to immutable
diff --git a/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.stderr b/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.stderr
index 578a40e4070..b7373d7cf1d 100644
--- a/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.stderr
+++ b/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.stderr
@@ -1,13 +1,15 @@
 error[E0384]: cannot assign twice to immutable variable `v`
   --> $DIR/liveness-assign-imm-local-in-op-eq.rs:6:5
    |
-LL |     let v: isize;
-   |         - help: consider making this binding mutable: `mut v`
-...
 LL |     v = 2;
    |     ----- first assignment to `v`
 LL |     v += 1;
    |     ^^^^^^ cannot assign twice to immutable variable
+   |
+help: consider making this binding mutable
+   |
+LL |     let mut v: isize;
+   |         +++
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.rs b/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.rs
index c9b16e43910..b7050d69306 100644
--- a/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.rs
+++ b/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.rs
@@ -1,7 +1,7 @@
 fn test() {
     let b = Box::new(1); //~ NOTE first assignment
                          //~| HELP consider making this binding mutable
-                         //~| SUGGESTION mut b
+                         //~| SUGGESTION mut
     drop(b);
     b = Box::new(2); //~ ERROR cannot assign twice to immutable variable `b`
                      //~| NOTE cannot assign twice to immutable
diff --git a/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.stderr b/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.stderr
index 2f55b50f0ba..35b47bd6d91 100644
--- a/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.stderr
+++ b/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.stderr
@@ -2,13 +2,15 @@ error[E0384]: cannot assign twice to immutable variable `b`
   --> $DIR/liveness-assign-imm-local-with-drop.rs:6:5
    |
 LL |     let b = Box::new(1);
-   |         -
-   |         |
-   |         first assignment to `b`
-   |         help: consider making this binding mutable: `mut b`
+   |         - first assignment to `b`
 ...
 LL |     b = Box::new(2);
    |     ^ cannot assign twice to immutable variable
+   |
+help: consider making this binding mutable
+   |
+LL |     let mut b = Box::new(1);
+   |         +++
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.rs b/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.rs
index 4bb2db27a16..67c97e38546 100644
--- a/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.rs
+++ b/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.rs
@@ -1,7 +1,7 @@
 fn test() {
     let v: isize = 1; //~ NOTE first assignment
                       //~| HELP consider making this binding mutable
-                      //~| SUGGESTION mut v
+                      //~| SUGGESTION mut
     v.clone();
     v = 2; //~ ERROR cannot assign twice to immutable variable `v`
            //~| NOTE cannot assign twice to immutable
diff --git a/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.stderr b/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.stderr
index 8eb71cd99bf..d1f9e1573e4 100644
--- a/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.stderr
+++ b/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.stderr
@@ -2,13 +2,15 @@ error[E0384]: cannot assign twice to immutable variable `v`
   --> $DIR/liveness-assign-imm-local-with-init.rs:6:5
    |
 LL |     let v: isize = 1;
-   |         -
-   |         |
-   |         first assignment to `v`
-   |         help: consider making this binding mutable: `mut v`
+   |         - first assignment to `v`
 ...
 LL |     v = 2;
    |     ^^^^^ cannot assign twice to immutable variable
+   |
+help: consider making this binding mutable
+   |
+LL |     let mut v: isize = 1;
+   |         +++
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/mut/mut-pattern-internal-mutability.stderr b/tests/ui/mut/mut-pattern-internal-mutability.stderr
index ab80af17a08..f3a8aa0126c 100644
--- a/tests/ui/mut/mut-pattern-internal-mutability.stderr
+++ b/tests/ui/mut/mut-pattern-internal-mutability.stderr
@@ -9,11 +9,11 @@ LL |     x += 1;
 help: consider making this binding mutable
    |
 LL |     let &mut mut x = foo;
-   |              ~~~~~
+   |              +++
 help: to modify the original value, take a borrow instead
    |
 LL |     let &mut ref mut x = foo;
-   |              ~~~~~~~~~
+   |              +++++++
 
 error[E0506]: cannot assign to `*foo` because it is borrowed
   --> $DIR/mut-pattern-internal-mutability.rs:13:5
diff --git a/tests/ui/pattern/bindings-after-at/pat-at-same-name-both.stderr b/tests/ui/pattern/bindings-after-at/pat-at-same-name-both.stderr
index 41d1b79d97d..ed71a39ff7e 100644
--- a/tests/ui/pattern/bindings-after-at/pat-at-same-name-both.stderr
+++ b/tests/ui/pattern/bindings-after-at/pat-at-same-name-both.stderr
@@ -78,11 +78,11 @@ LL |         | Err(a @ b @ a)
 help: consider making this binding mutable
    |
 LL |         Ok(a @ b @ mut a)
-   |                    ~~~~~
+   |                    +++
 help: to modify the original value, take a borrow instead
    |
 LL |         Ok(a @ b @ ref mut a)
-   |                    ~~~~~~~~~
+   |                    +++++++
 
 error: aborting due to 12 previous errors
 
diff --git a/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr b/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr
index 1e7b990b67c..a1049701dc3 100644
--- a/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr
+++ b/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr
@@ -22,11 +22,11 @@ LL |     _x1 = U;
 help: consider making this binding mutable
    |
 LL |     let [ref _x0_hold, mut _x1, ref xs_hold @ ..] = arr;
-   |                        ~~~~~~~
+   |                        +++
 help: to modify the original value, take a borrow instead
    |
 LL |     let [ref _x0_hold, ref mut _x1, ref xs_hold @ ..] = arr;
-   |                        ~~~~~~~~~~~
+   |                        +++++++
 
 error[E0505]: cannot move out of `arr[..]` because it is borrowed
   --> $DIR/borrowck-move-ref-pattern.rs:11:10
@@ -86,11 +86,11 @@ LL |     _x1 = U;
 help: consider making this binding mutable
    |
 LL |     let (ref _x0, mut _x1, ref _x2, ..) = tup;
-   |                   ~~~~~~~
+   |                   +++
 help: to modify the original value, take a borrow instead
    |
 LL |     let (ref _x0, ref mut _x1, ref _x2, ..) = tup;
-   |                   ~~~~~~~~~~~
+   |                   +++++++
 
 error[E0502]: cannot borrow `tup.0` as mutable because it is also borrowed as immutable
   --> $DIR/borrowck-move-ref-pattern.rs:24:20
diff --git a/tests/ui/pattern/mut-ref-mut-2021.stderr b/tests/ui/pattern/mut-ref-mut-2021.stderr
index ebf7979edb6..228afed2026 100644
--- a/tests/ui/pattern/mut-ref-mut-2021.stderr
+++ b/tests/ui/pattern/mut-ref-mut-2021.stderr
@@ -9,11 +9,11 @@ LL |     a = 42;
 help: consider making this binding mutable
    |
 LL |     let Foo(mut a) = Foo(0);
-   |             ~~~~~
+   |             +++
 help: to modify the original value, take a borrow instead
    |
 LL |     let Foo(ref mut a) = Foo(0);
-   |             ~~~~~~~~~
+   |             +++++++
 
 error[E0384]: cannot assign twice to immutable variable `a`
   --> $DIR/mut-ref-mut-2021.rs:15:5