]> git.lizzy.rs Git - rust.git/commitdiff
Verbose suggestions
authorEsteban Küber <esteban@kuber.com.ar>
Sun, 1 Jan 2023 08:06:31 +0000 (00:06 -0800)
committerEsteban Küber <esteban@kuber.com.ar>
Mon, 2 Jan 2023 05:33:23 +0000 (21:33 -0800)
53 files changed:
compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
src/test/ui/asm/aarch64/type-check-2-2.rs
src/test/ui/asm/aarch64/type-check-2-2.stderr
src/test/ui/asm/x86_64/type-check-5.stderr
src/test/ui/async-await/issue-61452.stderr
src/test/ui/async-await/issues/issue-61187.stderr
src/test/ui/augmented-assignments.rs
src/test/ui/augmented-assignments.stderr
src/test/ui/borrowck/borrow-raw-address-of-mutability.stderr
src/test/ui/borrowck/borrowck-access-permissions.stderr
src/test/ui/borrowck/borrowck-argument.stderr
src/test/ui/borrowck/borrowck-auto-mut-ref-to-immut-var.stderr
src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.stderr
src/test/ui/borrowck/borrowck-borrow-from-stack-variable.stderr
src/test/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.stderr
src/test/ui/borrowck/borrowck-mut-addr-of-imm-var.stderr
src/test/ui/borrowck/borrowck-mut-slice-of-imm-vec.stderr
src/test/ui/borrowck/borrowck-overloaded-call.stderr
src/test/ui/borrowck/borrowck-ref-mut-of-imm.stderr
src/test/ui/borrowck/borrowck-unboxed-closures.stderr
src/test/ui/borrowck/immut-function-arguments.stderr
src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.stderr
src/test/ui/borrowck/many-mutable-borrows.stderr
src/test/ui/borrowck/mutability-errors.stderr
src/test/ui/borrowck/reassignment_immutable_fields_overlapping.stderr
src/test/ui/borrowck/reassignment_immutable_fields_twice.stderr
src/test/ui/closures/issue-80313-mutable-borrow-in-closure.stderr
src/test/ui/closures/issue-80313-mutable-borrow-in-move-closure.stderr
src/test/ui/closures/issue-80313-mutation-in-closure.stderr
src/test/ui/closures/issue-80313-mutation-in-move-closure.stderr
src/test/ui/closures/issue-81700-mut-borrow.stderr
src/test/ui/closures/issue-82438-mut-without-upvar.stderr
src/test/ui/closures/issue-84044-drop-non-mut.stderr
src/test/ui/codemap_tests/huge_multispan_highlight.stderr
src/test/ui/did_you_mean/issue-35937.stderr
src/test/ui/did_you_mean/issue-39544.stderr
src/test/ui/error-codes/E0596.stderr
src/test/ui/issues/issue-36400.stderr
src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.stderr
src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.stderr
src/test/ui/macros/span-covering-argument-1.stderr
src/test/ui/mut/mut-suggestion.rs
src/test/ui/mut/mut-suggestion.stderr
src/test/ui/mut/mutable-class-fields.stderr
src/test/ui/nll/issue-51191.stderr
src/test/ui/pattern/bindings-after-at/nested-binding-modes-mut.stderr
src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr
src/test/ui/span/borrowck-borrow-overloaded-deref-mut.stderr
src/test/ui/span/borrowck-object-mutability.stderr
src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.stderr
src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-missing-mut.stderr
src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-move-missing-mut.stderr
src/test/ui/writing-to-immutable-vec.stderr

