]> git.lizzy.rs Git - rust.git/commitdiff
Use verbose suggestions for mutability errors
authorEsteban Küber <esteban@kuber.com.ar>
Thu, 29 Dec 2022 05:52:57 +0000 (21:52 -0800)
committerEsteban Küber <esteban@kuber.com.ar>
Thu, 29 Dec 2022 06:06:25 +0000 (22:06 -0800)
34 files changed:
compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
src/test/ui/array-slice-vec/slice-mut-2.stderr
src/test/ui/borrowck/borrow-raw-address-of-deref-mutability.stderr
src/test/ui/borrowck/borrowck-access-permissions.stderr
src/test/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr
src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr
src/test/ui/borrowck/borrowck-issue-14498.stderr
src/test/ui/borrowck/borrowck-reborrow-from-mut.stderr
src/test/ui/borrowck/issue-85765.stderr
src/test/ui/borrowck/issue-93093.stderr
src/test/ui/borrowck/mutability-errors.stderr
src/test/ui/closures/2229_closure_analysis/diagnostics/mut_ref.stderr
src/test/ui/did_you_mean/issue-38147-1.stderr
src/test/ui/did_you_mean/issue-38147-4.stderr
src/test/ui/did_you_mean/issue-39544.stderr
src/test/ui/did_you_mean/issue-40823.stderr
src/test/ui/error-codes/E0389.stderr
src/test/ui/issues/issue-51515.stderr
src/test/ui/issues/issue-61623.stderr
src/test/ui/mut/mutable-class-fields-2.stderr
src/test/ui/nll/issue-47388.stderr
src/test/ui/nll/issue-51244.stderr
src/test/ui/nll/issue-57989.stderr
src/test/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.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-call-is-borrow-issue-12224.stderr
src/test/ui/span/borrowck-call-method-from-mut-aliasable.stderr
src/test/ui/span/borrowck-fn-in-const-b.stderr
src/test/ui/span/borrowck-object-mutability.stderr
src/test/ui/span/mut-arg-hint.stderr
src/test/ui/suggestions/issue-68049-2.stderr
src/test/ui/suggestions/suggest-ref-mut.stderr
src/test/ui/trivial-bounds/trivial-bounds-inconsistent-copy-reborrow.stderr

