From dc630aad2547a71f6a104861846d4dc18013d1e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 5 Nov 2025 00:11:35 +0000 Subject: [PATCH 1/2] Provide more context when mutably borrowing an imutable borrow Point at statics and consts being mutable borrowed or written to: ``` error[E0594]: cannot assign to immutable static item `NUM` --> $DIR/E0594.rs:4:5 | LL | static NUM: i32 = 18; | --------------- this `static` cannot be written to ... LL | NUM = 20; | ^^^^^^^^ cannot assign ``` Point at the expression that couldn't be mutably borrowed from a pattern: ``` error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/mut-pattern-of-immutable-borrow.rs:19:14 | LL | match &arg.field { | ---------- this cannot be borrowed as mutable LL | Some(ref mut s) => s.push('a'), | ^^^^^^^^^ cannot borrow as mutable ``` --- .../src/diagnostics/mutability_errors.rs | 33 +++++++++-- .../argument_number_mismatch_ice.stderr | 2 +- .../borrowck-access-permissions.stderr | 3 + ...k-assign-to-andmut-in-aliasable-loc.stderr | 4 +- .../borrowck-assign-to-constants.stderr | 3 + ...orrow-mut-base-ptr-in-aliasable-loc.stderr | 2 +- tests/ui/borrowck/borrowck-issue-14498.stderr | 2 +- tests/ui/borrowck/issue-42344.stderr | 3 + ...issue-69789-iterator-mut-suggestion.stderr | 2 +- .../issue-83309-ice-immut-in-for-loop.stderr | 2 +- tests/ui/borrowck/issue-85765-closure.stderr | 6 +- tests/ui/borrowck/issue-85765.stderr | 6 +- tests/ui/borrowck/issue-92015.stderr | 2 +- tests/ui/borrowck/issue-93093.stderr | 2 +- tests/ui/borrowck/mutability-errors.stderr | 20 +++++-- ...estion-for-raw-pointer-issue-127562.stderr | 2 +- .../miri_unleashed/mutable_references.stderr | 3 + .../consts/write_to_static_via_mut_ref.stderr | 3 + tests/ui/error-codes/E0017.stderr | 3 + tests/ui/error-codes/E0389.stderr | 2 +- tests/ui/error-codes/E0594.stderr | 3 + tests/ui/issues/issue-46604.stderr | 3 + tests/ui/issues/issue-51515.stderr | 4 +- .../let-else-binding-explicit-mut.stderr | 6 +- .../let-else-binding-immutable.stderr | 2 +- tests/ui/mut/mutable-class-fields-2.stderr | 2 +- .../constant-thread-locals-issue-47053.stderr | 3 + tests/ui/nll/dont-print-desugared.stderr | 4 +- tests/ui/nll/issue-47388.stderr | 2 +- tests/ui/nll/issue-51191.stderr | 2 + tests/ui/nll/issue-51244.stderr | 2 +- tests/ui/nll/issue-57989.stderr | 2 +- tests/ui/pattern/issue-52240.stderr | 4 +- .../borrowck-move-ref-pattern.stderr | 4 +- .../mut-pattern-of-immutable-borrow.rs | 31 +++++++++++ .../mut-pattern-of-immutable-borrow.stderr | 55 +++++++++++++++++++ .../borrowck-errors.classic2021.stderr | 12 +++- .../borrowck-errors.classic2024.stderr | 8 ++- .../borrowck-errors.stable2021.stderr | 12 +++- .../borrowck-errors.structural2021.stderr | 4 +- .../borrowck-errors.structural2024.stderr | 4 +- .../mixed-editions.classic2021.stderr | 12 +++- .../mixed-editions.classic2024.stderr | 12 +++- ...nding-on-inh-ref-errors.classic2021.stderr | 4 +- ...nding-on-inh-ref-errors.classic2024.stderr | 4 +- ...inding-on-inh-ref-errors.stable2021.stderr | 4 +- ...ng-on-inh-ref-errors.structural2021.stderr | 4 +- ...ng-on-inh-ref-errors.structural2024.stderr | 4 +- ...well-typed-edition-2024.classic2021.stderr | 4 +- ...l-typed-edition-2024.structural2021.stderr | 4 +- .../rfc-2005-default-binding-mode/enum.stderr | 6 +- .../explicit-mut.stderr | 6 +- ...est_raw_pointer_syntax-issue-127562.stderr | 2 +- tests/ui/suggestions/issue-68049-1.stderr | 2 +- tests/ui/suggestions/issue-68049-2.stderr | 4 +- ...suggest-mut-method-for-loop-closure.stderr | 2 +- ...suggest-mut-method-for-loop-hashmap.stderr | 2 +- .../suggest-mut-method-for-loop.stderr | 2 +- tests/ui/suggestions/suggest-ref-mut.stderr | 8 +-- .../thread-local/thread-local-mutation.stderr | 3 + 60 files changed, 284 insertions(+), 79 deletions(-) create mode 100644 tests/ui/pattern/mut-pattern-of-immutable-borrow.rs create mode 100644 tests/ui/pattern/mut-pattern-of-immutable-borrow.stderr diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index 2f011dba60b16..621af32cf5984 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -213,7 +213,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { AccessKind::Mutate => { err = self.cannot_assign(span, &(item_msg + &reason)); act = "assign"; - acted_on = "written"; + acted_on = "written to"; span } AccessKind::MutableBorrow => { @@ -542,7 +542,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { self.expected_fn_found_fn_mut_call(&mut err, span, act); } - PlaceRef { local: _, projection: [.., ProjectionElem::Deref] } => { + PlaceRef { local, projection: [.., ProjectionElem::Deref] } => { err.span_label(span, format!("cannot {act}")); match opt_source { @@ -559,11 +559,36 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { )); self.suggest_map_index_mut_alternatives(ty, &mut err, span); } - _ => (), + _ => { + let local = &self.body.local_decls[local]; + match local.local_info() { + LocalInfo::StaticRef { def_id, .. } => { + let span = self.infcx.tcx.def_span(def_id); + err.span_label(span, format!("this `static` cannot be {acted_on}")); + } + LocalInfo::ConstRef { def_id } => { + let span = self.infcx.tcx.def_span(def_id); + err.span_label(span, format!("this `const` cannot be {acted_on}")); + } + LocalInfo::BlockTailTemp(_) | LocalInfo::Boring + if !local.source_info.span.overlaps(span) => + { + err.span_label( + local.source_info.span, + format!("this cannot be {acted_on}"), + ); + } + _ => {} + } + } } } - _ => { + PlaceRef { local, .. } => { + let local = &self.body.local_decls[local]; + if !local.source_info.span.overlaps(span) { + err.span_label(local.source_info.span, format!("this cannot be {acted_on}")); + } err.span_label(span, format!("cannot {act}")); } } diff --git a/tests/ui/borrowck/argument_number_mismatch_ice.stderr b/tests/ui/borrowck/argument_number_mismatch_ice.stderr index 702cebb86bae2..6a0c49c3db8d3 100644 --- a/tests/ui/borrowck/argument_number_mismatch_ice.stderr +++ b/tests/ui/borrowck/argument_number_mismatch_ice.stderr @@ -11,7 +11,7 @@ error[E0594]: cannot assign to `*input`, which is behind a `&` reference --> $DIR/argument_number_mismatch_ice.rs:10:9 | LL | *input = self.0; - | ^^^^^^^^^^^^^^^ `input` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^^^^^^^^^ `input` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this to be a mutable reference in the `impl` method and the `trait` definition | diff --git a/tests/ui/borrowck/borrowck-access-permissions.stderr b/tests/ui/borrowck/borrowck-access-permissions.stderr index 87717a5329052..e3a87e6961466 100644 --- a/tests/ui/borrowck/borrowck-access-permissions.stderr +++ b/tests/ui/borrowck/borrowck-access-permissions.stderr @@ -12,6 +12,9 @@ LL | let mut x = 1; error[E0596]: cannot borrow immutable static item `static_x` as mutable --> $DIR/borrowck-access-permissions.rs:16:19 | +LL | static static_x: i32 = 1; + | -------------------- this `static` cannot be borrowed as mutable +... LL | let _y1 = &mut static_x; | ^^^^^^^^^^^^^ cannot borrow as mutable diff --git a/tests/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr b/tests/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr index cf0c4127d82f4..343824df6c0ed 100644 --- a/tests/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr +++ b/tests/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `*s.pointer`, which is behind a `&` reference --> $DIR/borrowck-assign-to-andmut-in-aliasable-loc.rs:9:5 | LL | *s.pointer += 1; - | ^^^^^^^^^^^^^^^ `s` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^^^^^^^^^ `s` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this to be a mutable reference | @@ -13,7 +13,7 @@ error[E0594]: cannot assign to `*s.pointer`, which is behind a `&` reference --> $DIR/borrowck-assign-to-andmut-in-aliasable-loc.rs:17:5 | LL | *s.pointer += 1; - | ^^^^^^^^^^^^^^^ `s` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^^^^^^^^^ `s` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this to be a mutable reference | diff --git a/tests/ui/borrowck/borrowck-assign-to-constants.stderr b/tests/ui/borrowck/borrowck-assign-to-constants.stderr index 82972b573c6f7..6bfed855f95a3 100644 --- a/tests/ui/borrowck/borrowck-assign-to-constants.stderr +++ b/tests/ui/borrowck/borrowck-assign-to-constants.stderr @@ -1,6 +1,9 @@ error[E0594]: cannot assign to immutable static item `foo` --> $DIR/borrowck-assign-to-constants.rs:5:5 | +LL | static foo: isize = 5; + | ----------------- this `static` cannot be written to +... LL | foo = 6; | ^^^^^^^ cannot assign diff --git a/tests/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr b/tests/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr index 59ef61b19d501..cc2bc7036d91a 100644 --- a/tests/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr +++ b/tests/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `**t1`, which is behind a `&` reference --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:9:5 | LL | **t1 = 22; - | ^^^^^^^^^ `t1` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^^^ `t1` is a `&` reference, so the data it refers to cannot be written to | help: consider specifying this binding's type | diff --git a/tests/ui/borrowck/borrowck-issue-14498.stderr b/tests/ui/borrowck/borrowck-issue-14498.stderr index 12d67d536d951..7348bba704930 100644 --- a/tests/ui/borrowck/borrowck-issue-14498.stderr +++ b/tests/ui/borrowck/borrowck-issue-14498.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `***p`, which is behind a `&` reference --> $DIR/borrowck-issue-14498.rs:16:5 | LL | ***p = 2; - | ^^^^^^^^ `p` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^^ `p` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this to be a mutable reference | diff --git a/tests/ui/borrowck/issue-42344.stderr b/tests/ui/borrowck/issue-42344.stderr index bf82d462b51bc..e7e98d281302b 100644 --- a/tests/ui/borrowck/issue-42344.stderr +++ b/tests/ui/borrowck/issue-42344.stderr @@ -1,6 +1,9 @@ error[E0596]: cannot borrow `*TAB[_]` as mutable, as `TAB` is an immutable static item --> $DIR/issue-42344.rs:4:5 | +LL | static TAB: [&mut [u8]; 0] = []; + | -------------------------- this `static` cannot be borrowed as mutable +... LL | TAB[0].iter_mut(); | ^^^^^^ cannot borrow as mutable diff --git a/tests/ui/borrowck/issue-69789-iterator-mut-suggestion.stderr b/tests/ui/borrowck/issue-69789-iterator-mut-suggestion.stderr index 87b8e05913528..824a02c28f28e 100644 --- a/tests/ui/borrowck/issue-69789-iterator-mut-suggestion.stderr +++ b/tests/ui/borrowck/issue-69789-iterator-mut-suggestion.stderr @@ -5,7 +5,7 @@ LL | for item in &mut std::iter::empty::<&'static ()>() { | -------------------------------------- this iterator yields `&` references LL | LL | *item = (); - | ^^^^^^^^^^ `item` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^^^^ `item` is a `&` reference, so the data it refers to cannot be written to error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/issue-83309-ice-immut-in-for-loop.stderr b/tests/ui/borrowck/issue-83309-ice-immut-in-for-loop.stderr index 4e7a9b695e179..9bd4d9c65ff71 100644 --- a/tests/ui/borrowck/issue-83309-ice-immut-in-for-loop.stderr +++ b/tests/ui/borrowck/issue-83309-ice-immut-in-for-loop.stderr @@ -5,7 +5,7 @@ LL | for v in Query.iter_mut() { | ---------------- this iterator yields `&` references LL | LL | *v -= 1; - | ^^^^^^^ `v` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^ `v` is a `&` reference, so the data it refers to cannot be written to error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/issue-85765-closure.stderr b/tests/ui/borrowck/issue-85765-closure.stderr index cd2544ec5c952..0d1ef501a7446 100644 --- a/tests/ui/borrowck/issue-85765-closure.stderr +++ b/tests/ui/borrowck/issue-85765-closure.stderr @@ -13,7 +13,7 @@ error[E0594]: cannot assign to `*r`, which is behind a `&` reference --> $DIR/issue-85765-closure.rs:13:9 | LL | *r = 0; - | ^^^^^^ `r` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^ `r` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this to be a mutable reference | @@ -24,7 +24,7 @@ error[E0594]: cannot assign to `*x`, which is behind a `&` reference --> $DIR/issue-85765-closure.rs:20:9 | LL | *x = 1; - | ^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this binding's type | @@ -35,7 +35,7 @@ error[E0594]: cannot assign to `*y`, which is behind a `&` reference --> $DIR/issue-85765-closure.rs:27:9 | LL | *y = 1; - | ^^^^^^ `y` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^ `y` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this binding's type | diff --git a/tests/ui/borrowck/issue-85765.stderr b/tests/ui/borrowck/issue-85765.stderr index e252f3d44d976..862e175350918 100644 --- a/tests/ui/borrowck/issue-85765.stderr +++ b/tests/ui/borrowck/issue-85765.stderr @@ -13,7 +13,7 @@ error[E0594]: cannot assign to `*r`, which is behind a `&` reference --> $DIR/issue-85765.rs:12:5 | LL | *r = 0; - | ^^^^^^ `r` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^ `r` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this to be a mutable reference | @@ -24,7 +24,7 @@ error[E0594]: cannot assign to `*x`, which is behind a `&` reference --> $DIR/issue-85765.rs:19:5 | LL | *x = 1; - | ^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this binding's type | @@ -35,7 +35,7 @@ error[E0594]: cannot assign to `*y`, which is behind a `&` reference --> $DIR/issue-85765.rs:26:5 | LL | *y = 1; - | ^^^^^^ `y` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^ `y` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this binding's type | diff --git a/tests/ui/borrowck/issue-92015.stderr b/tests/ui/borrowck/issue-92015.stderr index 167a5cf5863c6..62b4ae3217460 100644 --- a/tests/ui/borrowck/issue-92015.stderr +++ b/tests/ui/borrowck/issue-92015.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `*foo`, which is behind a `&` reference --> $DIR/issue-92015.rs:6:5 | LL | *foo = 1; - | ^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written to | help: consider specifying this binding's type | diff --git a/tests/ui/borrowck/issue-93093.stderr b/tests/ui/borrowck/issue-93093.stderr index d788ce331973c..58aa6bc655cbd 100644 --- a/tests/ui/borrowck/issue-93093.stderr +++ b/tests/ui/borrowck/issue-93093.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `self.foo`, which is behind a `&` reference --> $DIR/issue-93093.rs:8:9 | LL | self.foo += 1; - | ^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this to be a mutable reference | diff --git a/tests/ui/borrowck/mutability-errors.stderr b/tests/ui/borrowck/mutability-errors.stderr index 7307e1f2a86b2..f5c61457f8235 100644 --- a/tests/ui/borrowck/mutability-errors.stderr +++ b/tests/ui/borrowck/mutability-errors.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `*x`, which is behind a `&` reference --> $DIR/mutability-errors.rs:9:5 | LL | *x = (1,); - | ^^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this to be a mutable reference | @@ -13,7 +13,7 @@ error[E0594]: cannot assign to `x.0`, which is behind a `&` reference --> $DIR/mutability-errors.rs:10:5 | LL | x.0 = 1; - | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this to be a mutable reference | @@ -70,7 +70,7 @@ error[E0594]: cannot assign to `*x`, which is behind a `*const` pointer --> $DIR/mutability-errors.rs:23:5 | LL | *x = (1,); - | ^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be written + | ^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be written to | help: consider changing this to be a mutable pointer | @@ -81,7 +81,7 @@ error[E0594]: cannot assign to `x.0`, which is behind a `*const` pointer --> $DIR/mutability-errors.rs:24:5 | LL | (*x).0 = 1; - | ^^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be written + | ^^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be written to | help: consider changing this to be a mutable pointer | @@ -358,24 +358,36 @@ LL | fn imm_capture(mut x: (i32,)) { error[E0594]: cannot assign to immutable static item `X` --> $DIR/mutability-errors.rs:76:5 | +LL | static X: (i32,) = (0,); + | ---------------- this `static` cannot be written to +... LL | X = (1,); | ^^^^^^^^ cannot assign error[E0594]: cannot assign to `X.0`, as `X` is an immutable static item --> $DIR/mutability-errors.rs:77:5 | +LL | static X: (i32,) = (0,); + | ---------------- this `static` cannot be written to +... LL | X.0 = 1; | ^^^^^^^ cannot assign error[E0596]: cannot borrow immutable static item `X` as mutable --> $DIR/mutability-errors.rs:78:5 | +LL | static X: (i32,) = (0,); + | ---------------- this `static` cannot be borrowed as mutable +... LL | &mut X; | ^^^^^^ cannot borrow as mutable error[E0596]: cannot borrow `X.0` as mutable, as `X` is an immutable static item --> $DIR/mutability-errors.rs:79:5 | +LL | static X: (i32,) = (0,); + | ---------------- this `static` cannot be borrowed as mutable +... LL | &mut X.0; | ^^^^^^^^ cannot borrow as mutable diff --git a/tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.stderr b/tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.stderr index 9bcfbd3379559..47cd6f029b57d 100644 --- a/tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.stderr +++ b/tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `*ptr`, which is behind a `*const` pointer --> $DIR/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.rs:7:14 | LL | unsafe { *ptr = 3; } - | ^^^^^^^^ `ptr` is a `*const` pointer, so the data it refers to cannot be written + | ^^^^^^^^ `ptr` is a `*const` pointer, so the data it refers to cannot be written to | help: consider changing this to be a mutable pointer | diff --git a/tests/ui/consts/miri_unleashed/mutable_references.stderr b/tests/ui/consts/miri_unleashed/mutable_references.stderr index b35076b669e29..9bff2711e5f1f 100644 --- a/tests/ui/consts/miri_unleashed/mutable_references.stderr +++ b/tests/ui/consts/miri_unleashed/mutable_references.stderr @@ -131,6 +131,9 @@ LL | const RAW_MUT_COERCE: SyncPtr = SyncPtr { x: &mut 0 }; error[E0594]: cannot assign to `*OH_YES`, as `OH_YES` is an immutable static item --> $DIR/mutable_references.rs:109:5 | +LL | static OH_YES: &mut i32 = &mut 42; + | ----------------------- this `static` cannot be written to +... LL | *OH_YES = 99; | ^^^^^^^^^^^^ cannot assign diff --git a/tests/ui/consts/write_to_static_via_mut_ref.stderr b/tests/ui/consts/write_to_static_via_mut_ref.stderr index 1bcd7b81fe059..ce44047f15506 100644 --- a/tests/ui/consts/write_to_static_via_mut_ref.stderr +++ b/tests/ui/consts/write_to_static_via_mut_ref.stderr @@ -11,6 +11,9 @@ LL | static OH_NO: &mut i32 = &mut 42; error[E0594]: cannot assign to `*OH_NO`, as `OH_NO` is an immutable static item --> $DIR/write_to_static_via_mut_ref.rs:4:5 | +LL | static OH_NO: &mut i32 = &mut 42; + | ---------------------- this `static` cannot be written to +... LL | *OH_NO = 43; | ^^^^^^^^^^^ cannot assign diff --git a/tests/ui/error-codes/E0017.stderr b/tests/ui/error-codes/E0017.stderr index 2039e5564701a..fcc57b9e5c3c6 100644 --- a/tests/ui/error-codes/E0017.stderr +++ b/tests/ui/error-codes/E0017.stderr @@ -26,6 +26,9 @@ LL | const CR: &'static mut i32 = &mut C; error[E0596]: cannot borrow immutable static item `X` as mutable --> $DIR/E0017.rs:11:39 | +LL | static X: i32 = 1; + | ------------- this `static` cannot be borrowed as mutable +... LL | static STATIC_REF: &'static mut i32 = &mut X; | ^^^^^^ cannot borrow as mutable diff --git a/tests/ui/error-codes/E0389.stderr b/tests/ui/error-codes/E0389.stderr index 156bff7f0223f..5fc270b34484d 100644 --- a/tests/ui/error-codes/E0389.stderr +++ b/tests/ui/error-codes/E0389.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `fancy_ref.num`, which is behind a `&` reference --> $DIR/E0389.rs:8:5 | LL | fancy_ref.num = 6; - | ^^^^^^^^^^^^^^^^^ `fancy_ref` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^^^^^^^^^^^ `fancy_ref` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this to be a mutable reference | diff --git a/tests/ui/error-codes/E0594.stderr b/tests/ui/error-codes/E0594.stderr index e010cda83ff90..3519d0881fad6 100644 --- a/tests/ui/error-codes/E0594.stderr +++ b/tests/ui/error-codes/E0594.stderr @@ -1,6 +1,9 @@ error[E0594]: cannot assign to immutable static item `NUM` --> $DIR/E0594.rs:4:5 | +LL | static NUM: i32 = 18; + | --------------- this `static` cannot be written to +... LL | NUM = 20; | ^^^^^^^^ cannot assign diff --git a/tests/ui/issues/issue-46604.stderr b/tests/ui/issues/issue-46604.stderr index d983674995ed2..abe3ad476c60d 100644 --- a/tests/ui/issues/issue-46604.stderr +++ b/tests/ui/issues/issue-46604.stderr @@ -11,6 +11,9 @@ LL | static buf: &mut [u8] = &mut [1u8,2,3,4,5,7]; error[E0594]: cannot assign to `buf[_]`, as `buf` is an immutable static item --> $DIR/issue-46604.rs:6:5 | +LL | static buf: &mut [u8] = &mut [1u8,2,3,4,5,7]; + | --------------------- this `static` cannot be written to +... LL | buf[0]=2; | ^^^^^^^^ cannot assign diff --git a/tests/ui/issues/issue-51515.stderr b/tests/ui/issues/issue-51515.stderr index 88b8d21090886..4c3a1919fbe26 100644 --- a/tests/ui/issues/issue-51515.stderr +++ b/tests/ui/issues/issue-51515.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `*foo`, which is behind a `&` reference --> $DIR/issue-51515.rs:4:5 | LL | *foo = 32; - | ^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this to be a mutable reference | @@ -13,7 +13,7 @@ error[E0594]: cannot assign to `*bar`, which is behind a `&` reference --> $DIR/issue-51515.rs:8:5 | LL | *bar = 64; - | ^^^^^^^^^ `bar` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^^^ `bar` is a `&` reference, so the data it refers to cannot be written to | help: consider specifying this binding's type | diff --git a/tests/ui/let-else/let-else-binding-explicit-mut.stderr b/tests/ui/let-else/let-else-binding-explicit-mut.stderr index 45f2b6b3bcee8..b93a5ae698a42 100644 --- a/tests/ui/let-else/let-else-binding-explicit-mut.stderr +++ b/tests/ui/let-else/let-else-binding-explicit-mut.stderr @@ -2,19 +2,19 @@ error[E0594]: cannot assign to `*n`, which is behind a `&` reference --> $DIR/let-else-binding-explicit-mut.rs:10:5 | LL | *n += 1; - | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written to error[E0594]: cannot assign to `*n`, which is behind a `&` reference --> $DIR/let-else-binding-explicit-mut.rs:14:5 | LL | *n += 1; - | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written to error[E0594]: cannot assign to `*n`, which is behind a `&` reference --> $DIR/let-else-binding-explicit-mut.rs:18:5 | LL | *n += 1; - | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written to error: aborting due to 3 previous errors diff --git a/tests/ui/let-else/let-else-binding-immutable.stderr b/tests/ui/let-else/let-else-binding-immutable.stderr index 0f854493b7e47..2d8f9197fc879 100644 --- a/tests/ui/let-else/let-else-binding-immutable.stderr +++ b/tests/ui/let-else/let-else-binding-immutable.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `*x`, which is behind a `&` reference --> $DIR/let-else-binding-immutable.rs:9:5 | LL | *x += 1; - | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written to error: aborting due to 1 previous error diff --git a/tests/ui/mut/mutable-class-fields-2.stderr b/tests/ui/mut/mutable-class-fields-2.stderr index 7a6ff4da2bf52..c133e883d3283 100644 --- a/tests/ui/mut/mutable-class-fields-2.stderr +++ b/tests/ui/mut/mutable-class-fields-2.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `self.how_hungry`, which is behind a `&` referenc --> $DIR/mutable-class-fields-2.rs:9:5 | LL | self.how_hungry -= 5; - | ^^^^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this to be a mutable reference | diff --git a/tests/ui/nll/constant-thread-locals-issue-47053.stderr b/tests/ui/nll/constant-thread-locals-issue-47053.stderr index 1c6844d6e332a..64cb866e758f7 100644 --- a/tests/ui/nll/constant-thread-locals-issue-47053.stderr +++ b/tests/ui/nll/constant-thread-locals-issue-47053.stderr @@ -1,6 +1,9 @@ error[E0594]: cannot assign to immutable static item `FOO` --> $DIR/constant-thread-locals-issue-47053.rs:9:5 | +LL | static FOO: isize = 5; + | ----------------- this `static` cannot be written to +... LL | FOO = 6; | ^^^^^^^ cannot assign diff --git a/tests/ui/nll/dont-print-desugared.stderr b/tests/ui/nll/dont-print-desugared.stderr index 289b246e663e1..9386e1f060591 100644 --- a/tests/ui/nll/dont-print-desugared.stderr +++ b/tests/ui/nll/dont-print-desugared.stderr @@ -2,7 +2,9 @@ error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/dont-print-desugared.rs:4:10 | LL | for &ref mut x in s {} - | ^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^ - this cannot be borrowed as mutable + | | + | cannot borrow as mutable error[E0597]: `y` does not live long enough --> $DIR/dont-print-desugared.rs:17:16 diff --git a/tests/ui/nll/issue-47388.stderr b/tests/ui/nll/issue-47388.stderr index bd8b4c1eea00f..ee4950c8e134c 100644 --- a/tests/ui/nll/issue-47388.stderr +++ b/tests/ui/nll/issue-47388.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `fancy_ref.num`, which is behind a `&` reference --> $DIR/issue-47388.rs:8:5 | LL | fancy_ref.num = 6; - | ^^^^^^^^^^^^^^^^^ `fancy_ref` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^^^^^^^^^^^ `fancy_ref` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this to be a mutable reference | diff --git a/tests/ui/nll/issue-51191.stderr b/tests/ui/nll/issue-51191.stderr index 73f8aab9d1417..a7f7603d27804 100644 --- a/tests/ui/nll/issue-51191.stderr +++ b/tests/ui/nll/issue-51191.stderr @@ -45,6 +45,8 @@ LL | fn imm(mut self) { error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable --> $DIR/issue-51191.rs:23:9 | +LL | fn immref(&self) { + | ----- this cannot be borrowed as mutable LL | (&mut self).bar(); | ^^^^^^^^^^^ cannot borrow as mutable diff --git a/tests/ui/nll/issue-51244.stderr b/tests/ui/nll/issue-51244.stderr index 610482f8b1a99..e994fb453f6cf 100644 --- a/tests/ui/nll/issue-51244.stderr +++ b/tests/ui/nll/issue-51244.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `*my_ref`, which is behind a `&` reference --> $DIR/issue-51244.rs:3:5 | LL | *my_ref = 0; - | ^^^^^^^^^^^ `my_ref` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^^^^^ `my_ref` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this to be a mutable reference | diff --git a/tests/ui/nll/issue-57989.stderr b/tests/ui/nll/issue-57989.stderr index 6062b31d6883c..d96974f93c76d 100644 --- a/tests/ui/nll/issue-57989.stderr +++ b/tests/ui/nll/issue-57989.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `*x`, which is behind a `&` reference --> $DIR/issue-57989.rs:5:5 | LL | *x = 0; - | ^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this to be a mutable reference | diff --git a/tests/ui/pattern/issue-52240.stderr b/tests/ui/pattern/issue-52240.stderr index dcf3da45e5358..7d419dd1b9b24 100644 --- a/tests/ui/pattern/issue-52240.stderr +++ b/tests/ui/pattern/issue-52240.stderr @@ -2,7 +2,9 @@ error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/issue-52240.rs:9:27 | LL | if let (Some(Foo::Bar(ref mut val)), _) = (&arr.get(0), 0) { - | ^^^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^^^ ---------------- this cannot be borrowed as mutable + | | + | cannot borrow as mutable error: aborting due to 1 previous error diff --git a/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr b/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr index a1049701dc3b8..dd3b507a51c4e 100644 --- a/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr +++ b/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr @@ -119,7 +119,7 @@ error[E0594]: cannot assign to `*_x0`, which is behind a `&` reference --> $DIR/borrowck-move-ref-pattern.rs:26:5 | LL | *_x0 = U; - | ^^^^^^^^ `_x0` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^^ `_x0` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this to be a mutable reference | @@ -130,7 +130,7 @@ error[E0594]: cannot assign to `*_x2`, which is behind a `&` reference --> $DIR/borrowck-move-ref-pattern.rs:27:5 | LL | *_x2 = U; - | ^^^^^^^^ `_x2` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^^ `_x2` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this to be a mutable reference | diff --git a/tests/ui/pattern/mut-pattern-of-immutable-borrow.rs b/tests/ui/pattern/mut-pattern-of-immutable-borrow.rs new file mode 100644 index 0000000000000..52852414da459 --- /dev/null +++ b/tests/ui/pattern/mut-pattern-of-immutable-borrow.rs @@ -0,0 +1,31 @@ +struct S { + field: Option, +} + +fn a(arg: &mut S) { + match arg.field { //~ ERROR cannot move out of `arg.field` + Some(s) => s.push('a'), //~ ERROR cannot borrow `s` as mutable + None => {} + } +} +fn b(arg: &mut S) { + match &arg.field { //~ ERROR cannot move out of a shared reference + Some(mut s) => s.push('a'), + None => {} + } +} +fn c(arg: &mut S) { + match &arg.field { + Some(ref mut s) => s.push('a'), //~ ERROR cannot borrow data in a `&` reference as mutable + None => {} + } +} + +fn main() { + let mut s = S { + field: Some("a".to_owned()), + }; + a(&mut s); + b(&mut s); + c(&mut s); +} diff --git a/tests/ui/pattern/mut-pattern-of-immutable-borrow.stderr b/tests/ui/pattern/mut-pattern-of-immutable-borrow.stderr new file mode 100644 index 0000000000000..be1b5fadb0dd0 --- /dev/null +++ b/tests/ui/pattern/mut-pattern-of-immutable-borrow.stderr @@ -0,0 +1,55 @@ +error[E0507]: cannot move out of `arg.field` as enum variant `Some` which is behind a mutable reference + --> $DIR/mut-pattern-of-immutable-borrow.rs:6:11 + | +LL | match arg.field { + | ^^^^^^^^^ +LL | Some(s) => s.push('a'), + | - + | | + | data moved here + | move occurs because `s` has type `String`, which does not implement the `Copy` trait + | +help: consider borrowing here + | +LL | match &arg.field { + | + + +error[E0596]: cannot borrow `s` as mutable, as it is not declared as mutable + --> $DIR/mut-pattern-of-immutable-borrow.rs:7:20 + | +LL | Some(s) => s.push('a'), + | ^ cannot borrow as mutable + | +help: consider changing this to be mutable + | +LL | Some(mut s) => s.push('a'), + | +++ + +error[E0507]: cannot move out of a shared reference + --> $DIR/mut-pattern-of-immutable-borrow.rs:12:11 + | +LL | match &arg.field { + | ^^^^^^^^^^ +LL | Some(mut s) => s.push('a'), + | ----- + | | + | data moved here + | move occurs because `s` has type `String`, which does not implement the `Copy` trait + | +help: consider borrowing the pattern binding + | +LL | Some(ref mut s) => s.push('a'), + | +++ + +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/mut-pattern-of-immutable-borrow.rs:19:14 + | +LL | match &arg.field { + | ---------- this cannot be borrowed as mutable +LL | Some(ref mut s) => s.push('a'), + | ^^^^^^^^^ cannot borrow as mutable + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0507, E0596. +For more information about an error, try `rustc --explain E0507`. diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.classic2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.classic2021.stderr index 4d795d5c38518..6391619fddf0e 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.classic2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.classic2021.stderr @@ -17,19 +17,25 @@ error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/borrowck-errors.rs:38:10 | LL | let &ref mut x = &0; - | ^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^ -- this cannot be borrowed as mutable + | | + | cannot borrow as mutable error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/borrowck-errors.rs:43:23 | LL | if let &Some(Some(x)) = &Some(&mut Some(0)) { - | ^ cannot borrow as mutable + | ^ ------------------- this cannot be borrowed as mutable + | | + | cannot borrow as mutable error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/borrowck-errors.rs:48:11 | LL | let &[x] = &&mut [0]; - | ^ cannot borrow as mutable + | ^ --------- this cannot be borrowed as mutable + | | + | cannot borrow as mutable error: aborting due to 4 previous errors diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.classic2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.classic2024.stderr index 6cc6c58bf7af5..1106342e62e49 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.classic2024.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.classic2024.stderr @@ -45,7 +45,9 @@ error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/borrowck-errors.rs:38:10 | LL | let &ref mut x = &0; - | ^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^ -- this cannot be borrowed as mutable + | | + | cannot borrow as mutable error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/borrowck-errors.rs:43:23 @@ -57,7 +59,9 @@ error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/borrowck-errors.rs:48:11 | LL | let &[x] = &&mut [0]; - | ^ cannot borrow as mutable + | ^ --------- this cannot be borrowed as mutable + | | + | cannot borrow as mutable error[E0508]: cannot move out of type `[&mut i32; 1]`, a non-copy array --> $DIR/borrowck-errors.rs:52:20 diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.stable2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.stable2021.stderr index 036b3dbeae39d..ac84fdf7f95ff 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.stable2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.stable2021.stderr @@ -49,19 +49,25 @@ error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/borrowck-errors.rs:38:10 | LL | let &ref mut x = &0; - | ^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^ -- this cannot be borrowed as mutable + | | + | cannot borrow as mutable error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/borrowck-errors.rs:43:23 | LL | if let &Some(Some(x)) = &Some(&mut Some(0)) { - | ^ cannot borrow as mutable + | ^ ------------------- this cannot be borrowed as mutable + | | + | cannot borrow as mutable error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/borrowck-errors.rs:48:11 | LL | let &[x] = &&mut [0]; - | ^ cannot borrow as mutable + | ^ --------- this cannot be borrowed as mutable + | | + | cannot borrow as mutable error: aborting due to 6 previous errors diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.structural2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.structural2021.stderr index e1764fa1d55da..0e431326cb915 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.structural2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.structural2021.stderr @@ -17,7 +17,9 @@ error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/borrowck-errors.rs:38:10 | LL | let &ref mut x = &0; - | ^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^ -- this cannot be borrowed as mutable + | | + | cannot borrow as mutable error: aborting due to 2 previous errors diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.structural2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.structural2024.stderr index e1764fa1d55da..0e431326cb915 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.structural2024.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.structural2024.stderr @@ -17,7 +17,9 @@ error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/borrowck-errors.rs:38:10 | LL | let &ref mut x = &0; - | ^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^ -- this cannot be borrowed as mutable + | | + | cannot borrow as mutable error: aborting due to 2 previous errors diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.classic2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.classic2021.stderr index fc1ca18c12026..4fa82a603a8e4 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.classic2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.classic2021.stderr @@ -81,19 +81,25 @@ error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/mixed-editions.rs:61:21 | LL | let match_ref!([x]) = &&mut [0]; - | ^ cannot borrow as mutable + | ^ --------- this cannot be borrowed as mutable + | | + | cannot borrow as mutable error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/mixed-editions.rs:65:22 | LL | let &match_ctor!(y) = &&mut [0]; - | ^ cannot borrow as mutable + | ^ --------- this cannot be borrowed as mutable + | | + | cannot borrow as mutable error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/mixed-editions.rs:69:11 | LL | let &[bind!(z)] = &&mut [0]; - | ^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^ --------- this cannot be borrowed as mutable + | | + | cannot borrow as mutable | = note: this error originates in the macro `bind` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.classic2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.classic2024.stderr index 9377d535f1874..ee152c2871f4e 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.classic2024.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.classic2024.stderr @@ -75,19 +75,25 @@ error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/mixed-editions.rs:61:21 | LL | let match_ref!([x]) = &&mut [0]; - | ^ cannot borrow as mutable + | ^ --------- this cannot be borrowed as mutable + | | + | cannot borrow as mutable error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/mixed-editions.rs:65:22 | LL | let &match_ctor!(y) = &&mut [0]; - | ^ cannot borrow as mutable + | ^ --------- this cannot be borrowed as mutable + | | + | cannot borrow as mutable error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/mixed-editions.rs:69:11 | LL | let &[bind!(z)] = &&mut [0]; - | ^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^ --------- this cannot be borrowed as mutable + | | + | cannot borrow as mutable | = note: this error originates in the macro `bind` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2021.stderr index dbb8ae87b661c..30c0814e19380 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2021.stderr @@ -2,7 +2,9 @@ error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/ref-binding-on-inh-ref-errors.rs:73:10 | LL | let [ref mut x] = &[0]; - | ^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^ ---- this cannot be borrowed as mutable + | | + | cannot borrow as mutable error: aborting due to 1 previous error diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2024.stderr index 956cd2166433a..34af303b55a40 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2024.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2024.stderr @@ -32,7 +32,9 @@ error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/ref-binding-on-inh-ref-errors.rs:73:10 | LL | let [ref mut x] = &[0]; - | ^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^ ---- this cannot be borrowed as mutable + | | + | cannot borrow as mutable error: cannot explicitly borrow within an implicitly-borrowing pattern --> $DIR/ref-binding-on-inh-ref-errors.rs:81:10 diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.stable2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.stable2021.stderr index 33119c4447ada..508264f1a9409 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.stable2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.stable2021.stderr @@ -34,7 +34,9 @@ error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/ref-binding-on-inh-ref-errors.rs:73:10 | LL | let [ref mut x] = &[0]; - | ^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^ ---- this cannot be borrowed as mutable + | | + | cannot borrow as mutable error: aborting due to 3 previous errors diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2021.stderr index dbb8ae87b661c..30c0814e19380 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2021.stderr @@ -2,7 +2,9 @@ error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/ref-binding-on-inh-ref-errors.rs:73:10 | LL | let [ref mut x] = &[0]; - | ^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^ ---- this cannot be borrowed as mutable + | | + | cannot borrow as mutable error: aborting due to 1 previous error diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2024.stderr index 9753e3e5fbfea..57e3df45af4d3 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2024.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2024.stderr @@ -138,7 +138,9 @@ error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/ref-binding-on-inh-ref-errors.rs:73:10 | LL | let [ref mut x] = &[0]; - | ^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^ ---- this cannot be borrowed as mutable + | | + | cannot borrow as mutable error: cannot explicitly borrow within an implicitly-borrowing pattern --> $DIR/ref-binding-on-inh-ref-errors.rs:81:10 diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.classic2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.classic2021.stderr index 9bf5c9544e51c..b83824180bf16 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.classic2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.classic2021.stderr @@ -114,7 +114,9 @@ error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/well-typed-edition-2024.rs:111:19 | LL | let [&mut ref mut x] = &mut [&0]; - | ^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^ --------- this cannot be borrowed as mutable + | | + | cannot borrow as mutable error: aborting due to 8 previous errors diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.structural2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.structural2021.stderr index 9bf5c9544e51c..b83824180bf16 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.structural2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.structural2021.stderr @@ -114,7 +114,9 @@ error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/well-typed-edition-2024.rs:111:19 | LL | let [&mut ref mut x] = &mut [&0]; - | ^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^ --------- this cannot be borrowed as mutable + | | + | cannot borrow as mutable error: aborting due to 8 previous errors diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/enum.stderr b/tests/ui/rfcs/rfc-2005-default-binding-mode/enum.stderr index 21e3d3d273d7f..20d7391c72112 100644 --- a/tests/ui/rfcs/rfc-2005-default-binding-mode/enum.stderr +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/enum.stderr @@ -2,19 +2,19 @@ error[E0594]: cannot assign to `*x`, which is behind a `&` reference --> $DIR/enum.rs:9:5 | LL | *x += 1; - | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written to error[E0594]: cannot assign to `*x`, which is behind a `&` reference --> $DIR/enum.rs:13:9 | LL | *x += 1; - | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written to error[E0594]: cannot assign to `*x`, which is behind a `&` reference --> $DIR/enum.rs:19:9 | LL | *x += 1; - | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written to error: aborting due to 3 previous errors diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/explicit-mut.stderr b/tests/ui/rfcs/rfc-2005-default-binding-mode/explicit-mut.stderr index c3f64f65a412e..3f0ffbba0562c 100644 --- a/tests/ui/rfcs/rfc-2005-default-binding-mode/explicit-mut.stderr +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/explicit-mut.stderr @@ -2,19 +2,19 @@ error[E0594]: cannot assign to `*n`, which is behind a `&` reference --> $DIR/explicit-mut.rs:7:13 | LL | *n += 1; - | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written to error[E0594]: cannot assign to `*n`, which is behind a `&` reference --> $DIR/explicit-mut.rs:15:13 | LL | *n += 1; - | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written to error[E0594]: cannot assign to `*n`, which is behind a `&` reference --> $DIR/explicit-mut.rs:23:13 | LL | *n += 1; - | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written to error: aborting due to 3 previous errors diff --git a/tests/ui/suggestions/dont_suggest_raw_pointer_syntax-issue-127562.stderr b/tests/ui/suggestions/dont_suggest_raw_pointer_syntax-issue-127562.stderr index 5396db7940f72..4993d87c822f2 100644 --- a/tests/ui/suggestions/dont_suggest_raw_pointer_syntax-issue-127562.stderr +++ b/tests/ui/suggestions/dont_suggest_raw_pointer_syntax-issue-127562.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `*ptr`, which is behind a `*const` pointer --> $DIR/dont_suggest_raw_pointer_syntax-issue-127562.rs:5:9 | LL | *ptr = 3; - | ^^^^^^^^ `ptr` is a `*const` pointer, so the data it refers to cannot be written + | ^^^^^^^^ `ptr` is a `*const` pointer, so the data it refers to cannot be written to error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/issue-68049-1.stderr b/tests/ui/suggestions/issue-68049-1.stderr index 4e683b75c48b0..5f7fc6031d526 100644 --- a/tests/ui/suggestions/issue-68049-1.stderr +++ b/tests/ui/suggestions/issue-68049-1.stderr @@ -4,7 +4,7 @@ error[E0594]: cannot assign to `self.0`, which is behind a `&` reference LL | unsafe fn alloc(&self, _layout: Layout) -> *mut u8 { | ----- this is an immutable reference LL | self.0 += 1; - | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written to error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/issue-68049-2.stderr b/tests/ui/suggestions/issue-68049-2.stderr index 91def27bfcd7e..8c72578716844 100644 --- a/tests/ui/suggestions/issue-68049-2.stderr +++ b/tests/ui/suggestions/issue-68049-2.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `*input`, which is behind a `&` reference --> $DIR/issue-68049-2.rs:9:7 | LL | *input = self.0; - | ^^^^^^^^^^^^^^^ `input` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^^^^^^^^^ `input` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this to be a mutable reference in the `impl` method and the `trait` definition | @@ -13,7 +13,7 @@ error[E0594]: cannot assign to `self.0`, which is behind a `&` reference --> $DIR/issue-68049-2.rs:17:5 | LL | self.0 += *input; - | ^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this to be a mutable reference in the `impl` method and the `trait` definition | diff --git a/tests/ui/suggestions/suggest-mut-method-for-loop-closure.stderr b/tests/ui/suggestions/suggest-mut-method-for-loop-closure.stderr index 0bd286e0a6228..8f886e6103169 100644 --- a/tests/ui/suggestions/suggest-mut-method-for-loop-closure.stderr +++ b/tests/ui/suggestions/suggest-mut-method-for-loop-closure.stderr @@ -8,7 +8,7 @@ LL | for mut t in buzz.values() { | this iterator yields `&` references ... LL | t.v += 1; - | ^^^^^^^^ `t` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^^ `t` is a `&` reference, so the data it refers to cannot be written to error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/suggest-mut-method-for-loop-hashmap.stderr b/tests/ui/suggestions/suggest-mut-method-for-loop-hashmap.stderr index 1be14aa8f55d6..9228214c9d55f 100644 --- a/tests/ui/suggestions/suggest-mut-method-for-loop-hashmap.stderr +++ b/tests/ui/suggestions/suggest-mut-method-for-loop-hashmap.stderr @@ -8,7 +8,7 @@ LL | for (_k, v) in map.iter() { | this iterator yields `&` references ... LL | v.v += 1; - | ^^^^^^^^ `v` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^^ `v` is a `&` reference, so the data it refers to cannot be written to error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/suggest-mut-method-for-loop.stderr b/tests/ui/suggestions/suggest-mut-method-for-loop.stderr index 37bb25b300f3b..4a534b9b2b232 100644 --- a/tests/ui/suggestions/suggest-mut-method-for-loop.stderr +++ b/tests/ui/suggestions/suggest-mut-method-for-loop.stderr @@ -8,7 +8,7 @@ LL | for mut t in buzz.values() { | this iterator yields `&` references ... LL | t.v += 1; - | ^^^^^^^^ `t` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^^ `t` is a `&` reference, so the data it refers to cannot be written to error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/suggest-ref-mut.stderr b/tests/ui/suggestions/suggest-ref-mut.stderr index 7c0899f0fbc16..d4700498c85dd 100644 --- a/tests/ui/suggestions/suggest-ref-mut.stderr +++ b/tests/ui/suggestions/suggest-ref-mut.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `self.0`, which is behind a `&` reference --> $DIR/suggest-ref-mut.rs:9:9 | LL | self.0 = 32; - | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this to be a mutable reference | @@ -13,7 +13,7 @@ error[E0594]: cannot assign to `*foo`, which is behind a `&` reference --> $DIR/suggest-ref-mut.rs:17:5 | LL | *foo = 32; - | ^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this to be a mutable reference | @@ -24,7 +24,7 @@ error[E0594]: cannot assign to `*bar`, which is behind a `&` reference --> $DIR/suggest-ref-mut.rs:21:9 | LL | *bar = 32; - | ^^^^^^^^^ `bar` is a `&` reference, so the data it refers to cannot be written + | ^^^^^^^^^ `bar` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this to be a mutable reference | @@ -35,7 +35,7 @@ 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 + | ^^^^^^^^^ `quo` is a `&` reference, so the data it refers to cannot be written to | help: consider changing this to be a mutable reference | diff --git a/tests/ui/thread-local/thread-local-mutation.stderr b/tests/ui/thread-local/thread-local-mutation.stderr index 9001de34adfb5..02f5472ad2df6 100644 --- a/tests/ui/thread-local/thread-local-mutation.stderr +++ b/tests/ui/thread-local/thread-local-mutation.stderr @@ -1,6 +1,9 @@ error[E0594]: cannot assign to immutable static item `S` --> $DIR/thread-local-mutation.rs:11:5 | +LL | static S: &str = "before"; + | -------------- this `static` cannot be written to +... LL | S = "after"; | ^^^^^^^^^^^ cannot assign From 417542f85fbd72996ab1a1a18957b4e3390f831e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 5 Nov 2025 18:03:35 +0000 Subject: [PATCH 2/2] reword label --- .../src/diagnostics/mutability_errors.rs | 4 ++-- tests/ui/array-slice-vec/slice-mut-2.stderr | 2 +- ...ccidentally-cloning-ref-borrow-error.stderr | 2 +- .../argument_number_mismatch_ice.stderr | 2 +- ...rrow-raw-address-of-deref-mutability.stderr | 4 ++-- .../borrowck-access-permissions.stderr | 6 +++--- ...ck-assign-to-andmut-in-aliasable-loc.stderr | 4 ++-- ...borrow-mut-base-ptr-in-aliasable-loc.stderr | 4 ++-- tests/ui/borrowck/borrowck-issue-14498.stderr | 2 +- .../borrowck/borrowck-reborrow-from-mut.stderr | 2 +- .../issue-115259-suggest-iter-mut.stderr | 2 +- .../issue-62387-suggest-iter-mut-2.stderr | 2 +- .../issue-62387-suggest-iter-mut.stderr | 4 ++-- .../issue-69789-iterator-mut-suggestion.stderr | 2 +- tests/ui/borrowck/issue-82032.stderr | 2 +- .../issue-83309-ice-immut-in-for-loop.rs | 2 +- .../issue-83309-ice-immut-in-for-loop.stderr | 2 +- tests/ui/borrowck/issue-85765-closure.rs | 8 ++++---- tests/ui/borrowck/issue-85765-closure.stderr | 8 ++++---- tests/ui/borrowck/issue-85765.rs | 8 ++++---- tests/ui/borrowck/issue-85765.stderr | 8 ++++---- tests/ui/borrowck/issue-91206.rs | 2 +- tests/ui/borrowck/issue-91206.stderr | 2 +- tests/ui/borrowck/issue-92015.stderr | 2 +- tests/ui/borrowck/issue-93093.stderr | 2 +- tests/ui/borrowck/mutability-errors.stderr | 16 ++++++++-------- ...utable-borrow-behind-reference-61623.stderr | 2 +- ...gestion-for-raw-pointer-issue-127562.stderr | 2 +- .../suggest-as-ref-on-mut-closure.stderr | 2 +- tests/ui/borrowck/suggest-mut-iterator.stderr | 2 +- ...aded-index-not-mut-but-should-be-mut.stderr | 6 +++--- .../overloaded-index-without-indexmut.stderr | 2 +- .../trait-impl-argument-difference-ice.stderr | 4 ++-- .../diagnostics/mut_ref.stderr | 2 +- tests/ui/did_you_mean/issue-38147-1.stderr | 2 +- tests/ui/did_you_mean/issue-38147-4.stderr | 2 +- tests/ui/did_you_mean/issue-39544.stderr | 18 +++++++++--------- tests/ui/did_you_mean/issue-40823.stderr | 2 +- tests/ui/error-codes/E0389.stderr | 2 +- tests/ui/issues/issue-51515.stderr | 4 ++-- .../let-else-binding-explicit-mut.stderr | 6 +++--- .../let-else/let-else-binding-immutable.stderr | 2 +- tests/ui/mut/mutable-class-fields-2.stderr | 2 +- tests/ui/nll/issue-47388.stderr | 2 +- tests/ui/nll/issue-51244.stderr | 2 +- tests/ui/nll/issue-57989.stderr | 2 +- .../borrowck-move-ref-pattern.stderr | 4 ++-- .../rfc-2005-default-binding-mode/enum.stderr | 6 +++--- .../explicit-mut.stderr | 6 +++--- ...wck-borrow-overloaded-auto-deref-mut.stderr | 8 ++++---- ...borrowck-borrow-overloaded-deref-mut.stderr | 4 ++-- .../borrowck-call-is-borrow-issue-12224.stderr | 4 ++-- ...rowck-call-method-from-mut-aliasable.stderr | 2 +- tests/ui/span/borrowck-fn-in-const-b.stderr | 2 +- .../ui/span/borrowck-object-mutability.stderr | 2 +- tests/ui/span/mut-arg-hint.stderr | 6 +++--- ...gest_raw_pointer_syntax-issue-127562.stderr | 2 +- tests/ui/suggestions/issue-68049-1.stderr | 2 +- tests/ui/suggestions/issue-68049-2.stderr | 4 ++-- .../suggest-mut-method-for-loop-closure.stderr | 2 +- .../suggest-mut-method-for-loop-hashmap.stderr | 2 +- .../suggest-mut-method-for-loop.stderr | 2 +- tests/ui/suggestions/suggest-ref-mut.stderr | 8 ++++---- ...al-bounds-inconsistent-copy-reborrow.stderr | 4 ++-- 64 files changed, 121 insertions(+), 121 deletions(-) diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index 621af32cf5984..d03c7cd2086d8 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -518,8 +518,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { err.span_label( span, format!( - "`{name}` is a `{pointer_sigil}` {pointer_desc}, \ - so the data it refers to cannot be {acted_on}", + "`{name}` is a `{pointer_sigil}` {pointer_desc}, so it cannot be \ + {acted_on}", ), ); diff --git a/tests/ui/array-slice-vec/slice-mut-2.stderr b/tests/ui/array-slice-vec/slice-mut-2.stderr index 228417c873dbe..49639ff1d227d 100644 --- a/tests/ui/array-slice-vec/slice-mut-2.stderr +++ b/tests/ui/array-slice-vec/slice-mut-2.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/slice-mut-2.rs:7:18 | LL | let _ = &mut x[2..4]; - | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^ `x` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this binding's type | diff --git a/tests/ui/borrowck/accidentally-cloning-ref-borrow-error.stderr b/tests/ui/borrowck/accidentally-cloning-ref-borrow-error.stderr index 7e51a4819eef6..e7b103eef9348 100644 --- a/tests/ui/borrowck/accidentally-cloning-ref-borrow-error.stderr +++ b/tests/ui/borrowck/accidentally-cloning-ref-borrow-error.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `sm.x` as mutable, as it is behind a `&` reference --> $DIR/accidentally-cloning-ref-borrow-error.rs:32:9 | LL | foo(&mut sm.x); - | ^^^^^^^^^ `sm` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^^^^^ `sm` is a `&` reference, so it cannot be borrowed as mutable | help: `Str` doesn't implement `Clone`, so this call clones the reference `&Str` --> $DIR/accidentally-cloning-ref-borrow-error.rs:31:21 diff --git a/tests/ui/borrowck/argument_number_mismatch_ice.stderr b/tests/ui/borrowck/argument_number_mismatch_ice.stderr index 6a0c49c3db8d3..f2f4567f7150f 100644 --- a/tests/ui/borrowck/argument_number_mismatch_ice.stderr +++ b/tests/ui/borrowck/argument_number_mismatch_ice.stderr @@ -11,7 +11,7 @@ error[E0594]: cannot assign to `*input`, which is behind a `&` reference --> $DIR/argument_number_mismatch_ice.rs:10:9 | LL | *input = self.0; - | ^^^^^^^^^^^^^^^ `input` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^^^^^^^^^ `input` is a `&` reference, so it cannot be written to | help: consider changing this to be a mutable reference in the `impl` method and the `trait` definition | diff --git a/tests/ui/borrowck/borrow-raw-address-of-deref-mutability.stderr b/tests/ui/borrowck/borrow-raw-address-of-deref-mutability.stderr index 0a32cccff1d4c..d796d541ab209 100644 --- a/tests/ui/borrowck/borrow-raw-address-of-deref-mutability.stderr +++ b/tests/ui/borrowck/borrow-raw-address-of-deref-mutability.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrow-raw-address-of-deref-mutability.rs:6:13 | LL | let q = &raw mut *x; - | ^^^^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^^^^^^^ `x` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | @@ -13,7 +13,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `*const` pointer --> $DIR/borrow-raw-address-of-deref-mutability.rs:12:13 | LL | let q = &raw mut *x; - | ^^^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable + | ^^^^^^^^^^^ `x` is a `*const` pointer, so it cannot be borrowed as mutable | help: consider specifying this binding's type | diff --git a/tests/ui/borrowck/borrowck-access-permissions.stderr b/tests/ui/borrowck/borrowck-access-permissions.stderr index e3a87e6961466..376b6bd271261 100644 --- a/tests/ui/borrowck/borrowck-access-permissions.stderr +++ b/tests/ui/borrowck/borrowck-access-permissions.stderr @@ -33,7 +33,7 @@ error[E0596]: cannot borrow `*ref_x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-access-permissions.rs:36:19 | LL | let _y1 = &mut *ref_x; - | ^^^^^^^^^^^ `ref_x` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^^^^^^^ `ref_x` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | @@ -44,7 +44,7 @@ error[E0596]: cannot borrow `*ptr_x` as mutable, as it is behind a `*const` poin --> $DIR/borrowck-access-permissions.rs:46:23 | LL | let _y1 = &mut *ptr_x; - | ^^^^^^^^^^^ `ptr_x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable + | ^^^^^^^^^^^ `ptr_x` is a `*const` pointer, so it cannot be borrowed as mutable | help: consider changing this binding's type | @@ -56,7 +56,7 @@ error[E0596]: cannot borrow `*foo_ref.f` as mutable, as it is behind a `&` refer --> $DIR/borrowck-access-permissions.rs:59:18 | LL | let _y = &mut *foo_ref.f; - | ^^^^^^^^^^^^^^^ `foo_ref` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^^^^^^^^^^^ `foo_ref` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | diff --git a/tests/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr b/tests/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr index 343824df6c0ed..62d456c5510a2 100644 --- a/tests/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr +++ b/tests/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `*s.pointer`, which is behind a `&` reference --> $DIR/borrowck-assign-to-andmut-in-aliasable-loc.rs:9:5 | LL | *s.pointer += 1; - | ^^^^^^^^^^^^^^^ `s` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^^^^^^^^^ `s` is a `&` reference, so it cannot be written to | help: consider changing this to be a mutable reference | @@ -13,7 +13,7 @@ error[E0594]: cannot assign to `*s.pointer`, which is behind a `&` reference --> $DIR/borrowck-assign-to-andmut-in-aliasable-loc.rs:17:5 | LL | *s.pointer += 1; - | ^^^^^^^^^^^^^^^ `s` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^^^^^^^^^ `s` is a `&` reference, so it cannot be written to | help: consider changing this to be a mutable reference | diff --git a/tests/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr b/tests/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr index cc2bc7036d91a..7e516fe89b40c 100644 --- a/tests/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr +++ b/tests/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `**t1`, which is behind a `&` reference --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:9:5 | LL | **t1 = 22; - | ^^^^^^^^^ `t1` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^^^ `t1` is a `&` reference, so it cannot be written to | help: consider specifying this binding's type | @@ -23,7 +23,7 @@ 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 | let x: &mut isize = &mut **t0; - | ^^^^^^^^^ `t0` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^^^^^ `t0` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | diff --git a/tests/ui/borrowck/borrowck-issue-14498.stderr b/tests/ui/borrowck/borrowck-issue-14498.stderr index 7348bba704930..a79fd3c74f896 100644 --- a/tests/ui/borrowck/borrowck-issue-14498.stderr +++ b/tests/ui/borrowck/borrowck-issue-14498.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `***p`, which is behind a `&` reference --> $DIR/borrowck-issue-14498.rs:16:5 | LL | ***p = 2; - | ^^^^^^^^ `p` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^^ `p` is a `&` reference, so it cannot be written to | help: consider changing this to be a mutable reference | diff --git a/tests/ui/borrowck/borrowck-reborrow-from-mut.stderr b/tests/ui/borrowck/borrowck-reborrow-from-mut.stderr index fb3db4e144635..cd576aafb383f 100644 --- a/tests/ui/borrowck/borrowck-reborrow-from-mut.stderr +++ b/tests/ui/borrowck/borrowck-reborrow-from-mut.stderr @@ -106,7 +106,7 @@ error[E0596]: cannot borrow `foo.bar1` as mutable, as it is behind a `&` referen --> $DIR/borrowck-reborrow-from-mut.rs:88:17 | LL | let _bar1 = &mut foo.bar1; - | ^^^^^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^^^^^^^^^ `foo` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | diff --git a/tests/ui/borrowck/issue-115259-suggest-iter-mut.stderr b/tests/ui/borrowck/issue-115259-suggest-iter-mut.stderr index 61c01f0f024fe..8191f1f4394b7 100644 --- a/tests/ui/borrowck/issue-115259-suggest-iter-mut.stderr +++ b/tests/ui/borrowck/issue-115259-suggest-iter-mut.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `**layer` as mutable, as it is behind a `&` referenc --> $DIR/issue-115259-suggest-iter-mut.rs:15:65 | LL | self.layers.iter().fold(0, |result, mut layer| result + layer.process()) - | --------- ^^^^^ `layer` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | --------- ^^^^^ `layer` is a `&` reference, so it cannot be borrowed as mutable | | | consider changing this binding's type to be: `&mut Box` | diff --git a/tests/ui/borrowck/issue-62387-suggest-iter-mut-2.stderr b/tests/ui/borrowck/issue-62387-suggest-iter-mut-2.stderr index c6955317d87d5..29121b85f3a08 100644 --- a/tests/ui/borrowck/issue-62387-suggest-iter-mut-2.stderr +++ b/tests/ui/borrowck/issue-62387-suggest-iter-mut-2.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*container` as mutable, as it is behind a `&` refer --> $DIR/issue-62387-suggest-iter-mut-2.rs:30:45 | LL | vec.iter().flat_map(|container| container.things()).cloned().collect::>(); - | --------- ^^^^^^^^^ `container` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | --------- ^^^^^^^^^ `container` is a `&` reference, so it cannot be borrowed as mutable | | | consider changing this binding's type to be: `&mut Container` | diff --git a/tests/ui/borrowck/issue-62387-suggest-iter-mut.stderr b/tests/ui/borrowck/issue-62387-suggest-iter-mut.stderr index ae4920b2a8cb0..55c17ab6cdea1 100644 --- a/tests/ui/borrowck/issue-62387-suggest-iter-mut.stderr +++ b/tests/ui/borrowck/issue-62387-suggest-iter-mut.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference --> $DIR/issue-62387-suggest-iter-mut.rs:18:27 | LL | v.iter().for_each(|a| a.double()); - | - ^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | - ^ `a` is a `&` reference, so it cannot be borrowed as mutable | | | consider changing this binding's type to be: `&mut A` | @@ -15,7 +15,7 @@ error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference --> $DIR/issue-62387-suggest-iter-mut.rs:25:39 | LL | v.iter().rev().rev().for_each(|a| a.double()); - | - ^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | - ^ `a` is a `&` reference, so it cannot be borrowed as mutable | | | consider changing this binding's type to be: `&mut A` | diff --git a/tests/ui/borrowck/issue-69789-iterator-mut-suggestion.stderr b/tests/ui/borrowck/issue-69789-iterator-mut-suggestion.stderr index 824a02c28f28e..048ed80fd82f3 100644 --- a/tests/ui/borrowck/issue-69789-iterator-mut-suggestion.stderr +++ b/tests/ui/borrowck/issue-69789-iterator-mut-suggestion.stderr @@ -5,7 +5,7 @@ LL | for item in &mut std::iter::empty::<&'static ()>() { | -------------------------------------- this iterator yields `&` references LL | LL | *item = (); - | ^^^^^^^^^^ `item` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^^^^ `item` is a `&` reference, so it cannot be written to error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/issue-82032.stderr b/tests/ui/borrowck/issue-82032.stderr index 2ac785cd1e3bd..d44b5e1b35f50 100644 --- a/tests/ui/borrowck/issue-82032.stderr +++ b/tests/ui/borrowck/issue-82032.stderr @@ -7,7 +7,7 @@ LL | for v in self.0.values() { | | help: use mutable method: `values_mut()` | this iterator yields `&` references LL | v.flush(); - | ^ `v` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^ `v` is a `&` reference, so it cannot be borrowed as mutable error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/issue-83309-ice-immut-in-for-loop.rs b/tests/ui/borrowck/issue-83309-ice-immut-in-for-loop.rs index d301e7b3524b8..f11eb65614a65 100644 --- a/tests/ui/borrowck/issue-83309-ice-immut-in-for-loop.rs +++ b/tests/ui/borrowck/issue-83309-ice-immut-in-for-loop.rs @@ -10,7 +10,7 @@ fn main() { //~^ NOTE this iterator yields `&` references *v -= 1; //~^ ERROR cannot assign to `*v`, which is behind a `&` reference - //~| NOTE `v` is a `&` reference, so the data it refers to cannot be written + //~| NOTE `v` is a `&` reference, so it cannot be written to } } diff --git a/tests/ui/borrowck/issue-83309-ice-immut-in-for-loop.stderr b/tests/ui/borrowck/issue-83309-ice-immut-in-for-loop.stderr index 9bd4d9c65ff71..0860f0c3afdfc 100644 --- a/tests/ui/borrowck/issue-83309-ice-immut-in-for-loop.stderr +++ b/tests/ui/borrowck/issue-83309-ice-immut-in-for-loop.stderr @@ -5,7 +5,7 @@ LL | for v in Query.iter_mut() { | ---------------- this iterator yields `&` references LL | LL | *v -= 1; - | ^^^^^^^ `v` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^ `v` is a `&` reference, so it cannot be written to error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/issue-85765-closure.rs b/tests/ui/borrowck/issue-85765-closure.rs index f2d1dd0fbc3fb..09b2d6c939a2b 100644 --- a/tests/ui/borrowck/issue-85765-closure.rs +++ b/tests/ui/borrowck/issue-85765-closure.rs @@ -5,27 +5,27 @@ fn main() { //~^ HELP consider changing this binding's type rofl.push(Vec::new()); //~^ ERROR cannot borrow `*rofl` as mutable, as it is behind a `&` reference - //~| NOTE `rofl` is a `&` reference, so the data it refers to cannot be borrowed as mutable + //~| NOTE `rofl` is a `&` reference, so it cannot be borrowed as mutable let mut mutvar = 42; let r = &mutvar; //~^ HELP consider changing this to be a mutable reference *r = 0; //~^ ERROR cannot assign to `*r`, which is behind a `&` reference - //~| NOTE `r` is a `&` reference, so the data it refers to cannot be written + //~| NOTE `r` is a `&` reference, so it cannot be written to #[rustfmt::skip] let x: &usize = &mut{0}; //~^ HELP consider changing this binding's type *x = 1; //~^ ERROR cannot assign to `*x`, which is behind a `&` reference - //~| NOTE `x` is a `&` reference, so the data it refers to cannot be written + //~| NOTE `x` is a `&` reference, so it cannot be written to #[rustfmt::skip] let y: &usize = &mut(0); //~^ HELP consider changing this binding's type *y = 1; //~^ ERROR cannot assign to `*y`, which is behind a `&` reference - //~| NOTE `y` is a `&` reference, so the data it refers to cannot be written + //~| NOTE `y` is a `&` reference, so it cannot be written to }; } diff --git a/tests/ui/borrowck/issue-85765-closure.stderr b/tests/ui/borrowck/issue-85765-closure.stderr index 0d1ef501a7446..1b1cd9cabb68c 100644 --- a/tests/ui/borrowck/issue-85765-closure.stderr +++ b/tests/ui/borrowck/issue-85765-closure.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*rofl` as mutable, as it is behind a `&` reference --> $DIR/issue-85765-closure.rs:6:9 | LL | rofl.push(Vec::new()); - | ^^^^ `rofl` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^ `rofl` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this binding's type | @@ -13,7 +13,7 @@ error[E0594]: cannot assign to `*r`, which is behind a `&` reference --> $DIR/issue-85765-closure.rs:13:9 | LL | *r = 0; - | ^^^^^^ `r` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^ `r` is a `&` reference, so it cannot be written to | help: consider changing this to be a mutable reference | @@ -24,7 +24,7 @@ error[E0594]: cannot assign to `*x`, which is behind a `&` reference --> $DIR/issue-85765-closure.rs:20:9 | LL | *x = 1; - | ^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^ `x` is a `&` reference, so it cannot be written to | help: consider changing this binding's type | @@ -35,7 +35,7 @@ error[E0594]: cannot assign to `*y`, which is behind a `&` reference --> $DIR/issue-85765-closure.rs:27:9 | LL | *y = 1; - | ^^^^^^ `y` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^ `y` is a `&` reference, so it cannot be written to | help: consider changing this binding's type | diff --git a/tests/ui/borrowck/issue-85765.rs b/tests/ui/borrowck/issue-85765.rs index 76e0b51735416..22e3882a8c781 100644 --- a/tests/ui/borrowck/issue-85765.rs +++ b/tests/ui/borrowck/issue-85765.rs @@ -4,26 +4,26 @@ fn main() { //~^ HELP consider changing this binding's type rofl.push(Vec::new()); //~^ ERROR cannot borrow `*rofl` as mutable, as it is behind a `&` reference - //~| NOTE `rofl` is a `&` reference, so the data it refers to cannot be borrowed as mutable + //~| NOTE `rofl` is a `&` reference, so it cannot be borrowed as mutable let mut mutvar = 42; let r = &mutvar; //~^ HELP consider changing this to be a mutable reference *r = 0; //~^ ERROR cannot assign to `*r`, which is behind a `&` reference - //~| NOTE `r` is a `&` reference, so the data it refers to cannot be written + //~| NOTE `r` is a `&` reference, so it cannot be written to #[rustfmt::skip] let x: &usize = &mut{0}; //~^ HELP consider changing this binding's type *x = 1; //~^ ERROR cannot assign to `*x`, which is behind a `&` reference - //~| NOTE `x` is a `&` reference, so the data it refers to cannot be written + //~| NOTE `x` is a `&` reference, so it cannot be written to #[rustfmt::skip] let y: &usize = &mut(0); //~^ HELP consider changing this binding's type *y = 1; //~^ ERROR cannot assign to `*y`, which is behind a `&` reference - //~| NOTE `y` is a `&` reference, so the data it refers to cannot be written + //~| NOTE `y` is a `&` reference, so it cannot be written to } diff --git a/tests/ui/borrowck/issue-85765.stderr b/tests/ui/borrowck/issue-85765.stderr index 862e175350918..6567891fde61b 100644 --- a/tests/ui/borrowck/issue-85765.stderr +++ b/tests/ui/borrowck/issue-85765.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*rofl` as mutable, as it is behind a `&` reference --> $DIR/issue-85765.rs:5:5 | LL | rofl.push(Vec::new()); - | ^^^^ `rofl` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^ `rofl` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this binding's type | @@ -13,7 +13,7 @@ error[E0594]: cannot assign to `*r`, which is behind a `&` reference --> $DIR/issue-85765.rs:12:5 | LL | *r = 0; - | ^^^^^^ `r` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^ `r` is a `&` reference, so it cannot be written to | help: consider changing this to be a mutable reference | @@ -24,7 +24,7 @@ error[E0594]: cannot assign to `*x`, which is behind a `&` reference --> $DIR/issue-85765.rs:19:5 | LL | *x = 1; - | ^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^ `x` is a `&` reference, so it cannot be written to | help: consider changing this binding's type | @@ -35,7 +35,7 @@ error[E0594]: cannot assign to `*y`, which is behind a `&` reference --> $DIR/issue-85765.rs:26:5 | LL | *y = 1; - | ^^^^^^ `y` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^ `y` is a `&` reference, so it cannot be written to | help: consider changing this binding's type | diff --git a/tests/ui/borrowck/issue-91206.rs b/tests/ui/borrowck/issue-91206.rs index e062a253767de..4f876853610ea 100644 --- a/tests/ui/borrowck/issue-91206.rs +++ b/tests/ui/borrowck/issue-91206.rs @@ -12,5 +12,5 @@ fn main() { //~^ HELP consider specifying this binding's type inner.clear(); //~^ ERROR cannot borrow `*inner` as mutable, as it is behind a `&` reference [E0596] - //~| NOTE `inner` is a `&` reference, so the data it refers to cannot be borrowed as mutable + //~| NOTE `inner` is a `&` reference, so it cannot be borrowed as mutable } diff --git a/tests/ui/borrowck/issue-91206.stderr b/tests/ui/borrowck/issue-91206.stderr index f96b0c7d9e1a6..ebd9ace34bcdd 100644 --- a/tests/ui/borrowck/issue-91206.stderr +++ b/tests/ui/borrowck/issue-91206.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*inner` as mutable, as it is behind a `&` reference --> $DIR/issue-91206.rs:13:5 | LL | inner.clear(); - | ^^^^^ `inner` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^ `inner` is a `&` reference, so it cannot be borrowed as mutable | help: consider specifying this binding's type | diff --git a/tests/ui/borrowck/issue-92015.stderr b/tests/ui/borrowck/issue-92015.stderr index 62b4ae3217460..cfd30b8337841 100644 --- a/tests/ui/borrowck/issue-92015.stderr +++ b/tests/ui/borrowck/issue-92015.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `*foo`, which is behind a `&` reference --> $DIR/issue-92015.rs:6:5 | LL | *foo = 1; - | ^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^^ `foo` is a `&` reference, so it cannot be written to | help: consider specifying this binding's type | diff --git a/tests/ui/borrowck/issue-93093.stderr b/tests/ui/borrowck/issue-93093.stderr index 58aa6bc655cbd..02239627a8932 100644 --- a/tests/ui/borrowck/issue-93093.stderr +++ b/tests/ui/borrowck/issue-93093.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `self.foo`, which is behind a `&` reference --> $DIR/issue-93093.rs:8:9 | LL | self.foo += 1; - | ^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^^^^^^^ `self` is a `&` reference, so it cannot be written to | help: consider changing this to be a mutable reference | diff --git a/tests/ui/borrowck/mutability-errors.stderr b/tests/ui/borrowck/mutability-errors.stderr index f5c61457f8235..18d8e6eb1a6e7 100644 --- a/tests/ui/borrowck/mutability-errors.stderr +++ b/tests/ui/borrowck/mutability-errors.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `*x`, which is behind a `&` reference --> $DIR/mutability-errors.rs:9:5 | LL | *x = (1,); - | ^^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^^^ `x` is a `&` reference, so it cannot be written to | help: consider changing this to be a mutable reference | @@ -13,7 +13,7 @@ error[E0594]: cannot assign to `x.0`, which is behind a `&` reference --> $DIR/mutability-errors.rs:10:5 | LL | x.0 = 1; - | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^ `x` is a `&` reference, so it cannot be written to | help: consider changing this to be a mutable reference | @@ -24,7 +24,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/mutability-errors.rs:11:5 | LL | &mut *x; - | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^^^ `x` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | @@ -35,7 +35,7 @@ error[E0596]: cannot borrow `x.0` as mutable, as it is behind a `&` reference --> $DIR/mutability-errors.rs:12:5 | LL | &mut x.0; - | ^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^^^^ `x` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | @@ -70,7 +70,7 @@ error[E0594]: cannot assign to `*x`, which is behind a `*const` pointer --> $DIR/mutability-errors.rs:23:5 | LL | *x = (1,); - | ^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be written to + | ^^^^^^^^^ `x` is a `*const` pointer, so it cannot be written to | help: consider changing this to be a mutable pointer | @@ -81,7 +81,7 @@ error[E0594]: cannot assign to `x.0`, which is behind a `*const` pointer --> $DIR/mutability-errors.rs:24:5 | LL | (*x).0 = 1; - | ^^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be written to + | ^^^^^^^^^^ `x` is a `*const` pointer, so it cannot be written to | help: consider changing this to be a mutable pointer | @@ -92,7 +92,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `*const` pointer --> $DIR/mutability-errors.rs:25:5 | LL | &mut *x; - | ^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable + | ^^^^^^^ `x` is a `*const` pointer, so it cannot be borrowed as mutable | help: consider changing this to be a mutable pointer | @@ -103,7 +103,7 @@ error[E0596]: cannot borrow `x.0` as mutable, as it is behind a `*const` pointer --> $DIR/mutability-errors.rs:26:5 | LL | &mut (*x).0; - | ^^^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable + | ^^^^^^^^^^^ `x` is a `*const` pointer, so it cannot be borrowed as mutable | help: consider changing this to be a mutable pointer | diff --git a/tests/ui/borrowck/mutable-borrow-behind-reference-61623.stderr b/tests/ui/borrowck/mutable-borrow-behind-reference-61623.stderr index cc7761acda9de..0357b7c6df8ce 100644 --- a/tests/ui/borrowck/mutable-borrow-behind-reference-61623.stderr +++ b/tests/ui/borrowck/mutable-borrow-behind-reference-61623.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*x.1` as mutable, as it is behind a `&` reference --> $DIR/mutable-borrow-behind-reference-61623.rs:7:19 | LL | f2(|| x.0, f1(x.1)) - | ^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^ `x` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | diff --git a/tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.stderr b/tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.stderr index 47cd6f029b57d..208e73235873b 100644 --- a/tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.stderr +++ b/tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `*ptr`, which is behind a `*const` pointer --> $DIR/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.rs:7:14 | LL | unsafe { *ptr = 3; } - | ^^^^^^^^ `ptr` is a `*const` pointer, so the data it refers to cannot be written to + | ^^^^^^^^ `ptr` is a `*const` pointer, so it cannot be written to | help: consider changing this to be a mutable pointer | diff --git a/tests/ui/borrowck/suggest-as-ref-on-mut-closure.stderr b/tests/ui/borrowck/suggest-as-ref-on-mut-closure.stderr index 1e98006a9a71e..ca0d0bd8a3caa 100644 --- a/tests/ui/borrowck/suggest-as-ref-on-mut-closure.stderr +++ b/tests/ui/borrowck/suggest-as-ref-on-mut-closure.stderr @@ -18,7 +18,7 @@ error[E0596]: cannot borrow `*cb` as mutable, as it is behind a `&` reference --> $DIR/suggest-as-ref-on-mut-closure.rs:12:26 | LL | cb.as_ref().map(|cb| cb()); - | -- ^^ `cb` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | -- ^^ `cb` is a `&` reference, so it cannot be borrowed as mutable | | | consider changing this binding's type to be: `&mut &mut dyn FnMut()` diff --git a/tests/ui/borrowck/suggest-mut-iterator.stderr b/tests/ui/borrowck/suggest-mut-iterator.stderr index b396bb7b5ec4c..bdb5fbfd2bcd6 100644 --- a/tests/ui/borrowck/suggest-mut-iterator.stderr +++ b/tests/ui/borrowck/suggest-mut-iterator.stderr @@ -4,7 +4,7 @@ error[E0596]: cannot borrow `*test` as mutable, as it is behind a `&` reference LL | for test in &tests { | ------ this iterator yields `&` references LL | test.add(2); - | ^^^^ `test` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^ `test` is a `&` reference, so it cannot be borrowed as mutable | help: use a mutable iterator instead | diff --git a/tests/ui/borrowck/suggestions/overloaded-index-not-mut-but-should-be-mut.stderr b/tests/ui/borrowck/suggestions/overloaded-index-not-mut-but-should-be-mut.stderr index 44cc9aefcf187..8ddc7368793cd 100644 --- a/tests/ui/borrowck/suggestions/overloaded-index-not-mut-but-should-be-mut.stderr +++ b/tests/ui/borrowck/suggestions/overloaded-index-not-mut-but-should-be-mut.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*string` as mutable, as it is behind a `&` referenc --> $DIR/overloaded-index-not-mut-but-should-be-mut.rs:7:5 | LL | string.push_str("test"); - | ^^^^^^ `string` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^^ `string` is a `&` reference, so it cannot be borrowed as mutable | help: consider using `get_mut` | @@ -14,7 +14,7 @@ error[E0596]: cannot borrow `*string` as mutable, as it is behind a `&` referenc --> $DIR/overloaded-index-not-mut-but-should-be-mut.rs:14:5 | LL | string.push_str("test"); - | ^^^^^^ `string` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^^ `string` is a `&` reference, so it cannot be borrowed as mutable | help: consider using `get_mut` | @@ -26,7 +26,7 @@ error[E0596]: cannot borrow `*string` as mutable, as it is behind a `&` referenc --> $DIR/overloaded-index-not-mut-but-should-be-mut.rs:19:5 | LL | string.push_str("test"); - | ^^^^^^ `string` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^^ `string` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | diff --git a/tests/ui/borrowck/suggestions/overloaded-index-without-indexmut.stderr b/tests/ui/borrowck/suggestions/overloaded-index-without-indexmut.stderr index 6a46332a5d7b7..7e952d69945c4 100644 --- a/tests/ui/borrowck/suggestions/overloaded-index-without-indexmut.stderr +++ b/tests/ui/borrowck/suggestions/overloaded-index-without-indexmut.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*y` as mutable, as it is behind a `&` reference --> $DIR/overloaded-index-without-indexmut.rs:14:5 | LL | y.push_str(""); - | ^ `y` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^ `y` is a `&` reference, so it cannot be borrowed as mutable error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/trait-impl-argument-difference-ice.stderr b/tests/ui/borrowck/trait-impl-argument-difference-ice.stderr index 3d54d5269ae2b..90d9ee3f32af0 100644 --- a/tests/ui/borrowck/trait-impl-argument-difference-ice.stderr +++ b/tests/ui/borrowck/trait-impl-argument-difference-ice.stderr @@ -36,7 +36,7 @@ error[E0596]: cannot borrow `*self` as mutable, as it is behind a `&` reference --> $DIR/trait-impl-argument-difference-ice.rs:16:19 | LL | let a16 = self.read_word() as u16; - | ^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^ `self` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference in the `impl` method and the `trait` definition | @@ -47,7 +47,7 @@ error[E0596]: cannot borrow `*self` as mutable, as it is behind a `&` reference --> $DIR/trait-impl-argument-difference-ice.rs:18:19 | LL | let b16 = self.read_word() as u16; - | ^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^ `self` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference in the `impl` method and the `trait` definition | diff --git a/tests/ui/closures/2229_closure_analysis/diagnostics/mut_ref.stderr b/tests/ui/closures/2229_closure_analysis/diagnostics/mut_ref.stderr index 1904faa959861..930659a2c9098 100644 --- a/tests/ui/closures/2229_closure_analysis/diagnostics/mut_ref.stderr +++ b/tests/ui/closures/2229_closure_analysis/diagnostics/mut_ref.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `**ref_mref_x` as mutable, as it is behind a `&` ref --> $DIR/mut_ref.rs:12:13 | LL | let c = || { - | ^^ `ref_mref_x` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^ `ref_mref_x` is a `&` reference, so it cannot be borrowed as mutable LL | LL | **ref_mref_x = y; | ------------ mutable borrow occurs due to use of `**ref_mref_x` in closure diff --git a/tests/ui/did_you_mean/issue-38147-1.stderr b/tests/ui/did_you_mean/issue-38147-1.stderr index 6def86e4ba8f1..1a6d1986c55bd 100644 --- a/tests/ui/did_you_mean/issue-38147-1.stderr +++ b/tests/ui/did_you_mean/issue-38147-1.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` referenc --> $DIR/issue-38147-1.rs:17:9 | LL | self.s.push('x'); - | ^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^^ `self` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | diff --git a/tests/ui/did_you_mean/issue-38147-4.stderr b/tests/ui/did_you_mean/issue-38147-4.stderr index 57309172194f4..1592238d6bed8 100644 --- a/tests/ui/did_you_mean/issue-38147-4.stderr +++ b/tests/ui/did_you_mean/issue-38147-4.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*f.s` as mutable, as it is behind a `&` reference --> $DIR/issue-38147-4.rs:6:5 | LL | f.s.push('x'); - | ^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^ `f` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | diff --git a/tests/ui/did_you_mean/issue-39544.stderr b/tests/ui/did_you_mean/issue-39544.stderr index 62dc027e31f2d..745ff2bac06dd 100644 --- a/tests/ui/did_you_mean/issue-39544.stderr +++ b/tests/ui/did_you_mean/issue-39544.stderr @@ -13,7 +13,7 @@ error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference --> $DIR/issue-39544.rs:16:17 | LL | let _ = &mut self.x; - | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^^^^^^^ `self` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | @@ -24,7 +24,7 @@ error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference --> $DIR/issue-39544.rs:20:17 | LL | let _ = &mut self.x; - | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^^^^^^^ `self` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | @@ -35,7 +35,7 @@ error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` referenc --> $DIR/issue-39544.rs:21:17 | LL | let _ = &mut other.x; - | ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^^^^^^^^ `other` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | @@ -46,7 +46,7 @@ error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference --> $DIR/issue-39544.rs:25:17 | LL | let _ = &mut self.x; - | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^^^^^^^ `self` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | @@ -57,7 +57,7 @@ error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` referenc --> $DIR/issue-39544.rs:26:17 | LL | let _ = &mut other.x; - | ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^^^^^^^^ `other` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | @@ -68,7 +68,7 @@ error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference --> $DIR/issue-39544.rs:30:17 | LL | let _ = &mut self.x; - | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^^^^^^^ `self` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | @@ -79,7 +79,7 @@ error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` referenc --> $DIR/issue-39544.rs:31:17 | LL | let _ = &mut other.x; - | ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^^^^^^^^ `other` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | @@ -90,7 +90,7 @@ error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` referenc --> $DIR/issue-39544.rs:35:17 | LL | let _ = &mut other.x; - | ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^^^^^^^^ `other` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | @@ -112,7 +112,7 @@ error[E0596]: cannot borrow `w.x` as mutable, as it is behind a `&` reference --> $DIR/issue-39544.rs:42:13 | LL | let _ = &mut w.x; - | ^^^^^^^^ `w` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^^^^^ `w` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | diff --git a/tests/ui/did_you_mean/issue-40823.stderr b/tests/ui/did_you_mean/issue-40823.stderr index d9f69eb47d241..cf75b20c81450 100644 --- a/tests/ui/did_you_mean/issue-40823.stderr +++ b/tests/ui/did_you_mean/issue-40823.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*buf` as mutable, as it is behind a `&` reference --> $DIR/issue-40823.rs:3:5 | LL | buf.iter_mut(); - | ^^^ `buf` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^ `buf` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | diff --git a/tests/ui/error-codes/E0389.stderr b/tests/ui/error-codes/E0389.stderr index 5fc270b34484d..c4dcab886a112 100644 --- a/tests/ui/error-codes/E0389.stderr +++ b/tests/ui/error-codes/E0389.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `fancy_ref.num`, which is behind a `&` reference --> $DIR/E0389.rs:8:5 | LL | fancy_ref.num = 6; - | ^^^^^^^^^^^^^^^^^ `fancy_ref` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^^^^^^^^^^^ `fancy_ref` is a `&` reference, so it cannot be written to | help: consider changing this to be a mutable reference | diff --git a/tests/ui/issues/issue-51515.stderr b/tests/ui/issues/issue-51515.stderr index 4c3a1919fbe26..5bf33b191c0eb 100644 --- a/tests/ui/issues/issue-51515.stderr +++ b/tests/ui/issues/issue-51515.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `*foo`, which is behind a `&` reference --> $DIR/issue-51515.rs:4:5 | LL | *foo = 32; - | ^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^^^ `foo` is a `&` reference, so it cannot be written to | help: consider changing this to be a mutable reference | @@ -13,7 +13,7 @@ error[E0594]: cannot assign to `*bar`, which is behind a `&` reference --> $DIR/issue-51515.rs:8:5 | LL | *bar = 64; - | ^^^^^^^^^ `bar` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^^^ `bar` is a `&` reference, so it cannot be written to | help: consider specifying this binding's type | diff --git a/tests/ui/let-else/let-else-binding-explicit-mut.stderr b/tests/ui/let-else/let-else-binding-explicit-mut.stderr index b93a5ae698a42..f1ec2d663d352 100644 --- a/tests/ui/let-else/let-else-binding-explicit-mut.stderr +++ b/tests/ui/let-else/let-else-binding-explicit-mut.stderr @@ -2,19 +2,19 @@ error[E0594]: cannot assign to `*n`, which is behind a `&` reference --> $DIR/let-else-binding-explicit-mut.rs:10:5 | LL | *n += 1; - | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^ `n` is a `&` reference, so it cannot be written to error[E0594]: cannot assign to `*n`, which is behind a `&` reference --> $DIR/let-else-binding-explicit-mut.rs:14:5 | LL | *n += 1; - | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^ `n` is a `&` reference, so it cannot be written to error[E0594]: cannot assign to `*n`, which is behind a `&` reference --> $DIR/let-else-binding-explicit-mut.rs:18:5 | LL | *n += 1; - | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^ `n` is a `&` reference, so it cannot be written to error: aborting due to 3 previous errors diff --git a/tests/ui/let-else/let-else-binding-immutable.stderr b/tests/ui/let-else/let-else-binding-immutable.stderr index 2d8f9197fc879..eb6c2c5c61eed 100644 --- a/tests/ui/let-else/let-else-binding-immutable.stderr +++ b/tests/ui/let-else/let-else-binding-immutable.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `*x`, which is behind a `&` reference --> $DIR/let-else-binding-immutable.rs:9:5 | LL | *x += 1; - | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^ `x` is a `&` reference, so it cannot be written to error: aborting due to 1 previous error diff --git a/tests/ui/mut/mutable-class-fields-2.stderr b/tests/ui/mut/mutable-class-fields-2.stderr index c133e883d3283..57a04bdc21444 100644 --- a/tests/ui/mut/mutable-class-fields-2.stderr +++ b/tests/ui/mut/mutable-class-fields-2.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `self.how_hungry`, which is behind a `&` referenc --> $DIR/mutable-class-fields-2.rs:9:5 | LL | self.how_hungry -= 5; - | ^^^^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so it cannot be written to | help: consider changing this to be a mutable reference | diff --git a/tests/ui/nll/issue-47388.stderr b/tests/ui/nll/issue-47388.stderr index ee4950c8e134c..a95cc574c87f4 100644 --- a/tests/ui/nll/issue-47388.stderr +++ b/tests/ui/nll/issue-47388.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `fancy_ref.num`, which is behind a `&` reference --> $DIR/issue-47388.rs:8:5 | LL | fancy_ref.num = 6; - | ^^^^^^^^^^^^^^^^^ `fancy_ref` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^^^^^^^^^^^ `fancy_ref` is a `&` reference, so it cannot be written to | help: consider changing this to be a mutable reference | diff --git a/tests/ui/nll/issue-51244.stderr b/tests/ui/nll/issue-51244.stderr index e994fb453f6cf..e86202e1aec13 100644 --- a/tests/ui/nll/issue-51244.stderr +++ b/tests/ui/nll/issue-51244.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `*my_ref`, which is behind a `&` reference --> $DIR/issue-51244.rs:3:5 | LL | *my_ref = 0; - | ^^^^^^^^^^^ `my_ref` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^^^^^ `my_ref` is a `&` reference, so it cannot be written to | help: consider changing this to be a mutable reference | diff --git a/tests/ui/nll/issue-57989.stderr b/tests/ui/nll/issue-57989.stderr index d96974f93c76d..8b102f20c122f 100644 --- a/tests/ui/nll/issue-57989.stderr +++ b/tests/ui/nll/issue-57989.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `*x`, which is behind a `&` reference --> $DIR/issue-57989.rs:5:5 | LL | *x = 0; - | ^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^ `x` is a `&` reference, so it cannot be written to | help: consider changing this to be a mutable reference | diff --git a/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr b/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr index dd3b507a51c4e..5c4446cbc17be 100644 --- a/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr +++ b/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr @@ -119,7 +119,7 @@ error[E0594]: cannot assign to `*_x0`, which is behind a `&` reference --> $DIR/borrowck-move-ref-pattern.rs:26:5 | LL | *_x0 = U; - | ^^^^^^^^ `_x0` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^^ `_x0` is a `&` reference, so it cannot be written to | help: consider changing this to be a mutable reference | @@ -130,7 +130,7 @@ error[E0594]: cannot assign to `*_x2`, which is behind a `&` reference --> $DIR/borrowck-move-ref-pattern.rs:27:5 | LL | *_x2 = U; - | ^^^^^^^^ `_x2` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^^ `_x2` is a `&` reference, so it cannot be written to | help: consider changing this to be a mutable reference | diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/enum.stderr b/tests/ui/rfcs/rfc-2005-default-binding-mode/enum.stderr index 20d7391c72112..3ba69f73783ca 100644 --- a/tests/ui/rfcs/rfc-2005-default-binding-mode/enum.stderr +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/enum.stderr @@ -2,19 +2,19 @@ error[E0594]: cannot assign to `*x`, which is behind a `&` reference --> $DIR/enum.rs:9:5 | LL | *x += 1; - | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^ `x` is a `&` reference, so it cannot be written to error[E0594]: cannot assign to `*x`, which is behind a `&` reference --> $DIR/enum.rs:13:9 | LL | *x += 1; - | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^ `x` is a `&` reference, so it cannot be written to error[E0594]: cannot assign to `*x`, which is behind a `&` reference --> $DIR/enum.rs:19:9 | LL | *x += 1; - | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^ `x` is a `&` reference, so it cannot be written to error: aborting due to 3 previous errors diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/explicit-mut.stderr b/tests/ui/rfcs/rfc-2005-default-binding-mode/explicit-mut.stderr index 3f0ffbba0562c..2892884ebf365 100644 --- a/tests/ui/rfcs/rfc-2005-default-binding-mode/explicit-mut.stderr +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/explicit-mut.stderr @@ -2,19 +2,19 @@ error[E0594]: cannot assign to `*n`, which is behind a `&` reference --> $DIR/explicit-mut.rs:7:13 | LL | *n += 1; - | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^ `n` is a `&` reference, so it cannot be written to error[E0594]: cannot assign to `*n`, which is behind a `&` reference --> $DIR/explicit-mut.rs:15:13 | LL | *n += 1; - | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^ `n` is a `&` reference, so it cannot be written to error[E0594]: cannot assign to `*n`, which is behind a `&` reference --> $DIR/explicit-mut.rs:23:13 | LL | *n += 1; - | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^ `n` is a `&` reference, so it cannot be written to error: aborting due to 3 previous errors diff --git a/tests/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr b/tests/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr index 4aad8843759b3..0cf9dd3b488c5 100644 --- a/tests/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr +++ b/tests/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr @@ -13,7 +13,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:65:10 | LL | &mut x.y - | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^ `x` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | @@ -45,7 +45,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:92:5 | LL | x.y = 3; - | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^ `x` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | @@ -77,7 +77,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:121:5 | LL | x.y_mut() - | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^ `x` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | @@ -99,7 +99,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:133:6 | LL | *x.y_mut() = 3; - | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^ `x` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | diff --git a/tests/ui/span/borrowck-borrow-overloaded-deref-mut.stderr b/tests/ui/span/borrowck-borrow-overloaded-deref-mut.stderr index dbd52dc2d38df..101641c8b06ba 100644 --- a/tests/ui/span/borrowck-borrow-overloaded-deref-mut.stderr +++ b/tests/ui/span/borrowck-borrow-overloaded-deref-mut.stderr @@ -13,7 +13,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:41:11 | LL | &mut **x - | ^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^ `x` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | @@ -35,7 +35,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:53:6 | LL | **x = 3; - | ^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^ `x` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | diff --git a/tests/ui/span/borrowck-call-is-borrow-issue-12224.stderr b/tests/ui/span/borrowck-call-is-borrow-issue-12224.stderr index f7750884b4a65..6590ba8a79e01 100644 --- a/tests/ui/span/borrowck-call-is-borrow-issue-12224.stderr +++ b/tests/ui/span/borrowck-call-is-borrow-issue-12224.stderr @@ -14,7 +14,7 @@ error[E0596]: cannot borrow `*f` as mutable, as it is behind a `&` reference --> $DIR/borrowck-call-is-borrow-issue-12224.rs:25:5 | LL | (*f)(); - | ^^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^^ `f` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | @@ -25,7 +25,7 @@ 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 | f.f.call_mut(()) - | ^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^^ `f` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | diff --git a/tests/ui/span/borrowck-call-method-from-mut-aliasable.stderr b/tests/ui/span/borrowck-call-method-from-mut-aliasable.stderr index 39e7279fb77d0..195a052d6dcc9 100644 --- a/tests/ui/span/borrowck-call-method-from-mut-aliasable.stderr +++ b/tests/ui/span/borrowck-call-method-from-mut-aliasable.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-call-method-from-mut-aliasable.rs:17:5 | LL | x.h(); - | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^ `x` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | diff --git a/tests/ui/span/borrowck-fn-in-const-b.stderr b/tests/ui/span/borrowck-fn-in-const-b.stderr index d4a8ba2698da0..985196c0286a9 100644 --- a/tests/ui/span/borrowck-fn-in-const-b.stderr +++ b/tests/ui/span/borrowck-fn-in-const-b.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-fn-in-const-b.rs:7:9 | LL | x.push(format!("this is broken")); - | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^ `x` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | diff --git a/tests/ui/span/borrowck-object-mutability.stderr b/tests/ui/span/borrowck-object-mutability.stderr index e4b5c8ce71f14..6fd4acd34793d 100644 --- a/tests/ui/span/borrowck-object-mutability.stderr +++ b/tests/ui/span/borrowck-object-mutability.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-object-mutability.rs:8:5 | LL | x.borrowed_mut(); - | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^ `x` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | diff --git a/tests/ui/span/mut-arg-hint.stderr b/tests/ui/span/mut-arg-hint.stderr index df782280b8af3..45449db4d7825 100644 --- a/tests/ui/span/mut-arg-hint.stderr +++ b/tests/ui/span/mut-arg-hint.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference --> $DIR/mut-arg-hint.rs:3:9 | LL | a.push_str("bar"); - | ^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^ `a` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | @@ -13,7 +13,7 @@ error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference --> $DIR/mut-arg-hint.rs:8:5 | LL | a.push_str("foo"); - | ^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^ `a` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | @@ -24,7 +24,7 @@ error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference --> $DIR/mut-arg-hint.rs:15:9 | LL | a.push_str("foo"); - | ^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^ `a` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | diff --git a/tests/ui/suggestions/dont_suggest_raw_pointer_syntax-issue-127562.stderr b/tests/ui/suggestions/dont_suggest_raw_pointer_syntax-issue-127562.stderr index 4993d87c822f2..fdbdf6379c1d4 100644 --- a/tests/ui/suggestions/dont_suggest_raw_pointer_syntax-issue-127562.stderr +++ b/tests/ui/suggestions/dont_suggest_raw_pointer_syntax-issue-127562.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `*ptr`, which is behind a `*const` pointer --> $DIR/dont_suggest_raw_pointer_syntax-issue-127562.rs:5:9 | LL | *ptr = 3; - | ^^^^^^^^ `ptr` is a `*const` pointer, so the data it refers to cannot be written to + | ^^^^^^^^ `ptr` is a `*const` pointer, so it cannot be written to error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/issue-68049-1.stderr b/tests/ui/suggestions/issue-68049-1.stderr index 5f7fc6031d526..11a8e9cc5275b 100644 --- a/tests/ui/suggestions/issue-68049-1.stderr +++ b/tests/ui/suggestions/issue-68049-1.stderr @@ -4,7 +4,7 @@ error[E0594]: cannot assign to `self.0`, which is behind a `&` reference LL | unsafe fn alloc(&self, _layout: Layout) -> *mut u8 { | ----- this is an immutable reference LL | self.0 += 1; - | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^^^^^ `self` is a `&` reference, so it cannot be written to error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/issue-68049-2.stderr b/tests/ui/suggestions/issue-68049-2.stderr index 8c72578716844..97240af207750 100644 --- a/tests/ui/suggestions/issue-68049-2.stderr +++ b/tests/ui/suggestions/issue-68049-2.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `*input`, which is behind a `&` reference --> $DIR/issue-68049-2.rs:9:7 | LL | *input = self.0; - | ^^^^^^^^^^^^^^^ `input` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^^^^^^^^^ `input` is a `&` reference, so it cannot be written to | help: consider changing this to be a mutable reference in the `impl` method and the `trait` definition | @@ -13,7 +13,7 @@ error[E0594]: cannot assign to `self.0`, which is behind a `&` reference --> $DIR/issue-68049-2.rs:17:5 | LL | self.0 += *input; - | ^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^^^^^^^^^^ `self` is a `&` reference, so it cannot be written to | help: consider changing this to be a mutable reference in the `impl` method and the `trait` definition | diff --git a/tests/ui/suggestions/suggest-mut-method-for-loop-closure.stderr b/tests/ui/suggestions/suggest-mut-method-for-loop-closure.stderr index 8f886e6103169..5c0bbe24ec922 100644 --- a/tests/ui/suggestions/suggest-mut-method-for-loop-closure.stderr +++ b/tests/ui/suggestions/suggest-mut-method-for-loop-closure.stderr @@ -8,7 +8,7 @@ LL | for mut t in buzz.values() { | this iterator yields `&` references ... LL | t.v += 1; - | ^^^^^^^^ `t` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^^ `t` is a `&` reference, so it cannot be written to error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/suggest-mut-method-for-loop-hashmap.stderr b/tests/ui/suggestions/suggest-mut-method-for-loop-hashmap.stderr index 9228214c9d55f..8e44128063878 100644 --- a/tests/ui/suggestions/suggest-mut-method-for-loop-hashmap.stderr +++ b/tests/ui/suggestions/suggest-mut-method-for-loop-hashmap.stderr @@ -8,7 +8,7 @@ LL | for (_k, v) in map.iter() { | this iterator yields `&` references ... LL | v.v += 1; - | ^^^^^^^^ `v` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^^ `v` is a `&` reference, so it cannot be written to error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/suggest-mut-method-for-loop.stderr b/tests/ui/suggestions/suggest-mut-method-for-loop.stderr index 4a534b9b2b232..26764ebc4a45a 100644 --- a/tests/ui/suggestions/suggest-mut-method-for-loop.stderr +++ b/tests/ui/suggestions/suggest-mut-method-for-loop.stderr @@ -8,7 +8,7 @@ LL | for mut t in buzz.values() { | this iterator yields `&` references ... LL | t.v += 1; - | ^^^^^^^^ `t` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^^ `t` is a `&` reference, so it cannot be written to error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/suggest-ref-mut.stderr b/tests/ui/suggestions/suggest-ref-mut.stderr index d4700498c85dd..ae96f6408f086 100644 --- a/tests/ui/suggestions/suggest-ref-mut.stderr +++ b/tests/ui/suggestions/suggest-ref-mut.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to `self.0`, which is behind a `&` reference --> $DIR/suggest-ref-mut.rs:9:9 | LL | self.0 = 32; - | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^^^^^ `self` is a `&` reference, so it cannot be written to | help: consider changing this to be a mutable reference | @@ -13,7 +13,7 @@ error[E0594]: cannot assign to `*foo`, which is behind a `&` reference --> $DIR/suggest-ref-mut.rs:17:5 | LL | *foo = 32; - | ^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^^^ `foo` is a `&` reference, so it cannot be written to | help: consider changing this to be a mutable reference | @@ -24,7 +24,7 @@ error[E0594]: cannot assign to `*bar`, which is behind a `&` reference --> $DIR/suggest-ref-mut.rs:21:9 | LL | *bar = 32; - | ^^^^^^^^^ `bar` is a `&` reference, so the data it refers to cannot be written to + | ^^^^^^^^^ `bar` is a `&` reference, so it cannot be written to | help: consider changing this to be a mutable reference | @@ -35,7 +35,7 @@ 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 to + | ^^^^^^^^^ `quo` is a `&` reference, so it cannot be written to | help: consider changing this to be a mutable reference | diff --git a/tests/ui/trivial-bounds/trivial-bounds-inconsistent-copy-reborrow.stderr b/tests/ui/trivial-bounds/trivial-bounds-inconsistent-copy-reborrow.stderr index c054ddb893d5c..703ad36c4cdc2 100644 --- a/tests/ui/trivial-bounds/trivial-bounds-inconsistent-copy-reborrow.stderr +++ b/tests/ui/trivial-bounds/trivial-bounds-inconsistent-copy-reborrow.stderr @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `**t` as mutable, as it is behind a `&` reference --> $DIR/trivial-bounds-inconsistent-copy-reborrow.rs:6:5 | LL | *t - | ^^ `t` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^ `t` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference | @@ -13,7 +13,7 @@ error[E0596]: cannot borrow `**t` as mutable, as it is behind a `&` reference --> $DIR/trivial-bounds-inconsistent-copy-reborrow.rs:10:6 | LL | {*t} - | ^^ `t` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | ^^ `t` is a `&` reference, so it cannot be borrowed as mutable | help: consider changing this to be a mutable reference |