index b04b11e7c9bda9ec987123a74356d9c4f53bc191..6f6d1b01bd4294a7f95195f858e0266a8a6f9c45 100644 (file)
@@ -377,10 +377,10 @@ pub(crate) fn report_mutability_error(
                     err.span_label(span, format!("cannot {act}"));
                 }
                 if suggest {
-                    err.span_suggestion(
-                        local_decl.source_info.span,
+                    err.span_suggestion_verbose(
+                        local_decl.source_info.span.shrink_to_lo(),
                         "consider changing this to be mutable",
-                        format!("mut {}", self.local_names[local].unwrap()),
+                        "mut ".to_string(),
                         Applicability::MachineApplicable,
                     );
                     let tcx = self.infcx.tcx;
index 0ce1f1d8f7f4ad33ac6926ed5e09576b03027e54..89f2b3bb7d0fe2e9fef3c90d3ec1fe91d205029e 100644 (file)
@@ -25,12 +25,10 @@ fn main() {
 
         // Outputs require mutable places
 
-        let v: Vec<u64> = vec![0, 1, 2];
+        let v: Vec<u64> = vec![0, 1, 2]; //~ ERROR cannot borrow `v` as mutable
         asm!("{}", in(reg) v[0]);
         asm!("{}", out(reg) v[0]);
-        //~^ ERROR cannot borrow `v` as mutable, as it is not declared as mutable
         asm!("{}", inout(reg) v[0]);
-        //~^ ERROR cannot borrow `v` as mutable, as it is not declared as mutable
 
         // Sym operands must point to a function or static
     }
index eef16a165a87556f187cbdbca517682024a1b87a..41f7c01dc82b1f1878d277ced92289e156d4d6a8 100644 (file)
@@ -25,24 +25,22 @@ LL |         let mut y: u64 = 0;
    |                        +++
 
 error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable
-  --> $DIR/type-check-2-2.rs:30:29
+  --> $DIR/type-check-2-2.rs:28:13
    |
 LL |         let v: Vec<u64> = vec![0, 1, 2];
-   |             - help: consider changing this to be mutable: `mut v`
+   |             ^ not mutable
 LL |         asm!("{}", in(reg) v[0]);
 LL |         asm!("{}", out(reg) v[0]);
-   |                             ^ cannot borrow as mutable
-
-error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable
-  --> $DIR/type-check-2-2.rs:32:31
-   |
-LL |         let v: Vec<u64> = vec![0, 1, 2];
-   |             - help: consider changing this to be mutable: `mut v`
-...
+   |                             - cannot borrow as mutable
 LL |         asm!("{}", inout(reg) v[0]);
-   |                               ^ cannot borrow as mutable
+   |                               - cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |         let mut v: Vec<u64> = vec![0, 1, 2];
+   |             +++
 
-error: aborting due to 4 previous errors
+error: aborting due to 3 previous errors
 
 Some errors have detailed explanations: E0381, E0596.
 For more information about an error, try `rustc --explain E0381`.
index af89e5e91174e9e9d10ae65b4e360f3691e5de3d..7970e76d6a1f4e74ae49531248cb057d79af9cae 100644 (file)
@@ -28,15 +28,17 @@ error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable
   --> $DIR/type-check-5.rs:24:13
    |
 LL |         let v: Vec<u64> = vec![0, 1, 2];
-   |             ^
-   |             |
-   |             not mutable
-   |             help: consider changing this to be mutable: `mut v`
+   |             ^ not mutable
 ...
 LL |         asm!("{}", out(reg) v[0]);
    |                             - cannot borrow as mutable
 LL |         asm!("{}", inout(reg) v[0]);
    |                               - cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |         let mut v: Vec<u64> = vec![0, 1, 2];
+   |             +++
 
 error: aborting due to 3 previous errors
 
index 2d3bb48e03be83ac3a5a042eaf9de06774d0c7c5..bf50443288032c74ada58b0664b71563b1cc570f 100644 (file)
@@ -1,10 +1,13 @@
 error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
   --> $DIR/issue-61452.rs:4:5
    |
-LL | pub async fn f(x: Option<usize>) {
-   |                - help: consider changing this to be mutable: `mut x`
 LL |     x.take();
    |     ^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL | pub async fn f(mut x: Option<usize>) {
+   |                +++
 
 error[E0384]: cannot assign twice to immutable variable `x`
   --> $DIR/issue-61452.rs:9:5
index 163053471b52daad9ce7b5394f0a693b323ba10e..e58f74546899ba16f109a820b887bc592e8154db 100644 (file)
@@ -1,10 +1,13 @@
 error[E0596]: cannot borrow `data` as mutable, as it is not declared as mutable
   --> $DIR/issue-61187.rs:6:5
    |
-LL | async fn response(data: Vec<u8>) {
-   |                   ---- help: consider changing this to be mutable: `mut data`
 LL |     data.reverse();
    |     ^^^^^^^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL | async fn response(mut data: Vec<u8>) {
+   |                   +++
 
 error: aborting due to previous error
 
index 1b4ac6edcb0d5547ce40b2099cb97c3bb501c55e..20c7fb3a98395bddc9bf07788364b7630dd9d867 100644 (file)
@@ -19,7 +19,7 @@ fn main() {
 
     let y = Int(2);
     //~^ HELP consider changing this to be mutable
-    //~| SUGGESTION mut y
+    //~| SUGGESTION mut
     y   //~ ERROR cannot borrow `y` as mutable, as it is not declared as mutable
         //~| cannot borrow as mutable
     +=
index ce555da8975a7af622eb377ec85f114da441d0b6..2910c910d55241bf4c660f667df359b0ac38289f 100644 (file)
@@ -10,11 +10,13 @@ LL |     x;
 error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable
   --> $DIR/augmented-assignments.rs:23:5
    |
-LL |     let y = Int(2);
-   |         - help: consider changing this to be mutable: `mut y`
-...
 LL |     y
    |     ^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut y = Int(2);
+   |         +++
 
 error: aborting due to 2 previous errors
 
index 869375cb2c61be2a0911f28e05e42e2c409b3cd2..a7748209187121bdd6f779b8d9e5644f0eaa0582 100644 (file)
@@ -1,10 +1,13 @@
 error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
   --> $DIR/borrow-raw-address-of-mutability.rs:5:13
    |
-LL |     let x = 0;
-   |         - help: consider changing this to be mutable: `mut x`
 LL |     let y = &raw mut x;
    |             ^^^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut x = 0;
+   |         +++
 
 error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
   --> $DIR/borrow-raw-address-of-mutability.rs:11:17
@@ -18,13 +21,16 @@ LL |         let y = &raw mut x;
 error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable
   --> $DIR/borrow-raw-address-of-mutability.rs:21:5
    |
-LL |     let f = || {
-   |         - help: consider changing this to be mutable: `mut f`
 LL |         let y = &raw mut x;
    |                          - calling `f` requires mutable binding due to mutable borrow of `x`
 LL |     };
 LL |     f();
    |     ^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut f = || {
+   |         +++
 
 error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
   --> $DIR/borrow-raw-address-of-mutability.rs:29:17
index 312720898473a9717d84ce3e1eedfe39ad786a38..26f3e2bbdb775901eaaed75553e50ca2b2c9c38e 100644 (file)
@@ -1,11 +1,13 @@
 error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
   --> $DIR/borrowck-access-permissions.rs:9:19
    |
-LL |     let x = 1;
-   |         - help: consider changing this to be mutable: `mut x`
-...
 LL |         let _y1 = &mut x;
    |                   ^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut x = 1;
+   |         +++
 
 error[E0596]: cannot borrow immutable static item `static_x` as mutable
   --> $DIR/borrowck-access-permissions.rs:14:19
@@ -16,11 +18,13 @@ LL |         let _y1 = &mut static_x;
 error[E0596]: cannot borrow `*box_x` as mutable, as `box_x` is not declared as mutable
   --> $DIR/borrowck-access-permissions.rs:22:19
    |
-LL |         let box_x = Box::new(1);
-   |             ----- help: consider changing this to be mutable: `mut box_x`
-...
 LL |         let _y1 = &mut *box_x;
    |                   ^^^^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |         let mut box_x = Box::new(1);
+   |             +++
 
 error[E0596]: cannot borrow `*ref_x` as mutable, as it is behind a `&` reference
   --> $DIR/borrowck-access-permissions.rs:30:19
index d4d646e390c31f5269ff87c814641679bb3cdbd6..1c992dfccebfbd95b775536183f5c766c93021a0 100644 (file)
@@ -1,34 +1,46 @@
 error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable
   --> $DIR/borrowck-argument.rs:10:5
    |
-LL | fn func(arg: S) {
-   |         --- help: consider changing this to be mutable: `mut arg`
 LL |     arg.mutate();
    |     ^^^^^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL | fn func(mut arg: S) {
+   |         +++
 
 error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable
   --> $DIR/borrowck-argument.rs:15:9
    |
-LL |     fn method(&self, arg: S) {
-   |                      --- help: consider changing this to be mutable: `mut arg`
 LL |         arg.mutate();
    |         ^^^^^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     fn method(&self, mut arg: S) {
+   |                      +++
 
 error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable
   --> $DIR/borrowck-argument.rs:21:9
    |
-LL |     fn default(&self, arg: S) {
-   |                       --- help: consider changing this to be mutable: `mut arg`
 LL |         arg.mutate();
    |         ^^^^^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     fn default(&self, mut arg: S) {
+   |                       +++
 
 error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable
   --> $DIR/borrowck-argument.rs:32:17
    |
 LL |     (|arg: S| { arg.mutate() })(s);
-   |       ---       ^^^^^^^^^^^^ cannot borrow as mutable
-   |       |
-   |       help: consider changing this to be mutable: `mut arg`
+   |                 ^^^^^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     (|mut arg: S| { arg.mutate() })(s);
+   |       +++
 
 error: aborting due to 4 previous errors
 
index 186ecddd6d61df3ff01e052cd5349897980860c9..19ef0301a2d76b3b5b8d560caf6d0ccce2d276d5 100644 (file)
@@ -1,10 +1,13 @@
 error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
   --> $DIR/borrowck-auto-mut-ref-to-immut-var.rs:15:5
    |
-LL |     let x = Foo { x: 3 };
-   |         - help: consider changing this to be mutable: `mut x`
 LL |     x.printme();
    |     ^^^^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut x = Foo { x: 3 };
+   |         +++
 
 error: aborting due to previous error
 
index e00d69f89d36eefea364e61d44bf7c330b1469b8..c2351aacdae62a35706b5e52a5e194f82816ed19 100644 (file)
@@ -105,10 +105,13 @@ LL |     *bar1;
 error[E0596]: cannot borrow `foo.bar1` as mutable, as `foo` is not declared as mutable
   --> $DIR/borrowck-borrow-from-owned-ptr.rs:122:16
    |
-LL |     let foo = make_foo();
-   |         --- help: consider changing this to be mutable: `mut foo`
 LL |     let bar1 = &mut foo.bar1;
    |                ^^^^^^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut foo = make_foo();
+   |         +++
 
 error: aborting due to 11 previous errors
 
index ce5ce56dea27fe85e2962e2f4173a08c485662ac..8fcaaa883b22c6520869d9a7e757a64ac28578ca 100644 (file)
@@ -105,10 +105,13 @@ LL |     *bar1;
 error[E0596]: cannot borrow `foo.bar1` as mutable, as `foo` is not declared as mutable
   --> $DIR/borrowck-borrow-from-stack-variable.rs:120:16
    |
-LL |     let foo = make_foo();
-   |         --- help: consider changing this to be mutable: `mut foo`
 LL |     let bar1 = &mut foo.bar1;
    |                ^^^^^^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut foo = make_foo();
+   |         +++
 
 error: aborting due to 11 previous errors
 
index 237071e16fc669b0f0e27414cc5ba5ccce10e115..3c28ff56e4196158358496cfc3f7953744f97e28 100644 (file)
@@ -1,10 +1,13 @@
 error[E0596]: cannot borrow `*a` as mutable, as `a` is not declared as mutable
   --> $DIR/borrowck-borrow-immut-deref-of-box-as-mut.rs:12:5
    |
-LL |     let a: Box<_> = Box::new(A);
-   |         - help: consider changing this to be mutable: `mut a`
 LL |     a.foo();
    |     ^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut a: Box<_> = Box::new(A);
+   |         +++
 
 error: aborting due to previous error
 
index d58548f22049a683748c72511b0c967e3c39db60..20528e3f0ee089d6fb949b186a0d66b15a1f6002 100644 (file)
@@ -1,10 +1,13 @@
 error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
   --> $DIR/borrowck-mut-addr-of-imm-var.rs:3:25
    |
-LL |     let x: isize = 3;
-   |         - help: consider changing this to be mutable: `mut x`
 LL |     let y: &mut isize = &mut x;
    |                         ^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut x: isize = 3;
+   |         +++
 
 error: aborting due to previous error
 
index 8e7ffdc6819a5c679ced357abdb9db3b76d7a76e..8ab472e64c7a929093691ef97102d71092900d89 100644 (file)
@@ -1,10 +1,13 @@
 error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable
   --> $DIR/borrowck-mut-slice-of-imm-vec.rs:7:11
    |
-LL |     let v = vec![1, 2, 3];
-   |         - help: consider changing this to be mutable: `mut v`
 LL |     write(&mut v);
    |           ^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut v = vec![1, 2, 3];
+   |         +++
 
 error: aborting due to previous error
 
index ddb63b5ec0fbec2d0a8a39e291fb0f8d0ab7b91f..723b19f4124ac10b6877486bd215d201fa6107bf 100644 (file)
@@ -11,11 +11,13 @@ LL |     use_mut(sp);
 error[E0596]: cannot borrow `s` as mutable, as it is not declared as mutable
   --> $DIR/borrowck-overloaded-call.rs:67:5
    |
-LL |     let s = SFnMut {
-   |         - help: consider changing this to be mutable: `mut s`
-...
 LL |     s(3);
    |     ^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut s = SFnMut {
+   |         +++
 
 error[E0382]: use of moved value: `s`
   --> $DIR/borrowck-overloaded-call.rs:75:5
index e744fc6b54b1a4fccb6f4e48f7a052948ab283b9..5cfd81bd00428e1644e215476b8e76656a204398 100644 (file)
@@ -1,11 +1,13 @@
 error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable
   --> $DIR/borrowck-ref-mut-of-imm.rs:4:12
    |
-LL | fn destructure(x: Option<isize>) -> isize {
-   |                - help: consider changing this to be mutable: `mut x`
-...
 LL |       Some(ref mut v) => *v
    |            ^^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL | fn destructure(mut x: Option<isize>) -> isize {
+   |                +++
 
 error: aborting due to previous error
 
index d46ef126da481a9c0ecc8606efd727d2349db5f8..3634676463c62f516be4f82a4da52570b14778b4 100644 (file)
@@ -11,10 +11,13 @@ LL |     use_mut(g);
 error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable
   --> $DIR/borrowck-unboxed-closures.rs:7:5
    |
-LL | fn b<F:FnMut(isize, isize) -> isize>(f: F) {
-   |                                      - help: consider changing this to be mutable: `mut f`
 LL |     f(1, 2);
    |     ^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL | fn b<F:FnMut(isize, isize) -> isize>(mut f: F) {
+   |                                      +++
 
 error[E0382]: use of moved value: `f`
   --> $DIR/borrowck-unboxed-closures.rs:12:5
index 7238dd14433ce888cfba8b7b303acd6cec186471..d5392e7d66fa4cbbe8e27adef49c5799599c4a2f 100644 (file)
@@ -1,18 +1,24 @@
 error[E0594]: cannot assign to `*y`, as `y` is not declared as mutable
   --> $DIR/immut-function-arguments.rs:2:5
    |
-LL | fn f(y: Box<isize>) {
-   |      - help: consider changing this to be mutable: `mut y`
 LL |     *y = 5;
    |     ^^^^^^ cannot assign
+   |
+help: consider changing this to be mutable
+   |
+LL | fn f(mut y: Box<isize>) {
+   |      +++
 
 error[E0594]: cannot assign to `*q`, as `q` is not declared as mutable
   --> $DIR/immut-function-arguments.rs:6:35
    |
 LL |     let _frob = |q: Box<isize>| { *q = 2; };
-   |                  -                ^^^^^^ cannot assign
-   |                  |
-   |                  help: consider changing this to be mutable: `mut q`
+   |                                   ^^^^^^ cannot assign
+   |
+help: consider changing this to be mutable
+   |
+LL |     let _frob = |mut q: Box<isize>| { *q = 2; };
+   |                  +++
 
 error: aborting due to 2 previous errors
 
index b7623a54056d809321115d790a204aa8c2aac4ba..774b6cf0ea6d23277ba9824bfe379c00d32b5f72 100644 (file)
@@ -1,11 +1,13 @@
 error[E0594]: cannot assign to `t.0`, as `t` is not declared as mutable
   --> $DIR/issue-54499-field-mutation-of-moved-out.rs:13:9
    |
-LL |         let t: Tuple = (S(0), 0);
-   |             - help: consider changing this to be mutable: `mut t`
-LL |         drop(t);
 LL |         t.0 = S(1);
    |         ^^^^^^^^^^ cannot assign
+   |
+help: consider changing this to be mutable
+   |
+LL |         let mut t: Tuple = (S(0), 0);
+   |             +++
 
 error[E0382]: assign to part of moved value: `t`
   --> $DIR/issue-54499-field-mutation-of-moved-out.rs:13:9
@@ -20,20 +22,24 @@ LL |         t.0 = S(1);
 error[E0594]: cannot assign to `t.1`, as `t` is not declared as mutable
   --> $DIR/issue-54499-field-mutation-of-moved-out.rs:16:9
    |
-LL |         let t: Tuple = (S(0), 0);
-   |             - help: consider changing this to be mutable: `mut t`
-...
 LL |         t.1 = 2;
    |         ^^^^^^^ cannot assign
+   |
+help: consider changing this to be mutable
+   |
+LL |         let mut t: Tuple = (S(0), 0);
+   |             +++
 
 error[E0594]: cannot assign to `u.0`, as `u` is not declared as mutable
   --> $DIR/issue-54499-field-mutation-of-moved-out.rs:24:9
    |
-LL |         let u: Tpair = Tpair(S(0), 0);
-   |             - help: consider changing this to be mutable: `mut u`
-LL |         drop(u);
 LL |         u.0 = S(1);
    |         ^^^^^^^^^^ cannot assign
+   |
+help: consider changing this to be mutable
+   |
+LL |         let mut u: Tpair = Tpair(S(0), 0);
+   |             +++
 
 error[E0382]: assign to part of moved value: `u`
   --> $DIR/issue-54499-field-mutation-of-moved-out.rs:24:9
@@ -48,20 +54,24 @@ LL |         u.0 = S(1);
 error[E0594]: cannot assign to `u.1`, as `u` is not declared as mutable
   --> $DIR/issue-54499-field-mutation-of-moved-out.rs:27:9
    |
-LL |         let u: Tpair = Tpair(S(0), 0);
-   |             - help: consider changing this to be mutable: `mut u`
-...
 LL |         u.1 = 2;
    |         ^^^^^^^ cannot assign
+   |
+help: consider changing this to be mutable
+   |
+LL |         let mut u: Tpair = Tpair(S(0), 0);
+   |             +++
 
 error[E0594]: cannot assign to `v.x`, as `v` is not declared as mutable
   --> $DIR/issue-54499-field-mutation-of-moved-out.rs:35:9
    |
-LL |         let v: Spair = Spair { x: S(0), y: 0 };
-   |             - help: consider changing this to be mutable: `mut v`
-LL |         drop(v);
 LL |         v.x = S(1);
    |         ^^^^^^^^^^ cannot assign
+   |
+help: consider changing this to be mutable
+   |
+LL |         let mut v: Spair = Spair { x: S(0), y: 0 };
+   |             +++
 
 error[E0382]: assign to part of moved value: `v`
   --> $DIR/issue-54499-field-mutation-of-moved-out.rs:35:9
@@ -76,11 +86,13 @@ LL |         v.x = S(1);
 error[E0594]: cannot assign to `v.y`, as `v` is not declared as mutable
   --> $DIR/issue-54499-field-mutation-of-moved-out.rs:38:9
    |
-LL |         let v: Spair = Spair { x: S(0), y: 0 };
-   |             - help: consider changing this to be mutable: `mut v`
-...
 LL |         v.y = 2;
    |         ^^^^^^^ cannot assign
+   |
+help: consider changing this to be mutable
+   |
+LL |         let mut v: Spair = Spair { x: S(0), y: 0 };
+   |             +++
 
 error: aborting due to 9 previous errors
 
index 25755d9432362603b17e1329970512dce14e973a..aa0cbcffd952ba77576a4f1ec90d32f54386cdd2 100644 (file)
@@ -2,10 +2,7 @@ error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable
   --> $DIR/many-mutable-borrows.rs:2:9
    |
 LL |     let v = Vec::new();
-   |         ^
-   |         |
-   |         not mutable
-   |         help: consider changing this to be mutable: `mut v`
+   |         ^ not mutable
 LL |     v.push(0);
    |     --------- cannot borrow as mutable
 LL |     v.push(0);
@@ -26,6 +23,10 @@ LL |     v.push(0);
    |     --------- cannot borrow as mutable
    |
    = note: ...and 5 other attempted mutable borrows
+help: consider changing this to be mutable
+   |
+LL |     let mut v = Vec::new();
+   |         +++
 
 error: aborting due to previous error
 
index 5da8e60db75932f201b113193a099fea4b42e445..d7c602718f1736ccf54fa451f4d2aff9e8d0f1e3 100644 (file)
@@ -248,14 +248,16 @@ error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
   --> $DIR/mutability-errors.rs:53:14
    |
 LL | fn imm_local(x: (i32,)) {
-   |              ^
-   |              |
-   |              not mutable
-   |              help: consider changing this to be mutable: `mut x`
+   |              ^ not mutable
 LL |     &mut x;
    |     ------ cannot borrow as mutable
 LL |     &mut x.0;
    |     -------- cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL | fn imm_local(mut x: (i32,)) {
+   |              +++
 
 error[E0594]: cannot assign to `x`, as it is not declared as mutable
   --> $DIR/mutability-errors.rs:60:9
index a3885b5f5caea4593bcaf8df52d32a95cf7dd63d..81e5bc45d4d38bbadc11c530131be0f0888ec90b 100644 (file)
@@ -11,11 +11,13 @@ LL |     x.a = 1;
 error[E0594]: cannot assign to `x.b`, as `x` is not declared as mutable
   --> $DIR/reassignment_immutable_fields_overlapping.rs:13:5
    |
-LL |     let x: Foo;
-   |         - help: consider changing this to be mutable: `mut x`
-LL |     x.a = 1;
 LL |     x.b = 22;
    |     ^^^^^^^^ cannot assign
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut x: Foo;
+   |         +++
 
 error: aborting due to 2 previous errors
 
index 49c81adad49373c788f0e80ad693b131490c3954..ba0457809ad43b591c49f2227ea852dcf2344e6a 100644 (file)
@@ -1,11 +1,13 @@
 error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable
   --> $DIR/reassignment_immutable_fields_twice.rs:7:5
    |
-LL |     let x: (u32, u32);
-   |         - help: consider changing this to be mutable: `mut x`
-LL |     x = (22, 44);
 LL |     x.0 = 1;
    |     ^^^^^^^ cannot assign
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut x: (u32, u32);
+   |         +++
 
 error[E0381]: partially assigned binding `x` isn't fully initialized
   --> $DIR/reassignment_immutable_fields_twice.rs:12:5
index bf9e1febdbba40a55ba062b64b82a824dd8bde40..239f071ca92b3152f60c86e011ce4b22fc74106f 100644 (file)
@@ -1,13 +1,16 @@
 error[E0596]: cannot borrow `callback` as mutable, as it is not declared as mutable
   --> $DIR/issue-80313-mutable-borrow-in-closure.rs:6:5
    |
-LL |     let callback = || {
-   |         -------- help: consider changing this to be mutable: `mut callback`
 LL |         &mut my_var;
    |              ------ calling `callback` requires mutable binding due to mutable borrow of `my_var`
 LL |     };
 LL |     callback();
    |     ^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut callback = || {
+   |         +++
 
 error: aborting due to previous error
 
index b67cec6a609f0857eaa8e6a63e0839aa7ba29941..1ec279f03eff5ff24369ea55dd03769424d0b889 100644 (file)
@@ -1,13 +1,16 @@
 error[E0596]: cannot borrow `callback` as mutable, as it is not declared as mutable
   --> $DIR/issue-80313-mutable-borrow-in-move-closure.rs:6:5
    |
-LL |     let callback = move || {
-   |         -------- help: consider changing this to be mutable: `mut callback`
 LL |         &mut my_var;
    |              ------ calling `callback` requires mutable binding due to possible mutation of `my_var`
 LL |     };
 LL |     callback();
    |     ^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut callback = move || {
+   |         +++
 
 error: aborting due to previous error
 
index 6e98549f6b84f8cbf1c0252e8c14cb6e5b77bdf1..22a62ce735053f2596b6ea0860e0b8f2a56792ae 100644 (file)
@@ -1,13 +1,16 @@
 error[E0596]: cannot borrow `callback` as mutable, as it is not declared as mutable
   --> $DIR/issue-80313-mutation-in-closure.rs:6:5
    |
-LL |     let callback = || {
-   |         -------- help: consider changing this to be mutable: `mut callback`
 LL |         my_var = true;
    |         ------ calling `callback` requires mutable binding due to mutable borrow of `my_var`
 LL |     };
 LL |     callback();
    |     ^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut callback = || {
+   |         +++
 
 error: aborting due to previous error
 
index edd55422a0bd490350d671b9b1b82bcaa31e6614..a2222f8cc9570bd21d1afa21cdcee4f15e926af6 100644 (file)
@@ -1,13 +1,16 @@
 error[E0596]: cannot borrow `callback` as mutable, as it is not declared as mutable
   --> $DIR/issue-80313-mutation-in-move-closure.rs:6:5
    |
-LL |     let callback = move || {
-   |         -------- help: consider changing this to be mutable: `mut callback`
 LL |         my_var = true;
    |         ------ calling `callback` requires mutable binding due to possible mutation of `my_var`
 LL |     };
 LL |     callback();
    |     ^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut callback = move || {
+   |         +++
 
 error: aborting due to previous error
 
index 3f564afff58e2df73a1424e327fc0bc8551c7ed2..03b18c3f70c63ae59dfb5b938b2dbcf69d1fed8b 100644 (file)
@@ -2,11 +2,14 @@ error[E0596]: cannot borrow `bar` as mutable, as it is not declared as mutable
   --> $DIR/issue-81700-mut-borrow.rs:3:5
    |
 LL |     let bar = || { foo(x); };
-   |         ---            - calling `bar` requires mutable binding due to mutable borrow of `x`
-   |         |
-   |         help: consider changing this to be mutable: `mut bar`
+   |                        - calling `bar` requires mutable binding due to mutable borrow of `x`
 LL |     bar();
    |     ^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut bar = || { foo(x); };
+   |         +++
 
 error: aborting due to previous error
 
index 802284b265821121fcb6fc5fa6bd7b2dbaf811d7..f0951b7d10873e73ec31645f30ba598707bdacdf 100644 (file)
@@ -1,11 +1,13 @@
 error[E0596]: cannot borrow `c` as mutable, as it is not declared as mutable
   --> $DIR/issue-82438-mut-without-upvar.rs:27:27
    |
-LL |     let c = |a, b, c, d| {};
-   |         - help: consider changing this to be mutable: `mut c`
-LL |
 LL |     A.f(participant_name, &mut c);
    |                           ^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut c = |a, b, c, d| {};
+   |         +++
 
 error: aborting due to previous error
 
index c0bfad263f1785723fcf547ab3d1923a51904a90..5335a056cd89f16042846c102149823fdd159453 100644 (file)
@@ -1,10 +1,13 @@
 error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable
   --> $DIR/issue-84044-drop-non-mut.rs:5:10
    |
-LL |     let f = || {};
-   |         - help: consider changing this to be mutable: `mut f`
 LL |     drop(&mut f);
    |          ^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut f = || {};
+   |         +++
 
 error: aborting due to previous error
 
index a60f1c77a586317ce2f1681444daef840cb6e94d..9f8ce3b6183f2c7f2f37e77c9308a6789085d8ff 100644 (file)
@@ -1,11 +1,13 @@
 error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
   --> $DIR/huge_multispan_highlight.rs:90:13
    |
-LL |     let x = "foo";
-   |         - help: consider changing this to be mutable: `mut x`
-...
 LL |     let y = &mut x;
    |             ^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut x = "foo";
+   |         +++
 
 error: aborting due to previous error
 
index 9562d94509ea8f479e44caaf578337b9a78aae1f..1670da55957d073097397d628acc8f0225dea82d 100644 (file)
@@ -1,26 +1,35 @@
 error[E0596]: cannot borrow `f.v` as mutable, as `f` is not declared as mutable
   --> $DIR/issue-35937.rs:7:5
    |
-LL |     let f = Foo { v: Vec::new() };
-   |         - help: consider changing this to be mutable: `mut f`
 LL |     f.v.push("cat".to_string());
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut f = Foo { v: Vec::new() };
+   |         +++
 
 error[E0594]: cannot assign to `s.x`, as `s` is not declared as mutable
   --> $DIR/issue-35937.rs:16:5
    |
-LL |     let s = S { x: 42 };
-   |         - help: consider changing this to be mutable: `mut s`
 LL |     s.x += 1;
    |     ^^^^^^^^ cannot assign
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut s = S { x: 42 };
+   |         +++
 
 error[E0594]: cannot assign to `s.x`, as `s` is not declared as mutable
   --> $DIR/issue-35937.rs:20:5
    |
-LL | fn bar(s: S) {
-   |        - help: consider changing this to be mutable: `mut s`
 LL |     s.x += 1;
    |     ^^^^^^^^ cannot assign
+   |
+help: consider changing this to be mutable
+   |
+LL | fn bar(mut s: S) {
+   |        +++
 
 error: aborting due to 3 previous errors
 
index b16309af0418d8a48e4853183a1146944924b9f9..8dc0512a9453dbafd54f2d28c73803ba9abcee84 100644 (file)
@@ -1,10 +1,13 @@
 error[E0596]: cannot borrow `z.x` as mutable, as `z` is not declared as mutable
   --> $DIR/issue-39544.rs:11:13
    |
-LL |     let z = Z { x: X::Y };
-   |         - help: consider changing this to be mutable: `mut z`
 LL |     let _ = &mut z.x;
    |             ^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut z = Z { x: X::Y };
+   |         +++
 
 error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference
   --> $DIR/issue-39544.rs:16:17
@@ -97,10 +100,13 @@ LL |     fn foo4(other: &mut Z) {
 error[E0596]: cannot borrow `z.x` as mutable, as `z` is not declared as mutable
   --> $DIR/issue-39544.rs:41:13
    |
-LL | pub fn with_arg(z: Z, w: &Z) {
-   |                 - help: consider changing this to be mutable: `mut z`
 LL |     let _ = &mut z.x;
    |             ^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL | pub fn with_arg(mut z: Z, w: &Z) {
+   |                 +++
 
 error[E0596]: cannot borrow `w.x` as mutable, as it is behind a `&` reference
   --> $DIR/issue-39544.rs:42:13
index 79bc258f1fae7a7605430fbfa344818374166b47..3f9aebcc8aeadca8739d4114b0956d42616beb6f 100644 (file)
@@ -1,10 +1,13 @@
 error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
   --> $DIR/E0596.rs:3:13
    |
-LL |     let x = 1;
-   |         - help: consider changing this to be mutable: `mut x`
 LL |     let y = &mut x;
    |             ^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut x = 1;
+   |         +++
 
 error: aborting due to previous error
 
index 3b37578f3c4551497c0a7a523839b32b548da32e..5b753c69d5d10a419e720d44054f263f3e032558 100644 (file)
@@ -1,10 +1,13 @@
 error[E0596]: cannot borrow `*x` as mutable, as `x` is not declared as mutable
   --> $DIR/issue-36400.rs:5:7
    |
-LL |     let x = Box::new(3);
-   |         - help: consider changing this to be mutable: `mut x`
 LL |     f(&mut *x);
    |       ^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut x = Box::new(3);
+   |         +++
 
 error: aborting due to previous error
 
index a909c5fa82351ddb2d59dfc4aaf49b5cfc032b8b..cc2447b1877500969643db39e02dd8cec7dae309 100644 (file)
@@ -16,10 +16,13 @@ LL | fn foo<'a>(x:fn(&u8, &u8), y: Vec<&'a u8>, z: &'a u8) {
 error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable
   --> $DIR/ex3-both-anon-regions-using-fn-items.rs:2:3
    |
-LL | fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) {
-   |                        - help: consider changing this to be mutable: `mut y`
 LL |   y.push(z);
    |   ^^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL | fn foo(x:fn(&u8, &u8), mut y: Vec<&u8>, z: &u8) {
+   |                        +++
 
 error: aborting due to 2 previous errors
 
index d85ea6529f628e08ea4272e961a378d99a8315bb..2ba5afa808d734af4f66474b92e25d291d6f62b3 100644 (file)
@@ -16,10 +16,13 @@ LL | fn foo<'a>(x:Box<dyn Fn(&u8, &u8)> , y: Vec<&'a u8>, z: &'a u8) {
 error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable
   --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:2:3
    |
-LL | fn foo(x:Box<dyn Fn(&u8, &u8)> , y: Vec<&u8>, z: &u8) {
-   |                                  - help: consider changing this to be mutable: `mut y`
 LL |   y.push(z);
    |   ^^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL | fn foo(x:Box<dyn Fn(&u8, &u8)> , mut y: Vec<&u8>, z: &u8) {
+   |                                  +++
 
 error: aborting due to 2 previous errors
 
index ce3424a8b15f07f8eb09aa870f29cdeb6e19c03a..e57347b362dd4faaea384624031cca90310ad816 100644 (file)
@@ -1,8 +1,6 @@
 error[E0596]: cannot borrow `foo` as mutable, as it is not declared as mutable
   --> $DIR/span-covering-argument-1.rs:5:14
    |
-LL |             let $s = 0;
-   |                 -- help: consider changing this to be mutable: `mut foo`
 LL |             *&mut $s = 0;
    |              ^^^^^^^ cannot borrow as mutable
 ...
@@ -10,6 +8,10 @@ LL |     bad!(foo whatever);
    |     ------------------ in this macro invocation
    |
    = note: this error originates in the macro `bad` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: consider changing this to be mutable
+   |
+LL |             let mut $s = 0;
+   |                 +++
 
 error: aborting due to previous error
 
index 3104b20aca4e6428bdb75035eed5e9ef7681934e..8c269d1e727643e96a43a28f115014bfa30a1c00 100644 (file)
@@ -8,7 +8,7 @@ fn mutate(&mut self) {
 
 fn func(arg: S) {
     //~^ HELP consider changing this to be mutable
-    //~| SUGGESTION mut arg
+    //~| SUGGESTION mut
     arg.mutate();
     //~^ ERROR cannot borrow `arg` as mutable, as it is not declared as mutable
 }
@@ -16,7 +16,7 @@ fn func(arg: S) {
 fn main() {
     let local = S;
     //~^ HELP consider changing this to be mutable
-    //~| SUGGESTION mut local
+    //~| SUGGESTION mut
     local.mutate();
     //~^ ERROR cannot borrow `local` as mutable, as it is not declared as mutable
 }
index cba284550b95a3cb818dd5ad8c693a3006c78669..d89c8b41304af7ed3a7d370da726771e46e954d6 100644 (file)
@@ -1,20 +1,24 @@
 error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable
   --> $DIR/mut-suggestion.rs:12:5
    |
-LL | fn func(arg: S) {
-   |         --- help: consider changing this to be mutable: `mut arg`
-...
 LL |     arg.mutate();
    |     ^^^^^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL | fn func(mut arg: S) {
+   |         +++
 
 error[E0596]: cannot borrow `local` as mutable, as it is not declared as mutable
   --> $DIR/mut-suggestion.rs:20:5
    |
-LL |     let local = S;
-   |         ----- help: consider changing this to be mutable: `mut local`
-...
 LL |     local.mutate();
    |     ^^^^^^^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut local = S;
+   |         +++
 
 error: aborting due to 2 previous errors
 
index 40a0dc9b29c238223d00e8aab5b98582d59eef48..1d731be8a855db5d550d23c0bbab88869abdbbc1 100644 (file)
@@ -1,10 +1,13 @@
 error[E0594]: cannot assign to `nyan.how_hungry`, as `nyan` is not declared as mutable
   --> $DIR/mutable-class-fields.rs:15:3
    |
-LL |   let nyan : Cat = cat(52, 99);
-   |       ---- help: consider changing this to be mutable: `mut nyan`
 LL |   nyan.how_hungry = 0;
    |   ^^^^^^^^^^^^^^^^^^^ cannot assign
+   |
+help: consider changing this to be mutable
+   |
+LL |   let mut nyan : Cat = cat(52, 99);
+   |       +++
 
 error: aborting due to previous error
 
index 63ca6ae5c284164a641021957fcc03a54d37b309..27b1f8705ff1c163840726f7b110d80e730b0012 100644 (file)
@@ -30,10 +30,13 @@ LL |         (&mut self).bar();
 error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable
   --> $DIR/issue-51191.rs:13:9
    |
-LL |     fn imm(self) {
-   |            ---- help: consider changing this to be mutable: `mut self`
 LL |         (&mut self).bar();
    |         ^^^^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     fn imm(mut self) {
+   |            +++
 
 error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable
   --> $DIR/issue-51191.rs:22:9
index 70beb5d423223888072bf6072c552320a1d5c96b..54118dc367770cc90c2a71bbcbd40c9499045594 100644 (file)
@@ -1,20 +1,24 @@
 error[E0596]: cannot borrow `not_mut` as mutable, as it is not declared as mutable
   --> $DIR/nested-binding-modes-mut.rs:4:5
    |
-LL |     let mut is_mut @ not_mut = 42;
-   |                      ------- help: consider changing this to be mutable: `mut not_mut`
-LL |     &mut is_mut;
 LL |     &mut not_mut;
    |     ^^^^^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut is_mut @ mut not_mut = 42;
+   |                      +++
 
 error[E0596]: cannot borrow `not_mut` as mutable, as it is not declared as mutable
   --> $DIR/nested-binding-modes-mut.rs:9:5
    |
-LL |     let not_mut @ mut is_mut = 42;
-   |         ------- help: consider changing this to be mutable: `mut not_mut`
-LL |     &mut is_mut;
 LL |     &mut not_mut;
    |     ^^^^^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut not_mut @ mut is_mut = 42;
+   |         +++
 
 error: aborting due to 2 previous errors
 
index 20330c92325e4f15516311658ebf2cee121005d9..570328fc211f98b052a9ae7185d053312fb2fbcd 100644 (file)
@@ -1,10 +1,13 @@
 error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
   --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:53:24
    |
-LL | fn deref_mut_field1(x: Own<Point>) {
-   |                     - help: consider changing this to be mutable: `mut x`
 LL |     let __isize = &mut x.y;
    |                        ^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL | fn deref_mut_field1(mut x: Own<Point>) {
+   |                     +++
 
 error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
   --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:65:10
@@ -30,10 +33,13 @@ LL |     use_mut(_x);
 error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
   --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:88:5
    |
-LL | fn assign_field1<'a>(x: Own<Point>) {
-   |                      - help: consider changing this to be mutable: `mut x`
 LL |     x.y = 3;
    |     ^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL | fn assign_field1<'a>(mut x: Own<Point>) {
+   |                      +++
 
 error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
   --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:92:5
@@ -59,10 +65,13 @@ LL |     use_mut(_p);
 error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
   --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:109:5
    |
-LL | fn deref_mut_method1(x: Own<Point>) {
-   |                      - help: consider changing this to be mutable: `mut x`
 LL |     x.set(0, 0);
    |     ^^^^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL | fn deref_mut_method1(mut x: Own<Point>) {
+   |                      +++
 
 error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
   --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:121:5
@@ -78,10 +87,13 @@ LL | fn deref_extend_mut_method1(x: &mut Own<Point>) -> &mut isize {
 error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
   --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:129:6
    |
-LL | fn assign_method1<'a>(x: Own<Point>) {
-   |                       - help: consider changing this to be mutable: `mut x`
 LL |     *x.y_mut() = 3;
    |      ^^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL | fn assign_method1<'a>(mut x: Own<Point>) {
+   |                       +++
 
 error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
   --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:133:6
index 6d34909e43b965d84d37b7cb6c7aaedf1d63c548..3fed7b3f4dcf3afd2da5944de1cc0278429df860 100644 (file)
@@ -1,10 +1,13 @@
 error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
   --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:29:25
    |
-LL | fn deref_mut1(x: Own<isize>) {
-   |               - help: consider changing this to be mutable: `mut x`
 LL |     let __isize = &mut *x;
    |                         ^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL | fn deref_mut1(mut x: Own<isize>) {
+   |               +++
 
 error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
   --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:41:11
@@ -20,10 +23,13 @@ LL | fn deref_extend_mut1<'a>(x: &'a mut Own<isize>) -> &'a mut isize {
 error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
   --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:49:6
    |
-LL | fn assign1<'a>(x: Own<isize>) {
-   |                - help: consider changing this to be mutable: `mut x`
 LL |     *x = 3;
    |      ^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL | fn assign1<'a>(mut x: Own<isize>) {
+   |                +++
 
 error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
   --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:53:6
index e63ca95eff01d6160c78d12ee8cbdfd37ca270a6..b6517e0b3095dc3430306bf7aa3373d544cc234a 100644 (file)
@@ -12,11 +12,13 @@ LL | fn borrowed_receiver(x: &mut dyn Foo) {
 error[E0596]: cannot borrow `*x` as mutable, as `x` is not declared as mutable
   --> $DIR/borrowck-object-mutability.rs:18:5
    |
-LL | fn owned_receiver(x: Box<dyn Foo>) {
-   |                   - help: consider changing this to be mutable: `mut x`
-LL |     x.borrowed();
 LL |     x.borrowed_mut();
    |     ^^^^^^^^^^^^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL | fn owned_receiver(mut x: Box<dyn Foo>) {
+   |                   +++
 
 error: aborting due to 2 previous errors
 
index a0ed56d4bcf7bf20ff20ce696debf0734bb9d5aa..5c93ed6d7f70f471ae74f2b826bc6279745baea6 100644 (file)
@@ -12,13 +12,16 @@ LL |         tick1();
 error[E0596]: cannot borrow `tick2` as mutable, as it is not declared as mutable
   --> $DIR/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs:19:5
    |
-LL |     let tick2 = || {
-   |         ----- help: consider changing this to be mutable: `mut tick2`
 LL |         tick1();
    |         ----- calling `tick2` requires mutable binding due to mutable borrow of `tick1`
 ...
 LL |     tick2();
    |     ^^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut tick2 = || {
+   |         +++
 
 error: aborting due to 2 previous errors
 
index 27d23e3fa044bb5f261478c435f44f0971da4639..3f539c42d9b311150db5ba0f4305132cb14853c3 100644 (file)
@@ -2,11 +2,14 @@ error[E0596]: cannot borrow `tick` as mutable, as it is not declared as mutable
   --> $DIR/unboxed-closures-infer-fnmut-missing-mut.rs:7:5
    |
 LL |     let tick = || counter += 1;
-   |         ----      ------- calling `tick` requires mutable binding due to mutable borrow of `counter`
-   |         |
-   |         help: consider changing this to be mutable: `mut tick`
+   |                   ------- calling `tick` requires mutable binding due to mutable borrow of `counter`
 LL |     tick();
    |     ^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut tick = || counter += 1;
+   |         +++
 
 error: aborting due to previous error
 
index c00f986c397a7240012490b0823521d9a8c82d3e..e3b19297b9c18d086b25f99c19d8de856bfa9986 100644 (file)
@@ -2,11 +2,14 @@ error[E0596]: cannot borrow `tick` as mutable, as it is not declared as mutable
   --> $DIR/unboxed-closures-infer-fnmut-move-missing-mut.rs:7:5
    |
 LL |     let tick = move || counter += 1;
-   |         ----           ------- calling `tick` requires mutable binding due to possible mutation of `counter`
-   |         |
-   |         help: consider changing this to be mutable: `mut tick`
+   |                        ------- calling `tick` requires mutable binding due to possible mutation of `counter`
 LL |     tick();
    |     ^^^^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut tick = move || counter += 1;
+   |         +++
 
 error: aborting due to previous error
 
index a65765c86c8b72956532f957a56087d128e5eb4f..286267c3834abc3b5e5f3fe7ea61fb23b74ba549 100644 (file)
@@ -1,10 +1,13 @@
 error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable
   --> $DIR/writing-to-immutable-vec.rs:3:5
    |
-LL |     let v: Vec<isize> = vec![1, 2, 3];
-   |         - help: consider changing this to be mutable: `mut v`
 LL |     v[1] = 4;
    |     ^ cannot borrow as mutable
+   |
+help: consider changing this to be mutable
+   |
+LL |     let mut v: Vec<isize> = vec![1, 2, 3];
+   |         +++
 
 error: aborting due to previous error