index 3319a80681fde277dc0fd3f361c2656adfafe6b6..05c718d5802051df69b0441426a1db5a74e46d1b 100644 (file)
@@ -333,7 +333,7 @@ pub(crate) fn report_mutability_error(
                 let local_decl = &self.body.local_decls[local];
                 assert_eq!(local_decl.mutability, Mutability::Not);
 
-                err.span_label(span, format!("cannot {ACT}", ACT = act));
+                err.span_label(span, format!("cannot {act}"));
                 err.span_suggestion(
                     local_decl.source_info.span,
                     "consider changing this to be mutable",
@@ -357,7 +357,7 @@ pub(crate) fn report_mutability_error(
 
                 let captured_place = &self.upvars[upvar_index.index()].place;
 
-                err.span_label(span, format!("cannot {ACT}", ACT = act));
+                err.span_label(span, format!("cannot {act}"));
 
                 let upvar_hir_id = captured_place.get_root_variable();
 
@@ -397,7 +397,7 @@ pub(crate) fn report_mutability_error(
                     .span_to_snippet(span)
                     .map_or(false, |snippet| snippet.starts_with("&mut ")) =>
             {
-                err.span_label(span, format!("cannot {ACT}", ACT = act));
+                err.span_label(span, format!("cannot {act}"));
                 err.span_suggestion(
                     span,
                     "try removing `&mut` here",
@@ -409,7 +409,7 @@ pub(crate) fn report_mutability_error(
             PlaceRef { local, projection: [ProjectionElem::Deref] }
                 if self.body.local_decls[local].is_ref_for_guard() =>
             {
-                err.span_label(span, format!("cannot {ACT}", ACT = act));
+                err.span_label(span, format!("cannot {act}"));
                 err.note(
                     "variables bound in patterns are immutable until the end of the pattern guard",
                 );
@@ -537,7 +537,7 @@ pub(crate) fn report_mutability_error(
                             Some((true, err_help_span, suggested_code)) => {
                                 let (is_trait_sig, local_trait) = self.is_error_in_trait(local);
                                 if !is_trait_sig {
-                                    err.span_suggestion(
+                                    err.span_suggestion_verbose(
                                         err_help_span,
                                         &format!(
                                             "consider changing this to be a mutable {pointer_desc}"
@@ -546,7 +546,7 @@ pub(crate) fn report_mutability_error(
                                         Applicability::MachineApplicable,
                                     );
                                 } else if let Some(x) = local_trait {
-                                    err.span_suggestion(
+                                    err.span_suggestion_verbose(
                                         x,
                                         &format!(
                                             "consider changing that to be a mutable {pointer_desc}"
@@ -569,24 +569,15 @@ pub(crate) fn report_mutability_error(
                         err.span_label(
                             span,
                             format!(
-                                "`{NAME}` is a `{SIGIL}` {DESC}, \
-                                so the data it refers to cannot be {ACTED_ON}",
-                                NAME = name,
-                                SIGIL = pointer_sigil,
-                                DESC = pointer_desc,
-                                ACTED_ON = acted_on
+                                "`{name}` is a `{pointer_sigil}` {pointer_desc}, \
+                                 so the data it refers to cannot be {acted_on}",
                             ),
                         );
                     }
                     _ => {
                         err.span_label(
                             span,
-                            format!(
-                                "cannot {ACT} through `{SIGIL}` {DESC}",
-                                ACT = act,
-                                SIGIL = pointer_sigil,
-                                DESC = pointer_desc
-                            ),
+                            format!("cannot {act} through `{pointer_sigil}` {pointer_desc}"),
                         );
                     }
                 }
@@ -605,13 +596,13 @@ pub(crate) fn report_mutability_error(
                     Some(BorrowedContentSource::OverloadedDeref(ty)) => {
                         err.help(&format!(
                             "trait `DerefMut` is required to modify through a dereference, \
-                                but it is not implemented for `{ty}`",
+                             but it is not implemented for `{ty}`",
                         ));
                     }
                     Some(BorrowedContentSource::OverloadedIndex(ty)) => {
                         err.help(&format!(
                             "trait `IndexMut` is required to modify indexed content, \
-                                but it is not implemented for `{ty}`",
+                             but it is not implemented for `{ty}`",
                         ));
                         self.suggest_map_index_mut_alternatives(ty, &mut err, span);
                     }
@@ -620,7 +611,7 @@ pub(crate) fn report_mutability_error(
             }
 
             _ => {
-                err.span_label(span, format!("cannot {ACT}", ACT = act));
+                err.span_label(span, format!("cannot {act}"));
             }
         }
 
index bad0268772b79185be9595194533667595ec8449..5b040d3e4d31db2839ff0ec87580506e2e73e30c 100644 (file)
@@ -1,11 +1,13 @@
 error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
   --> $DIR/slice-mut-2.rs:7:18
    |
-LL |     let x: &[isize] = &[1, 2, 3, 4, 5];
-   |                       ---------------- help: consider changing this to be a mutable reference: `&mut [1, 2, 3, 4, 5]`
-...
 LL |     let _ = &mut x[2..4];
    |                  ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     let x: &[isize] = &mut [1, 2, 3, 4, 5];
+   |                       ~~~~~~~~~~~~~~~~~~~~
 
 error: aborting due to previous error
 
index 5963dab9f4aab255fa97c9f4f5a5cd22182a526f..4cc1d821d0a06e6e245041ddbc8f49ae80f9d950 100644 (file)
@@ -1,20 +1,24 @@
 error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
   --> $DIR/borrow-raw-address-of-deref-mutability.rs:8:13
    |
-LL |     let x = &0;
-   |             -- help: consider changing this to be a mutable reference: `&mut 0`
-LL |
 LL |     let q = &raw mut *x;
    |             ^^^^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     let x = &mut 0;
+   |             ~~~~~~
 
 error[E0596]: cannot borrow `*x` as mutable, as it is behind a `*const` pointer
   --> $DIR/borrow-raw-address-of-deref-mutability.rs:14:13
    |
-LL |     let x = &0 as *const i32;
-   |             -- help: consider changing this to be a mutable pointer: `&mut 0`
-LL |
 LL |     let q = &raw mut *x;
    |             ^^^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable pointer
+   |
+LL |     let x = &mut 0 as *const i32;
+   |             ~~~~~~
 
 error: aborting due to 2 previous errors
 
index e3a35c38a7c0373aaa52d10d666e35c072c671ea..312720898473a9717d84ce3e1eedfe39ad786a38 100644 (file)
@@ -25,28 +25,35 @@ LL |         let _y1 = &mut *box_x;
 error[E0596]: cannot borrow `*ref_x` as mutable, as it is behind a `&` reference
   --> $DIR/borrowck-access-permissions.rs:30:19
    |
-LL |         let ref_x = &x;
-   |                     -- help: consider changing this to be a mutable reference: `&mut x`
-...
 LL |         let _y1 = &mut *ref_x;
    |                   ^^^^^^^^^^^ `ref_x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |         let ref_x = &mut x;
+   |                     ~~~~~~
 
 error[E0596]: cannot borrow `*ptr_x` as mutable, as it is behind a `*const` pointer
   --> $DIR/borrowck-access-permissions.rs:39:23
    |
-LL |         let ptr_x : *const _ = &x;
-   |                                -- help: consider changing this to be a mutable pointer: `&mut x`
-...
 LL |             let _y1 = &mut *ptr_x;
    |                       ^^^^^^^^^^^ `ptr_x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable pointer
+   |
+LL |         let ptr_x : *const _ = &mut x;
+   |                                ~~~~~~
 
 error[E0596]: cannot borrow `*foo_ref.f` as mutable, as it is behind a `&` reference
   --> $DIR/borrowck-access-permissions.rs:48:18
    |
-LL |         let foo_ref = &foo;
-   |                       ---- help: consider changing this to be a mutable reference: `&mut foo`
 LL |         let _y = &mut *foo_ref.f;
    |                  ^^^^^^^^^^^^^^^ `foo_ref` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |         let foo_ref = &mut foo;
+   |                       ~~~~~~~~
 
 error: aborting due to 6 previous errors
 
index 0475df447445df05067ce82fab23feb4ebe0b11e..cbacc87a0e85845e7cbce3efccbe71c093dd02dd 100644 (file)
@@ -1,18 +1,24 @@
 error[E0594]: cannot assign to `*s.pointer`, which is behind a `&` reference
   --> $DIR/borrowck-assign-to-andmut-in-aliasable-loc.rs:9:5
    |
-LL | fn a(s: &S) {
-   |         -- help: consider changing this to be a mutable reference: `&mut S<'_>`
 LL |     *s.pointer += 1;
    |     ^^^^^^^^^^^^^^^ `s` is a `&` reference, so the data it refers to cannot be written
+   |
+help: consider changing this to be a mutable reference
+   |
+LL | fn a(s: &mut S<'_>) {
+   |         ~~~~~~~~~~
 
 error[E0594]: cannot assign to `*s.pointer`, which is behind a `&` reference
   --> $DIR/borrowck-assign-to-andmut-in-aliasable-loc.rs:17:5
    |
-LL | fn c(s: & &mut S) {
-   |         -------- help: consider changing this to be a mutable reference: `&mut &mut S<'_>`
 LL |     *s.pointer += 1;
    |     ^^^^^^^^^^^^^^^ `s` is a `&` reference, so the data it refers to cannot be written
+   |
+help: consider changing this to be a mutable reference
+   |
+LL | fn c(s: &mut &mut S<'_>) {
+   |         ~~~~~~~~~~~~~~~
 
 error: aborting due to 2 previous errors
 
index c99c0f77982edecf4a03edc402f7f8afb3526755..ce9f7aa050a0aca647a80a16cfc7471afa4784f4 100644 (file)
@@ -20,10 +20,13 @@ LL |     **t1 = 22;
 error[E0596]: cannot borrow `**t0` as mutable, as it is behind a `&` reference
   --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:19:26
    |
-LL | fn foo4(t0: & &mut isize) {
-   |             ------------ help: consider changing this to be a mutable reference: `&mut &mut isize`
 LL |     let x:  &mut isize = &mut **t0;
    |                          ^^^^^^^^^ `t0` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL | fn foo4(t0: &mut &mut isize) {
+   |             ~~~~~~~~~~~~~~~
 
 error: aborting due to 3 previous errors
 
index 4c0e46d453142eeb838bd463b2a857e981ae559f..42a55b7a854ba407b8670ea37dde36b86c61302f 100644 (file)
@@ -1,10 +1,13 @@
 error[E0594]: cannot assign to `***p`, which is behind a `&` reference
   --> $DIR/borrowck-issue-14498.rs:16:5
    |
-LL |     let p = &y;
-   |             -- help: consider changing this to be a mutable reference: `&mut y`
 LL |     ***p = 2;
    |     ^^^^^^^^ `p` is a `&` reference, so the data it refers to cannot be written
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     let p = &mut y;
+   |             ~~~~~~
 
 error[E0506]: cannot assign to `**y` because it is borrowed
   --> $DIR/borrowck-issue-14498.rs:25:5
index 284cab296084292a147df652f889fc277b145a31..d9590e446c756b73ca4042777f310563728bc9b2 100644 (file)
@@ -105,10 +105,13 @@ LL |     use_imm(_bar1);
 error[E0596]: cannot borrow `foo.bar1` as mutable, as it is behind a `&` reference
   --> $DIR/borrowck-reborrow-from-mut.rs:88:17
    |
-LL | fn borrow_mut_from_imm(foo: &Foo) {
-   |                             ---- help: consider changing this to be a mutable reference: `&mut Foo`
 LL |     let _bar1 = &mut foo.bar1;
    |                 ^^^^^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL | fn borrow_mut_from_imm(foo: &mut Foo) {
+   |                             ~~~~~~~~
 
 error: aborting due to 11 previous errors
 
index 13033962142fa51583cd5065639db7221824a981..7da7dba68ab7aaf537a8a24ff100797e264f3f5c 100644 (file)
@@ -10,11 +10,13 @@ LL |     rofl.push(Vec::new());
 error[E0594]: cannot assign to `*r`, which is behind a `&` reference
   --> $DIR/issue-85765.rs:12:5
    |
-LL |     let r = &mutvar;
-   |             ------- help: consider changing this to be a mutable reference: `&mut mutvar`
-LL |
 LL |     *r = 0;
    |     ^^^^^^ `r` is a `&` reference, so the data it refers to cannot be written
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     let r = &mut mutvar;
+   |             ~~~~~~~~~~~
 
 error[E0594]: cannot assign to `*x`, which is behind a `&` reference
   --> $DIR/issue-85765.rs:19:5
index 031128af47655e34fa8cef6f8552eb2f887afabe..afa76594f0b5e71de8641ee857acda79a6dcd633 100644 (file)
@@ -1,11 +1,13 @@
 error[E0594]: cannot assign to `self.foo`, which is behind a `&` reference
   --> $DIR/issue-93093.rs:8:9
    |
-LL |     async fn bar(&self) {
-   |                  ----- help: consider changing this to be a mutable reference: `&mut self`
-LL |
 LL |         self.foo += 1;
    |         ^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     async fn bar(&mut self) {
+   |                  ~~~~~~~~~
 
 error: aborting due to previous error
 
index dd29ae492d604fa758dfc593df29f24f0f969942..7a00ace3bb220331d78982298c826e2fc3f4e100 100644 (file)
@@ -1,37 +1,46 @@
 error[E0594]: cannot assign to `*x`, which is behind a `&` reference
   --> $DIR/mutability-errors.rs:9:5
    |
-LL | fn named_ref(x: &(i32,)) {
-   |                 ------- help: consider changing this to be a mutable reference: `&mut (i32,)`
 LL |     *x = (1,);
    |     ^^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written
+   |
+help: consider changing this to be a mutable reference
+   |
+LL | fn named_ref(x: &mut (i32,)) {
+   |                 ~~~~~~~~~~~
 
 error[E0594]: cannot assign to `x.0`, which is behind a `&` reference
   --> $DIR/mutability-errors.rs:10:5
    |
-LL | fn named_ref(x: &(i32,)) {
-   |                 ------- help: consider changing this to be a mutable reference: `&mut (i32,)`
-LL |     *x = (1,);
 LL |     x.0 = 1;
    |     ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written
+   |
+help: consider changing this to be a mutable reference
+   |
+LL | fn named_ref(x: &mut (i32,)) {
+   |                 ~~~~~~~~~~~
 
 error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
   --> $DIR/mutability-errors.rs:11:5
    |
-LL | fn named_ref(x: &(i32,)) {
-   |                 ------- help: consider changing this to be a mutable reference: `&mut (i32,)`
-...
 LL |     &mut *x;
    |     ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL | fn named_ref(x: &mut (i32,)) {
+   |                 ~~~~~~~~~~~
 
 error[E0596]: cannot borrow `x.0` as mutable, as it is behind a `&` reference
   --> $DIR/mutability-errors.rs:12:5
    |
-LL | fn named_ref(x: &(i32,)) {
-   |                 ------- help: consider changing this to be a mutable reference: `&mut (i32,)`
-...
 LL |     &mut x.0;
    |     ^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL | fn named_ref(x: &mut (i32,)) {
+   |                 ~~~~~~~~~~~
 
 error[E0594]: cannot assign to data in a `&` reference
   --> $DIR/mutability-errors.rs:16:5
@@ -60,37 +69,46 @@ LL |     &mut f().0;
 error[E0594]: cannot assign to `*x`, which is behind a `*const` pointer
   --> $DIR/mutability-errors.rs:23:5
    |
-LL | unsafe fn named_ptr(x: *const (i32,)) {
-   |                        ------------- help: consider changing this to be a mutable pointer: `*mut (i32,)`
 LL |     *x = (1,);
    |     ^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be written
+   |
+help: consider changing this to be a mutable pointer
+   |
+LL | unsafe fn named_ptr(x: *mut (i32,)) {
+   |                        ~~~~~~~~~~~
 
 error[E0594]: cannot assign to `x.0`, which is behind a `*const` pointer
   --> $DIR/mutability-errors.rs:24:5
    |
-LL | unsafe fn named_ptr(x: *const (i32,)) {
-   |                        ------------- help: consider changing this to be a mutable pointer: `*mut (i32,)`
-LL |     *x = (1,);
 LL |     (*x).0 = 1;
    |     ^^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be written
+   |
+help: consider changing this to be a mutable pointer
+   |
+LL | unsafe fn named_ptr(x: *mut (i32,)) {
+   |                        ~~~~~~~~~~~
 
 error[E0596]: cannot borrow `*x` as mutable, as it is behind a `*const` pointer
   --> $DIR/mutability-errors.rs:25:5
    |
-LL | unsafe fn named_ptr(x: *const (i32,)) {
-   |                        ------------- help: consider changing this to be a mutable pointer: `*mut (i32,)`
-...
 LL |     &mut *x;
    |     ^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable pointer
+   |
+LL | unsafe fn named_ptr(x: *mut (i32,)) {
+   |                        ~~~~~~~~~~~
 
 error[E0596]: cannot borrow `x.0` as mutable, as it is behind a `*const` pointer
   --> $DIR/mutability-errors.rs:26:5
    |
-LL | unsafe fn named_ptr(x: *const (i32,)) {
-   |                        ------------- help: consider changing this to be a mutable pointer: `*mut (i32,)`
-...
 LL |     &mut (*x).0;
    |     ^^^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable pointer
+   |
+LL | unsafe fn named_ptr(x: *mut (i32,)) {
+   |                        ~~~~~~~~~~~
 
 error[E0594]: cannot assign to data in a `*const` pointer
   --> $DIR/mutability-errors.rs:30:5
index 481d7e58529eebe089afd91fe0460ba870b05600..95f36fc042c4fd8668725c98a2cc28a1560f4efb 100644 (file)
@@ -1,14 +1,16 @@
 error[E0596]: cannot borrow `**ref_mref_x` as mutable, as it is behind a `&` reference
   --> $DIR/mut_ref.rs:12:13
    |
-LL |     let ref_mref_x = &mref_x;
-   |                      ------- help: consider changing this to be a mutable reference: `&mut mref_x`
-LL |
 LL |     let c = || {
    |             ^^ `ref_mref_x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
 LL |
 LL |         **ref_mref_x = y;
    |         ------------ mutable borrow occurs due to use of `**ref_mref_x` in closure
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     let ref_mref_x = &mut mref_x;
+   |                      ~~~~~~~~~~~
 
 error[E0596]: cannot borrow `**mref_ref_x` as mutable, as it is behind a `&` reference
   --> $DIR/mut_ref.rs:26:13
index dd193458b3726bc8294c046191ddbee6ef279246..74fb1c2eca30771bce01691c7cd03514baa9b7d9 100644 (file)
@@ -1,10 +1,13 @@
 error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` reference
   --> $DIR/issue-38147-1.rs:17:9
    |
-LL |     fn f(&self) {
-   |          ----- help: consider changing this to be a mutable reference: `&mut self`
 LL |         self.s.push('x');
    |         ^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     fn f(&mut self) {
+   |          ~~~~~~~~~
 
 error: aborting due to previous error
 
index a2d162f08a173cbf2d56be888ccb470da09eb97b..d3339989361694c840542ea437695f992cc189bb 100644 (file)
@@ -1,10 +1,13 @@
 error[E0596]: cannot borrow `*f.s` as mutable, as it is behind a `&` reference
   --> $DIR/issue-38147-4.rs:6:5
    |
-LL | fn f(x: usize, f: &Foo) {
-   |                   ---- help: consider changing this to be a mutable reference: `&mut Foo<'_>`
 LL |     f.s.push('x');
    |     ^^^^^^^^^^^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL | fn f(x: usize, f: &mut Foo<'_>) {
+   |                   ~~~~~~~~~~~~
 
 error: aborting due to previous error
 
index 68180eaee036c41f1fa7d80fa88fead6bb498250..b16309af0418d8a48e4853183a1146944924b9f9 100644 (file)
@@ -9,69 +9,90 @@ LL |     let _ = &mut z.x;
 error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference
   --> $DIR/issue-39544.rs:16:17
    |
-LL |     fn foo<'z>(&'z self) {
-   |                -------- help: consider changing this to be a mutable reference: `&'z mut self`
 LL |         let _ = &mut self.x;
    |                 ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     fn foo<'z>(&'z mut self) {
+   |                ~~~~~~~~~~~~
 
 error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference
   --> $DIR/issue-39544.rs:20:17
    |
-LL |     fn foo1(&self, other: &Z) {
-   |             ----- help: consider changing this to be a mutable reference: `&mut self`
 LL |         let _ = &mut self.x;
    |                 ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     fn foo1(&mut self, other: &Z) {
+   |             ~~~~~~~~~
 
 error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference
   --> $DIR/issue-39544.rs:21:17
    |
-LL |     fn foo1(&self, other: &Z) {
-   |                           -- help: consider changing this to be a mutable reference: `&mut Z`
-LL |         let _ = &mut self.x;
 LL |         let _ = &mut other.x;
    |                 ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     fn foo1(&self, other: &mut Z) {
+   |                           ~~~~~~
 
 error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference
   --> $DIR/issue-39544.rs:25:17
    |
-LL |     fn foo2<'a>(&'a self, other: &Z) {
-   |                 -------- help: consider changing this to be a mutable reference: `&'a mut self`
 LL |         let _ = &mut self.x;
    |                 ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     fn foo2<'a>(&'a mut self, other: &Z) {
+   |                 ~~~~~~~~~~~~
 
 error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference
   --> $DIR/issue-39544.rs:26:17
    |
-LL |     fn foo2<'a>(&'a self, other: &Z) {
-   |                                  -- help: consider changing this to be a mutable reference: `&mut Z`
-LL |         let _ = &mut self.x;
 LL |         let _ = &mut other.x;
    |                 ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     fn foo2<'a>(&'a self, other: &mut Z) {
+   |                                  ~~~~~~
 
 error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference
   --> $DIR/issue-39544.rs:30:17
    |
-LL |     fn foo3<'a>(self: &'a Self, other: &Z) {
-   |                       -------- help: consider changing this to be a mutable reference: `&'a mut Self`
 LL |         let _ = &mut self.x;
    |                 ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     fn foo3<'a>(self: &'a mut Self, other: &Z) {
+   |                       ~~~~~~~~~~~~
 
 error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference
   --> $DIR/issue-39544.rs:31:17
    |
-LL |     fn foo3<'a>(self: &'a Self, other: &Z) {
-   |                                        -- help: consider changing this to be a mutable reference: `&mut Z`
-LL |         let _ = &mut self.x;
 LL |         let _ = &mut other.x;
    |                 ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     fn foo3<'a>(self: &'a Self, other: &mut Z) {
+   |                                        ~~~~~~
 
 error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference
   --> $DIR/issue-39544.rs:35:17
    |
-LL |     fn foo4(other: &Z) {
-   |                    -- help: consider changing this to be a mutable reference: `&mut Z`
 LL |         let _ = &mut other.x;
    |                 ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+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
@@ -84,11 +105,13 @@ LL |     let _ = &mut z.x;
 error[E0596]: cannot borrow `w.x` as mutable, as it is behind a `&` reference
   --> $DIR/issue-39544.rs:42:13
    |
-LL | pub fn with_arg(z: Z, w: &Z) {
-   |                          -- help: consider changing this to be a mutable reference: `&mut Z`
-LL |     let _ = &mut z.x;
 LL |     let _ = &mut w.x;
    |             ^^^^^^^^ `w` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL | pub fn with_arg(z: Z, w: &mut Z) {
+   |                          ~~~~~~
 
 error[E0594]: cannot assign to `*x.0`, which is behind a `&` reference
   --> $DIR/issue-39544.rs:48:5
index 67703a1497f50c7e60d6ebde2f621e9bd917a065..aadd698891edc7a5f9218c3491bdab65ac4cb407 100644 (file)
@@ -1,10 +1,13 @@
 error[E0596]: cannot borrow `*buf` as mutable, as it is behind a `&` reference
   --> $DIR/issue-40823.rs:3:5
    |
-LL |     let mut buf = &[1, 2, 3, 4];
-   |                   ------------- help: consider changing this to be a mutable reference: `&mut [1, 2, 3, 4]`
 LL |     buf.iter_mut();
    |     ^^^^^^^^^^^^^^ `buf` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     let mut buf = &mut [1, 2, 3, 4];
+   |                   ~~~~~~~~~~~~~~~~~
 
 error: aborting due to previous error
 
index 3d615bd932f436fe42e5c529664424ded3959616..51c4c92addf2856b413d36a2a10864f2b3756abb 100644 (file)
@@ -1,10 +1,13 @@
 error[E0594]: cannot assign to `fancy_ref.num`, which is behind a `&` reference
   --> $DIR/E0389.rs:8:5
    |
-LL |     let fancy_ref = &(&mut fancy);
-   |                     ------------- help: consider changing this to be a mutable reference: `&mut (&mut fancy)`
 LL |     fancy_ref.num = 6;
    |     ^^^^^^^^^^^^^^^^^ `fancy_ref` is a `&` reference, so the data it refers to cannot be written
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     let fancy_ref = &mut (&mut fancy);
+   |                     ~~~~~~~~~~~~~~~~~
 
 error: aborting due to previous error
 
index 067bdef8b6746c73a645eda9e50115ebbae0ebac..c4e61e719539280b1bc96b9e87fae6ae4c180ffd 100644 (file)
@@ -1,11 +1,13 @@
 error[E0594]: cannot assign to `*foo`, which is behind a `&` reference
   --> $DIR/issue-51515.rs:5:5
    |
-LL |     let foo = &16;
-   |               --- help: consider changing this to be a mutable reference: `&mut 16`
-...
 LL |     *foo = 32;
    |     ^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     let foo = &mut 16;
+   |               ~~~~~~~
 
 error[E0594]: cannot assign to `*bar`, which is behind a `&` reference
   --> $DIR/issue-51515.rs:8:5
index f654605423379849b5788867d7fa14b2bf3e6aca..5fcc338557c58c9e9c01a25b1f0ad5184d2d4ef6 100644 (file)
@@ -1,10 +1,13 @@
 error[E0596]: cannot borrow `*x.1` as mutable, as it is behind a `&` reference
   --> $DIR/issue-61623.rs:6:19
    |
-LL | fn f3<'a>(x: &'a ((), &'a mut ())) {
-   |              -------------------- help: consider changing this to be a mutable reference: `&'a mut ((), &'a mut ())`
 LL |     f2(|| x.0, f1(x.1))
    |                   ^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL | fn f3<'a>(x: &'a mut ((), &'a mut ())) {
+   |              ~~~~~~~~~~~~~~~~~~~~~~~~
 
 error: aborting due to previous error
 
index 5a4e31947f2b2e889a1ceee9b40625fe3c4a0270..c53c6ea302c6716feb0f9ad40a3f62df4a29e5c4 100644 (file)
@@ -1,10 +1,13 @@
 error[E0594]: cannot assign to `self.how_hungry`, which is behind a `&` reference
   --> $DIR/mutable-class-fields-2.rs:9:5
    |
-LL |   pub fn eat(&self) {
-   |              ----- help: consider changing this to be a mutable reference: `&mut self`
 LL |     self.how_hungry -= 5;
    |     ^^^^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |   pub fn eat(&mut self) {
+   |              ~~~~~~~~~
 
 error: aborting due to previous error
 
index a4ee7781753060f0bb8c6fbd7f5227d692f031c0..c780451dfa9355d9a74f2ce326c1b5474fcbcfc6 100644 (file)
@@ -1,10 +1,13 @@
 error[E0594]: cannot assign to `fancy_ref.num`, which is behind a `&` reference
   --> $DIR/issue-47388.rs:8:5
    |
-LL |     let fancy_ref = &(&mut fancy);
-   |                     ------------- help: consider changing this to be a mutable reference: `&mut (&mut fancy)`
 LL |     fancy_ref.num = 6;
    |     ^^^^^^^^^^^^^^^^^ `fancy_ref` is a `&` reference, so the data it refers to cannot be written
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     let fancy_ref = &mut (&mut fancy);
+   |                     ~~~~~~~~~~~~~~~~~
 
 error: aborting due to previous error
 
index dcb6f9fec18b6eb94aec31ecd326569227f1674c..03d8acc81886a3f1cc4ce3735554946adbd2ffcf 100644 (file)
@@ -1,10 +1,13 @@
 error[E0594]: cannot assign to `*my_ref`, which is behind a `&` reference
   --> $DIR/issue-51244.rs:3:5
    |
-LL |     let ref my_ref @ _ = 0;
-   |         ---------- help: consider changing this to be a mutable reference: `ref mut my_ref`
 LL |     *my_ref = 0;
    |     ^^^^^^^^^^^ `my_ref` is a `&` reference, so the data it refers to cannot be written
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     let ref mut my_ref @ _ = 0;
+   |         ~~~~~~~~~~~~~~
 
 error: aborting due to previous error
 
index e85e63e52ecc37bbec6731f5b2f1c34078cddf92..31f40d8252ed6a40745dc26e2606729a84cf5a8b 100644 (file)
@@ -1,11 +1,13 @@
 error[E0594]: cannot assign to `*x`, which is behind a `&` reference
   --> $DIR/issue-57989.rs:5:5
    |
-LL | fn f(x: &i32) {
-   |         ---- help: consider changing this to be a mutable reference: `&mut i32`
-LL |     let g = &x;
 LL |     *x = 0;
    |     ^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written
+   |
+help: consider changing this to be a mutable reference
+   |
+LL | fn f(x: &mut i32) {
+   |         ~~~~~~~~
 
 error[E0506]: cannot assign to `*x` because it is borrowed
   --> $DIR/issue-57989.rs:5:5
index bb7b818368b78dca3969c32b35f92d5c45371b04..1b93267b397714cf694a084d0b7a3da0100c90dd 100644 (file)
@@ -104,20 +104,24 @@ LL |     *_x0 = U;
 error[E0594]: cannot assign to `*_x0`, which is behind a `&` reference
   --> $DIR/borrowck-move-ref-pattern.rs:26:5
    |
-LL |     let (ref _x0, _x1, ref _x2, ..) = tup;
-   |          ------- help: consider changing this to be a mutable reference: `ref mut _x0`
-...
 LL |     *_x0 = U;
    |     ^^^^^^^^ `_x0` is a `&` reference, so the data it refers to cannot be written
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     let (ref mut _x0, _x1, ref _x2, ..) = tup;
+   |          ~~~~~~~~~~~
 
 error[E0594]: cannot assign to `*_x2`, which is behind a `&` reference
   --> $DIR/borrowck-move-ref-pattern.rs:27:5
    |
-LL |     let (ref _x0, _x1, ref _x2, ..) = tup;
-   |                        ------- help: consider changing this to be a mutable reference: `ref mut _x2`
-...
 LL |     *_x2 = U;
    |     ^^^^^^^^ `_x2` is a `&` reference, so the data it refers to cannot be written
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     let (ref _x0, _x1, ref mut _x2, ..) = tup;
+   |                        ~~~~~~~~~~~
 
 error[E0382]: use of moved value: `tup.1`
   --> $DIR/borrowck-move-ref-pattern.rs:28:10
index e4ec9f875765a35d3f1c88dddfacb4dcf35c02f8..20330c92325e4f15516311658ebf2cee121005d9 100644 (file)
@@ -9,10 +9,13 @@ LL |     let __isize = &mut x.y;
 error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
   --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:65:10
    |
-LL | fn deref_extend_mut_field1(x: &Own<Point>) -> &mut isize {
-   |                               ----------- help: consider changing this to be a mutable reference: `&mut Own<Point>`
 LL |     &mut x.y
    |          ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL | fn deref_extend_mut_field1(x: &mut Own<Point>) -> &mut isize {
+   |                               ~~~~~~~~~~~~~~~
 
 error[E0499]: cannot borrow `*x` as mutable more than once at a time
   --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:78:19
@@ -35,10 +38,13 @@ LL |     x.y = 3;
 error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
   --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:92:5
    |
-LL | fn assign_field2<'a>(x: &'a Own<Point>) {
-   |                         -------------- help: consider changing this to be a mutable reference: `&'a mut Own<Point>`
 LL |     x.y = 3;
    |     ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL | fn assign_field2<'a>(x: &'a mut Own<Point>) {
+   |                         ~~~~~~~~~~~~~~~~~~
 
 error[E0499]: cannot borrow `*x` as mutable more than once at a time
   --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:101:5
@@ -61,10 +67,13 @@ LL |     x.set(0, 0);
 error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
   --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:121:5
    |
-LL | fn deref_extend_mut_method1(x: &Own<Point>) -> &mut isize {
-   |                                ----------- help: consider changing this to be a mutable reference: `&mut Own<Point>`
 LL |     x.y_mut()
    |     ^^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+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
@@ -77,10 +86,13 @@ LL |     *x.y_mut() = 3;
 error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
   --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:133:6
    |
-LL | fn assign_method2<'a>(x: &'a Own<Point>) {
-   |                          -------------- help: consider changing this to be a mutable reference: `&'a mut Own<Point>`
 LL |     *x.y_mut() = 3;
    |      ^^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL | fn assign_method2<'a>(x: &'a mut Own<Point>) {
+   |                          ~~~~~~~~~~~~~~~~~~
 
 error: aborting due to 10 previous errors
 
index 3ebfba7e4debe7d0f299721f0902b9afd1383200..6d34909e43b965d84d37b7cb6c7aaedf1d63c548 100644 (file)
@@ -9,10 +9,13 @@ LL |     let __isize = &mut *x;
 error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
   --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:41:11
    |
-LL | fn deref_extend_mut1<'a>(x: &'a Own<isize>) -> &'a mut isize {
-   |                             -------------- help: consider changing this to be a mutable reference: `&'a mut Own<isize>`
 LL |     &mut **x
    |           ^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+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
@@ -25,10 +28,13 @@ LL |     *x = 3;
 error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
   --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:53:6
    |
-LL | fn assign2<'a>(x: &'a Own<isize>) {
-   |                   -------------- help: consider changing this to be a mutable reference: `&'a mut Own<isize>`
 LL |     **x = 3;
    |      ^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL | fn assign2<'a>(x: &'a mut Own<isize>) {
+   |                   ~~~~~~~~~~~~~~~~~~
 
 error: aborting due to 4 previous errors
 
index 6b43801b5e074fbdd4c1e3a80b57791b08e6eed2..48b42bc78253f59842a5fe00a4416b3bea2e24b4 100644 (file)
@@ -13,18 +13,24 @@ LL |         f((Box::new(|| {})))
 error[E0596]: cannot borrow `*f` as mutable, as it is behind a `&` reference
   --> $DIR/borrowck-call-is-borrow-issue-12224.rs:25:5
    |
-LL | fn test2<F>(f: &F) where F: FnMut() {
-   |                -- help: consider changing this to be a mutable reference: `&mut F`
 LL |     (*f)();
    |     ^^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL | fn test2<F>(f: &mut F) where F: FnMut() {
+   |                ~~~~~~
 
 error[E0596]: cannot borrow `f.f` as mutable, as it is behind a `&` reference
   --> $DIR/borrowck-call-is-borrow-issue-12224.rs:34:5
    |
-LL | fn test4(f: &Test) {
-   |             ----- help: consider changing this to be a mutable reference: `&mut Test<'_>`
 LL |     f.f.call_mut(())
    |     ^^^^^^^^^^^^^^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL | fn test4(f: &mut Test<'_>) {
+   |             ~~~~~~~~~~~~~
 
 error[E0507]: cannot move out of `f`, a captured variable in an `FnMut` closure
   --> $DIR/borrowck-call-is-borrow-issue-12224.rs:57:13
index 1864f5de108cd10911c221588cb43ea1ff85bf08..2a842f5a2a9f8f6ab6688a7572e38a4a791d6585 100644 (file)
@@ -1,11 +1,13 @@
 error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
   --> $DIR/borrowck-call-method-from-mut-aliasable.rs:17:5
    |
-LL | fn b(x: &Foo) {
-   |         ---- help: consider changing this to be a mutable reference: `&mut Foo`
-LL |     x.f();
 LL |     x.h();
    |     ^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL | fn b(x: &mut Foo) {
+   |         ~~~~~~~~
 
 error: aborting due to previous error
 
index 1f5d8bd32bb57faf27df0e2c8cdca481ca30d15a..1df19deb12f6b59955b0d862f5a258a3960b64c5 100644 (file)
@@ -1,10 +1,13 @@
 error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
   --> $DIR/borrowck-fn-in-const-b.rs:7:9
    |
-LL |     fn broken(x: &Vec<String>) {
-   |                  ------------ help: consider changing this to be a mutable reference: `&mut Vec<String>`
 LL |         x.push(format!("this is broken"));
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     fn broken(x: &mut Vec<String>) {
+   |                  ~~~~~~~~~~~~~~~~
 
 error: aborting due to previous error
 
index cc43f6d0928dadb51e94e829793f837680a01b82..e63ca95eff01d6160c78d12ee8cbdfd37ca270a6 100644 (file)
@@ -1,11 +1,13 @@
 error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
   --> $DIR/borrowck-object-mutability.rs:8:5
    |
-LL | fn borrowed_receiver(x: &dyn Foo) {
-   |                         -------- help: consider changing this to be a mutable reference: `&mut dyn Foo`
-LL |     x.borrowed();
 LL |     x.borrowed_mut();
    |     ^^^^^^^^^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+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
index 8a7c504f0053bdaa94a9ba5ebcc036166d87f189..96ce4d5bc6c338f83ee658b0f77f3c32279618c9 100644 (file)
@@ -1,26 +1,35 @@
 error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference
   --> $DIR/mut-arg-hint.rs:3:9
    |
-LL |     fn foo(mut a: &String) {
-   |                   ------- help: consider changing this to be a mutable reference: `&mut String`
 LL |         a.push_str("bar");
    |         ^^^^^^^^^^^^^^^^^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     fn foo(mut a: &mut String) {
+   |                   ~~~~~~~~~~~
 
 error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference
   --> $DIR/mut-arg-hint.rs:8:5
    |
-LL | pub fn foo<'a>(mut a: &'a String) {
-   |                       ---------- help: consider changing this to be a mutable reference: `&'a mut String`
 LL |     a.push_str("foo");
    |     ^^^^^^^^^^^^^^^^^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL | pub fn foo<'a>(mut a: &'a mut String) {
+   |                       ~~~~~~~~~~~~~~
 
 error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference
   --> $DIR/mut-arg-hint.rs:15:9
    |
-LL |     pub fn foo(mut a: &String) {
-   |                       ------- help: consider changing this to be a mutable reference: `&mut String`
 LL |         a.push_str("foo");
    |         ^^^^^^^^^^^^^^^^^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     pub fn foo(mut a: &mut String) {
+   |                       ~~~~~~~~~~~
 
 error: aborting due to 3 previous errors
 
index 2f31193e4a4a2b1717bf3d1bd5acd45e9e21a74b..de35aa5b186b5af82a94790bdb4f6876b814c367 100644 (file)
@@ -1,20 +1,24 @@
 error[E0594]: cannot assign to `*input`, which is behind a `&` reference
   --> $DIR/issue-68049-2.rs:9:7
    |
-LL |   fn example(&self, input: &i32); // should suggest here
-   |                            ---- help: consider changing that to be a mutable reference: `&mut i32`
-...
 LL |       *input = self.0;
    |       ^^^^^^^^^^^^^^^ `input` is a `&` reference, so the data it refers to cannot be written
+   |
+help: consider changing that to be a mutable reference
+   |
+LL |   fn example(&self, input: &mut i32); // should suggest here
+   |                            ~~~~~~~~
 
 error[E0594]: cannot assign to `self.0`, which is behind a `&` reference
   --> $DIR/issue-68049-2.rs:17:5
    |
-LL |   fn example(&self, input: &i32); // should suggest here
-   |              ----- help: consider changing that to be a mutable reference: `&mut self`
-...
 LL |     self.0 += *input;
    |     ^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written
+   |
+help: consider changing that to be a mutable reference
+   |
+LL |   fn example(&mut self, input: &i32); // should suggest here
+   |              ~~~~~~~~~
 
 error: aborting due to 2 previous errors
 
index 9fd2658ec702db71609de9cba8ea44458c58bc86..7973759bf5ec7f188259867284dd4c673cadef1a 100644 (file)
@@ -1,37 +1,46 @@
 error[E0594]: cannot assign to `self.0`, which is behind a `&` reference
   --> $DIR/suggest-ref-mut.rs:7:9
    |
-LL |     fn zap(&self) {
-   |            ----- help: consider changing this to be a mutable reference: `&mut self`
-...
 LL |         self.0 = 32;
    |         ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     fn zap(&mut self) {
+   |            ~~~~~~~~~
 
 error[E0594]: cannot assign to `*foo`, which is behind a `&` reference
   --> $DIR/suggest-ref-mut.rs:16:5
    |
-LL |     let ref foo = 16;
-   |         ------- help: consider changing this to be a mutable reference: `ref mut foo`
-...
 LL |     *foo = 32;
    |     ^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     let ref mut foo = 16;
+   |         ~~~~~~~~~~~
 
 error[E0594]: cannot assign to `*bar`, which is behind a `&` reference
   --> $DIR/suggest-ref-mut.rs:21:9
    |
-LL |     if let Some(ref bar) = Some(16) {
-   |                 ------- help: consider changing this to be a mutable reference: `ref mut bar`
-...
 LL |         *bar = 32;
    |         ^^^^^^^^^ `bar` is a `&` reference, so the data it refers to cannot be written
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     if let Some(ref mut bar) = Some(16) {
+   |                 ~~~~~~~~~~~
 
 error[E0594]: cannot assign to `*quo`, which is behind a `&` reference
   --> $DIR/suggest-ref-mut.rs:25:22
    |
 LL |         ref quo => { *quo = 32; },
-   |         -------      ^^^^^^^^^ `quo` is a `&` reference, so the data it refers to cannot be written
-   |         |
-   |         help: consider changing this to be a mutable reference: `ref mut quo`
+   |                      ^^^^^^^^^ `quo` is a `&` reference, so the data it refers to cannot be written
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |         ref mut quo => { *quo = 32; },
+   |         ~~~~~~~~~~~
 
 error: aborting due to 4 previous errors
 
index aac119afda544e3b7d7bccb7a57419b92292ee4f..39b60c3119727116463b0e356b6bc2f0b8e78414 100644 (file)
@@ -1,18 +1,24 @@
 error[E0596]: cannot borrow `**t` as mutable, as it is behind a `&` reference
   --> $DIR/trivial-bounds-inconsistent-copy-reborrow.rs:6:5
    |
-LL | fn reborrow_mut<'a>(t: &'a &'a mut i32) -> &'a mut i32 where &'a mut i32: Copy {
-   |                        --------------- help: consider changing this to be a mutable reference: `&'a mut &'a mut i32`
 LL |     *t
    |     ^^ `t` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL | fn reborrow_mut<'a>(t: &'a mut &'a mut i32) -> &'a mut i32 where &'a mut i32: Copy {
+   |                        ~~~~~~~~~~~~~~~~~~~
 
 error[E0596]: cannot borrow `**t` as mutable, as it is behind a `&` reference
   --> $DIR/trivial-bounds-inconsistent-copy-reborrow.rs:10:6
    |
-LL | fn copy_reborrow_mut<'a>(t: &'a &'a mut i32) -> &'a mut i32 where &'a mut i32: Copy {
-   |                             --------------- help: consider changing this to be a mutable reference: `&'a mut &'a mut i32`
 LL |     {*t}
    |      ^^ `t` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+   |
+help: consider changing this to be a mutable reference
+   |
+LL | fn copy_reborrow_mut<'a>(t: &'a mut &'a mut i32) -> &'a mut i32 where &'a mut i32: Copy {
+   |                             ~~~~~~~~~~~~~~~~~~~
 
 error: aborting due to 2 previous errors