1
Fork 0

use structured suggestion for "missing mut" label

Fixes #54133.
This commit is contained in:
Andy Russell 2018-09-12 14:13:40 -04:00
parent 6810f5286b
commit d871b8ad4a
No known key found for this signature in database
GPG key ID: BE2221033EDBC374
77 changed files with 179 additions and 164 deletions

View file

@ -45,7 +45,7 @@ use rustc_data_structures::sync::Lrc;
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
use syntax::ast; use syntax::ast;
use syntax_pos::{MultiSpan, Span}; use syntax_pos::{MultiSpan, Span};
use errors::{DiagnosticBuilder, DiagnosticId}; use errors::{Applicability, DiagnosticBuilder, DiagnosticId};
use rustc::hir; use rustc::hir;
use rustc::hir::intravisit::{self, Visitor}; use rustc::hir::intravisit::{self, Visitor};
@ -1299,9 +1299,11 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
snippet snippet
); );
} else { } else {
db.span_label( db.span_suggestion_with_applicability(
let_span, let_span,
format!("consider changing this to `mut {}`", snippet), "make this binding mutable",
format!("mut {}", snippet),
Applicability::MachineApplicable,
); );
} }
} }

View file

@ -17,7 +17,7 @@ use rustc::mir::{ProjectionElem, Rvalue, Statement, StatementKind};
use rustc::ty; use rustc::ty;
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
use rustc_errors::DiagnosticBuilder; use rustc_errors::{Applicability, DiagnosticBuilder};
use syntax_pos::Span; use syntax_pos::Span;
use super::borrow_set::BorrowData; use super::borrow_set::BorrowData;
@ -690,9 +690,11 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
if let Some(decl) = local_decl { if let Some(decl) = local_decl {
if let Some(name) = decl.name { if let Some(name) = decl.name {
if decl.can_be_made_mutable() { if decl.can_be_made_mutable() {
err.span_label( err.span_suggestion_with_applicability(
decl.source_info.span, decl.source_info.span,
format!("consider changing this to `mut {}`", name), "make this binding mutable",
format!("mut {}", name),
Applicability::MachineApplicable,
); );
} }
} }

View file

@ -2,7 +2,7 @@ error[E0596]: cannot borrow immutable local variable `x` as mutable
--> $DIR/E0596.rs:16:18 --> $DIR/E0596.rs:16:18
| |
LL | let x = 1; LL | let x = 1;
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
LL | let y = &mut x; //[ast]~ ERROR [E0596] LL | let y = &mut x; //[ast]~ ERROR [E0596]
| ^ cannot borrow mutably | ^ cannot borrow mutably

View file

@ -2,7 +2,7 @@ error[E0384]: cannot assign twice to immutable variable `x`
--> $DIR/asm-out-assign-imm.rs:34:9 --> $DIR/asm-out-assign-imm.rs:34:9
| |
LL | let x: isize; LL | let x: isize;
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
LL | x = 1; LL | x = 1;
| ----- first assignment to `x` | ----- first assignment to `x`
... ...

View file

@ -1,9 +1,9 @@
error[E0384]: cannot assign twice to immutable variable `v` error[E0384]: cannot assign twice to immutable variable `v`
--> $DIR/assign-imm-local-twice.rs:20:5 --> $DIR/assign-imm-local-twice.rs:21:5
| |
LL | let v: isize; LL | let v: isize;
| - consider changing this to `mut v` | - help: make this binding mutable: `mut v`
LL | //[mir]~^ NOTE consider changing this to `mut v` ...
LL | v = 1; //[ast]~ NOTE first assignment LL | v = 1; //[ast]~ NOTE first assignment
| ----- first assignment to `v` | ----- first assignment to `v`
... ...

View file

@ -1,5 +1,5 @@
error[E0384]: cannot assign twice to immutable variable `v` error[E0384]: cannot assign twice to immutable variable `v`
--> $DIR/assign-imm-local-twice.rs:20:5 --> $DIR/assign-imm-local-twice.rs:21:5
| |
LL | v = 1; //[ast]~ NOTE first assignment LL | v = 1; //[ast]~ NOTE first assignment
| ----- first assignment to `v` | ----- first assignment to `v`

View file

@ -1,9 +1,9 @@
error[E0384]: cannot assign twice to immutable variable `v` error[E0384]: cannot assign twice to immutable variable `v`
--> $DIR/assign-imm-local-twice.rs:20:5 --> $DIR/assign-imm-local-twice.rs:21:5
| |
LL | let v: isize; LL | let v: isize;
| - consider changing this to `mut v` | - help: make this binding mutable: `mut v`
LL | //[mir]~^ NOTE consider changing this to `mut v` ...
LL | v = 1; //[ast]~ NOTE first assignment LL | v = 1; //[ast]~ NOTE first assignment
| ----- first assignment to `v` | ----- first assignment to `v`
... ...

View file

@ -13,7 +13,8 @@
fn test() { fn test() {
let v: isize; let v: isize;
//[mir]~^ NOTE consider changing this to `mut v` //[mir]~^ HELP make this binding mutable
//[mir]~| SUGGESTION mut v
v = 1; //[ast]~ NOTE first assignment v = 1; //[ast]~ NOTE first assignment
//[mir]~^ NOTE first assignment //[mir]~^ NOTE first assignment
println!("v={}", v); println!("v={}", v);

View file

@ -15,11 +15,11 @@ LL | | x; //~ value moved here
| borrow later used here | borrow later used here
error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable
--> $DIR/augmented-assignments.rs:30:5 --> $DIR/augmented-assignments.rs:31:5
| |
LL | let y = Int(2); LL | let y = Int(2);
| - help: consider changing this to be mutable: `mut y` | - help: consider changing this to be mutable: `mut y`
LL | //~^ consider changing this to `mut y` ...
LL | y //~ error: cannot borrow immutable local variable `y` as mutable LL | y //~ error: cannot borrow immutable local variable `y` as mutable
| ^ cannot borrow as mutable | ^ cannot borrow as mutable

View file

@ -26,7 +26,8 @@ fn main() {
x; //~ value moved here x; //~ value moved here
let y = Int(2); let y = Int(2);
//~^ consider changing this to `mut y` //~^ HELP make this binding mutable
//~| SUGGESTION mut y
y //~ error: cannot borrow immutable local variable `y` as mutable y //~ error: cannot borrow immutable local variable `y` as mutable
//~| cannot borrow //~| cannot borrow
+= +=

View file

@ -1,9 +1,9 @@
error[E0596]: cannot borrow immutable local variable `y` as mutable error[E0596]: cannot borrow immutable local variable `y` as mutable
--> $DIR/augmented-assignments.rs:30:5 --> $DIR/augmented-assignments.rs:31:5
| |
LL | let y = Int(2); LL | let y = Int(2);
| - consider changing this to `mut y` | - help: make this binding mutable: `mut y`
LL | //~^ consider changing this to `mut y` ...
LL | y //~ error: cannot borrow immutable local variable `y` as mutable LL | y //~ error: cannot borrow immutable local variable `y` as mutable
| ^ cannot borrow mutably | ^ cannot borrow mutably

View file

@ -2,7 +2,7 @@ error[E0596]: cannot borrow immutable local variable `x` as mutable
--> $DIR/borrowck-access-permissions.rs:22:24 --> $DIR/borrowck-access-permissions.rs:22:24
| |
LL | let x = 1; LL | let x = 1;
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
... ...
LL | let _y1 = &mut x; //[ast]~ ERROR [E0596] LL | let _y1 = &mut x; //[ast]~ ERROR [E0596]
| ^ cannot borrow mutably | ^ cannot borrow mutably
@ -17,7 +17,7 @@ error[E0596]: cannot borrow immutable `Box` content `*box_x` as mutable
--> $DIR/borrowck-access-permissions.rs:37:24 --> $DIR/borrowck-access-permissions.rs:37:24
| |
LL | let box_x = Box::new(1); LL | let box_x = Box::new(1);
| ----- consider changing this to `mut box_x` | ----- help: make this binding mutable: `mut box_x`
... ...
LL | let _y1 = &mut *box_x; //[ast]~ ERROR [E0596] LL | let _y1 = &mut *box_x; //[ast]~ ERROR [E0596]
| ^^^^^^ cannot borrow as mutable | ^^^^^^ cannot borrow as mutable

View file

@ -2,7 +2,7 @@ error[E0596]: cannot borrow immutable argument `arg` as mutable
--> $DIR/borrowck-argument.rs:20:5 --> $DIR/borrowck-argument.rs:20:5
| |
LL | fn func(arg: S) { LL | fn func(arg: S) {
| --- consider changing this to `mut arg` | --- help: make this binding mutable: `mut arg`
LL | arg.mutate(); //~ ERROR: cannot borrow immutable argument LL | arg.mutate(); //~ ERROR: cannot borrow immutable argument
| ^^^ cannot borrow mutably | ^^^ cannot borrow mutably
@ -10,7 +10,7 @@ error[E0596]: cannot borrow immutable argument `arg` as mutable
--> $DIR/borrowck-argument.rs:25:9 --> $DIR/borrowck-argument.rs:25:9
| |
LL | fn method(&self, arg: S) { LL | fn method(&self, arg: S) {
| --- consider changing this to `mut arg` | --- help: make this binding mutable: `mut arg`
LL | arg.mutate(); //~ ERROR: cannot borrow immutable argument LL | arg.mutate(); //~ ERROR: cannot borrow immutable argument
| ^^^ cannot borrow mutably | ^^^ cannot borrow mutably
@ -18,7 +18,7 @@ error[E0596]: cannot borrow immutable argument `arg` as mutable
--> $DIR/borrowck-argument.rs:31:9 --> $DIR/borrowck-argument.rs:31:9
| |
LL | fn default(&self, arg: S) { LL | fn default(&self, arg: S) {
| --- consider changing this to `mut arg` | --- help: make this binding mutable: `mut arg`
LL | arg.mutate(); //~ ERROR: cannot borrow immutable argument LL | arg.mutate(); //~ ERROR: cannot borrow immutable argument
| ^^^ cannot borrow mutably | ^^^ cannot borrow mutably
@ -28,7 +28,7 @@ error[E0596]: cannot borrow immutable argument `arg` as mutable
LL | (|arg: S| { arg.mutate() })(s); //~ ERROR: cannot borrow immutable argument LL | (|arg: S| { arg.mutate() })(s); //~ ERROR: cannot borrow immutable argument
| --- ^^^ cannot borrow mutably | --- ^^^ cannot borrow mutably
| | | |
| consider changing this to `mut arg` | help: make this binding mutable: `mut arg`
error: aborting due to 4 previous errors error: aborting due to 4 previous errors

View file

@ -28,7 +28,7 @@ LL | let x = 3;
| - | -
| | | |
| first assignment to `x` | first assignment to `x`
| consider changing this to `mut x` | help: make this binding mutable: `mut x`
LL | unsafe { LL | unsafe {
LL | asm!("nop" : "=r"(x)); //[ast]~ ERROR cannot assign twice LL | asm!("nop" : "=r"(x)); //[ast]~ ERROR cannot assign twice
| ^^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable | ^^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable
@ -40,7 +40,7 @@ LL | let x = 3;
| - | -
| | | |
| first assignment to `x` | first assignment to `x`
| consider changing this to `mut x` | help: make this binding mutable: `mut x`
LL | unsafe { LL | unsafe {
LL | asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign twice LL | asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign twice
| ^^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable | ^^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable

View file

@ -28,7 +28,7 @@ LL | let x = 3;
| - | -
| | | |
| first assignment to `x` | first assignment to `x`
| consider changing this to `mut x` | help: make this binding mutable: `mut x`
LL | unsafe { LL | unsafe {
LL | asm!("nop" : "=r"(x)); //[ast]~ ERROR cannot assign twice LL | asm!("nop" : "=r"(x)); //[ast]~ ERROR cannot assign twice
| ^^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable | ^^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable
@ -40,7 +40,7 @@ LL | let x = 3;
| - | -
| | | |
| first assignment to `x` | first assignment to `x`
| consider changing this to `mut x` | help: make this binding mutable: `mut x`
LL | unsafe { LL | unsafe {
LL | asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign twice LL | asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign twice
| ^^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable | ^^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable

View file

@ -2,7 +2,7 @@ error[E0596]: cannot borrow immutable local variable `x` as mutable
--> $DIR/borrowck-auto-mut-ref-to-immut-var.rs:25:5 --> $DIR/borrowck-auto-mut-ref-to-immut-var.rs:25:5
| |
LL | let x = Foo { x: 3 }; LL | let x = Foo { x: 3 };
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
LL | x.printme(); //~ ERROR cannot borrow LL | x.printme(); //~ ERROR cannot borrow
| ^ cannot borrow mutably | ^ cannot borrow mutably

View file

@ -147,7 +147,7 @@ error[E0596]: cannot borrow field `foo.bar1` of immutable binding as mutable
--> $DIR/borrowck-borrow-from-owned-ptr.rs:132:21 --> $DIR/borrowck-borrow-from-owned-ptr.rs:132:21
| |
LL | let foo = make_foo(); LL | let foo = make_foo();
| --- consider changing this to `mut foo` | --- help: make this binding mutable: `mut foo`
LL | let bar1 = &mut foo.bar1; //~ ERROR cannot borrow LL | let bar1 = &mut foo.bar1; //~ ERROR cannot borrow
| ^^^^^^^^ cannot mutably borrow field of immutable binding | ^^^^^^^^ cannot mutably borrow field of immutable binding

View file

@ -114,7 +114,7 @@ error[E0596]: cannot borrow field `foo.bar1` of immutable binding as mutable
--> $DIR/borrowck-borrow-from-stack-variable.rs:130:21 --> $DIR/borrowck-borrow-from-stack-variable.rs:130:21
| |
LL | let foo = make_foo(); LL | let foo = make_foo();
| --- consider changing this to `mut foo` | --- help: make this binding mutable: `mut foo`
LL | let bar1 = &mut foo.bar1; //~ ERROR cannot borrow LL | let bar1 = &mut foo.bar1; //~ ERROR cannot borrow
| ^^^^^^^^ cannot mutably borrow field of immutable binding | ^^^^^^^^ cannot mutably borrow field of immutable binding

View file

@ -2,7 +2,7 @@ error[E0596]: cannot borrow immutable `Box` content `*a` as mutable
--> $DIR/borrowck-borrow-immut-deref-of-box-as-mut.rs:22:5 --> $DIR/borrowck-borrow-immut-deref-of-box-as-mut.rs:22:5
| |
LL | let a: Box<_> = box A; LL | let a: Box<_> = box A;
| - consider changing this to `mut a` | - help: make this binding mutable: `mut a`
LL | a.foo(); LL | a.foo();
| ^ cannot borrow as mutable | ^ cannot borrow as mutable

View file

@ -5,7 +5,7 @@ LL | x => {
| - | -
| | | |
| first assignment to `x` | first assignment to `x`
| consider changing this to `mut x` | help: make this binding mutable: `mut x`
LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
| ^^^^^^ cannot assign twice to immutable variable | ^^^^^^ cannot assign twice to immutable variable
@ -16,7 +16,7 @@ LL | E::Foo(x) => {
| - | -
| | | |
| first assignment to `x` | first assignment to `x`
| consider changing this to `mut x` | help: make this binding mutable: `mut x`
LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
| ^^^^^^ cannot assign twice to immutable variable | ^^^^^^ cannot assign twice to immutable variable
@ -27,7 +27,7 @@ LL | S { bar: x } => {
| - | -
| | | |
| first assignment to `x` | first assignment to `x`
| consider changing this to `mut x` | help: make this binding mutable: `mut x`
LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
| ^^^^^^ cannot assign twice to immutable variable | ^^^^^^ cannot assign twice to immutable variable
@ -38,7 +38,7 @@ LL | (x,) => {
| - | -
| | | |
| first assignment to `x` | first assignment to `x`
| consider changing this to `mut x` | help: make this binding mutable: `mut x`
LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
| ^^^^^^ cannot assign twice to immutable variable | ^^^^^^ cannot assign twice to immutable variable
@ -49,7 +49,7 @@ LL | [x,_,_] => {
| - | -
| | | |
| first assignment to `x` | first assignment to `x`
| consider changing this to `mut x` | help: make this binding mutable: `mut x`
LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
| ^^^^^^ cannot assign twice to immutable variable | ^^^^^^ cannot assign twice to immutable variable

View file

@ -5,7 +5,7 @@ LL | x => {
| - | -
| | | |
| first assignment to `x` | first assignment to `x`
| consider changing this to `mut x` | help: make this binding mutable: `mut x`
LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
| ^^^^^^ cannot assign twice to immutable variable | ^^^^^^ cannot assign twice to immutable variable
@ -16,7 +16,7 @@ LL | E::Foo(x) => {
| - | -
| | | |
| first assignment to `x` | first assignment to `x`
| consider changing this to `mut x` | help: make this binding mutable: `mut x`
LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
| ^^^^^^ cannot assign twice to immutable variable | ^^^^^^ cannot assign twice to immutable variable
@ -27,7 +27,7 @@ LL | S { bar: x } => {
| - | -
| | | |
| first assignment to `x` | first assignment to `x`
| consider changing this to `mut x` | help: make this binding mutable: `mut x`
LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
| ^^^^^^ cannot assign twice to immutable variable | ^^^^^^ cannot assign twice to immutable variable
@ -38,7 +38,7 @@ LL | (x,) => {
| - | -
| | | |
| first assignment to `x` | first assignment to `x`
| consider changing this to `mut x` | help: make this binding mutable: `mut x`
LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
| ^^^^^^ cannot assign twice to immutable variable | ^^^^^^ cannot assign twice to immutable variable
@ -49,7 +49,7 @@ LL | [x,_,_] => {
| - | -
| | | |
| first assignment to `x` | first assignment to `x`
| consider changing this to `mut x` | help: make this binding mutable: `mut x`
LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
| ^^^^^^ cannot assign twice to immutable variable | ^^^^^^ cannot assign twice to immutable variable

View file

@ -2,7 +2,7 @@ error[E0596]: cannot borrow immutable local variable `x` as mutable
--> $DIR/borrowck-mut-addr-of-imm-var.rs:13:30 --> $DIR/borrowck-mut-addr-of-imm-var.rs:13:30
| |
LL | let x: isize = 3; LL | let x: isize = 3;
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
LL | let y: &mut isize = &mut x; //~ ERROR cannot borrow LL | let y: &mut isize = &mut x; //~ ERROR cannot borrow
| ^ cannot borrow mutably | ^ cannot borrow mutably

View file

@ -2,7 +2,7 @@ error[E0596]: cannot borrow immutable local variable `v` as mutable
--> $DIR/borrowck-mut-slice-of-imm-vec.rs:17:16 --> $DIR/borrowck-mut-slice-of-imm-vec.rs:17:16
| |
LL | let v = vec![1, 2, 3]; LL | let v = vec![1, 2, 3];
| - consider changing this to `mut v` | - help: make this binding mutable: `mut v`
LL | write(&mut v); //~ ERROR cannot borrow LL | write(&mut v); //~ ERROR cannot borrow
| ^ cannot borrow mutably | ^ cannot borrow mutably

View file

@ -12,7 +12,7 @@ error[E0596]: cannot borrow immutable local variable `s` as mutable
--> $DIR/borrowck-overloaded-call.rs:77:5 --> $DIR/borrowck-overloaded-call.rs:77:5
| |
LL | let s = SFnMut { LL | let s = SFnMut {
| - consider changing this to `mut s` | - help: make this binding mutable: `mut s`
... ...
LL | s(3); //~ ERROR cannot borrow immutable local variable `s` as mutable LL | s(3); //~ ERROR cannot borrow immutable local variable `s` as mutable
| ^ cannot borrow mutably | ^ cannot borrow mutably

View file

@ -2,7 +2,7 @@ error[E0596]: cannot borrow field `(x as std::prelude::v1::Some).0` of immutable
--> $DIR/borrowck-ref-mut-of-imm.rs:14:12 --> $DIR/borrowck-ref-mut-of-imm.rs:14:12
| |
LL | fn destructure(x: Option<isize>) -> isize { LL | fn destructure(x: Option<isize>) -> isize {
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
... ...
LL | Some(ref mut v) => *v //~ ERROR cannot borrow LL | Some(ref mut v) => *v //~ ERROR cannot borrow
| ^^^^^^^^^ cannot mutably borrow field of immutable binding | ^^^^^^^^^ cannot mutably borrow field of immutable binding

View file

@ -12,7 +12,7 @@ error[E0596]: cannot borrow immutable argument `f` as mutable
--> $DIR/borrowck-unboxed-closures.rs:17:5 --> $DIR/borrowck-unboxed-closures.rs:17:5
| |
LL | fn b<F:FnMut(isize, isize) -> isize>(f: F) { LL | fn b<F:FnMut(isize, isize) -> isize>(f: F) {
| - consider changing this to `mut f` | - help: make this binding mutable: `mut f`
LL | f(1, 2); //~ ERROR cannot borrow immutable argument LL | f(1, 2); //~ ERROR cannot borrow immutable argument
| ^ cannot borrow mutably | ^ cannot borrow mutably

View file

@ -10,7 +10,7 @@ error[E0384]: cannot assign to immutable argument `_x` (Mir)
--> $DIR/immutable-arg.rs:14:5 --> $DIR/immutable-arg.rs:14:5
| |
LL | fn foo(_x: u32) { LL | fn foo(_x: u32) {
| -- consider changing this to `mut _x` | -- help: make this binding mutable: `mut _x`
LL | _x = 4; LL | _x = 4;
| ^^^^^^ cannot assign to immutable argument | ^^^^^^ cannot assign to immutable argument

View file

@ -230,7 +230,7 @@ error[E0596]: cannot borrow immutable argument `x` as mutable
--> $DIR/mutability-errors.rs:64:10 --> $DIR/mutability-errors.rs:64:10
| |
LL | fn imm_local(x: (i32,)) { LL | fn imm_local(x: (i32,)) {
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
LL | &mut x; //~ ERROR LL | &mut x; //~ ERROR
| ^ cannot borrow mutably | ^ cannot borrow mutably
@ -238,7 +238,7 @@ error[E0596]: cannot borrow field `x.0` of immutable binding as mutable
--> $DIR/mutability-errors.rs:65:10 --> $DIR/mutability-errors.rs:65:10
| |
LL | fn imm_local(x: (i32,)) { LL | fn imm_local(x: (i32,)) {
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
LL | &mut x; //~ ERROR LL | &mut x; //~ ERROR
LL | &mut x.0; //~ ERROR LL | &mut x.0; //~ ERROR
| ^^^ cannot mutably borrow field of immutable binding | ^^^ cannot mutably borrow field of immutable binding
@ -247,7 +247,7 @@ error[E0595]: closure cannot assign to immutable argument `x`
--> $DIR/mutability-errors.rs:69:5 --> $DIR/mutability-errors.rs:69:5
| |
LL | fn imm_capture(x: (i32,)) { LL | fn imm_capture(x: (i32,)) {
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
LL | || { //~ ERROR LL | || { //~ ERROR
| ^^ cannot borrow mutably | ^^ cannot borrow mutably

View file

@ -2,7 +2,7 @@ error[E0594]: cannot assign to field `x.0` of immutable binding
--> $DIR/reassignment_immutable_fields.rs:17:5 --> $DIR/reassignment_immutable_fields.rs:17:5
| |
LL | let x: (u32, u32); LL | let x: (u32, u32);
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
LL | x.0 = 1; //~ ERROR LL | x.0 = 1; //~ ERROR
| ^^^^^^^ cannot mutably borrow field of immutable binding | ^^^^^^^ cannot mutably borrow field of immutable binding
@ -10,7 +10,7 @@ error[E0594]: cannot assign to field `x.1` of immutable binding
--> $DIR/reassignment_immutable_fields.rs:18:5 --> $DIR/reassignment_immutable_fields.rs:18:5
| |
LL | let x: (u32, u32); LL | let x: (u32, u32);
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
LL | x.0 = 1; //~ ERROR LL | x.0 = 1; //~ ERROR
LL | x.1 = 22; //~ ERROR LL | x.1 = 22; //~ ERROR
| ^^^^^^^^ cannot mutably borrow field of immutable binding | ^^^^^^^^ cannot mutably borrow field of immutable binding
@ -31,7 +31,7 @@ error[E0594]: cannot assign to field `x.0` of immutable binding
--> $DIR/reassignment_immutable_fields.rs:25:5 --> $DIR/reassignment_immutable_fields.rs:25:5
| |
LL | let x: (u32, u32); LL | let x: (u32, u32);
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
LL | x.0 = 1; //~ ERROR LL | x.0 = 1; //~ ERROR
| ^^^^^^^ cannot mutably borrow field of immutable binding | ^^^^^^^ cannot mutably borrow field of immutable binding
@ -39,7 +39,7 @@ error[E0594]: cannot assign to field `x.1` of immutable binding
--> $DIR/reassignment_immutable_fields.rs:26:5 --> $DIR/reassignment_immutable_fields.rs:26:5
| |
LL | let x: (u32, u32); LL | let x: (u32, u32);
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
LL | x.0 = 1; //~ ERROR LL | x.0 = 1; //~ ERROR
LL | x.1 = 22; //~ ERROR LL | x.1 = 22; //~ ERROR
| ^^^^^^^^ cannot mutably borrow field of immutable binding | ^^^^^^^^ cannot mutably borrow field of immutable binding

View file

@ -2,7 +2,7 @@ error[E0594]: cannot assign to field `x.a` of immutable binding
--> $DIR/reassignment_immutable_fields_overlapping.rs:22:5 --> $DIR/reassignment_immutable_fields_overlapping.rs:22:5
| |
LL | let x: Foo; LL | let x: Foo;
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
LL | x.a = 1; //~ ERROR LL | x.a = 1; //~ ERROR
| ^^^^^^^ cannot mutably borrow field of immutable binding | ^^^^^^^ cannot mutably borrow field of immutable binding
@ -10,7 +10,7 @@ error[E0594]: cannot assign to field `x.b` of immutable binding
--> $DIR/reassignment_immutable_fields_overlapping.rs:23:5 --> $DIR/reassignment_immutable_fields_overlapping.rs:23:5
| |
LL | let x: Foo; LL | let x: Foo;
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
LL | x.a = 1; //~ ERROR LL | x.a = 1; //~ ERROR
LL | x.b = 22; //~ ERROR LL | x.b = 22; //~ ERROR
| ^^^^^^^^ cannot mutably borrow field of immutable binding | ^^^^^^^^ cannot mutably borrow field of immutable binding

View file

@ -2,7 +2,7 @@ error[E0594]: cannot assign to field `x.0` of immutable binding
--> $DIR/reassignment_immutable_fields_twice.rs:17:5 --> $DIR/reassignment_immutable_fields_twice.rs:17:5
| |
LL | let x: (u32, u32); LL | let x: (u32, u32);
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
LL | x = (22, 44); LL | x = (22, 44);
LL | x.0 = 1; //~ ERROR LL | x.0 = 1; //~ ERROR
| ^^^^^^^ cannot mutably borrow field of immutable binding | ^^^^^^^ cannot mutably borrow field of immutable binding
@ -11,7 +11,7 @@ error[E0594]: cannot assign to field `x.0` of immutable binding
--> $DIR/reassignment_immutable_fields_twice.rs:22:5 --> $DIR/reassignment_immutable_fields_twice.rs:22:5
| |
LL | let x: (u32, u32); LL | let x: (u32, u32);
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
LL | x.0 = 1; //~ ERROR LL | x.0 = 1; //~ ERROR
| ^^^^^^^ cannot mutably borrow field of immutable binding | ^^^^^^^ cannot mutably borrow field of immutable binding
@ -19,7 +19,7 @@ error[E0594]: cannot assign to field `x.0` of immutable binding
--> $DIR/reassignment_immutable_fields_twice.rs:23:5 --> $DIR/reassignment_immutable_fields_twice.rs:23:5
| |
LL | let x: (u32, u32); LL | let x: (u32, u32);
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
LL | x.0 = 1; //~ ERROR LL | x.0 = 1; //~ ERROR
LL | x.0 = 22; //~ ERROR LL | x.0 = 22; //~ ERROR
| ^^^^^^^^ cannot mutably borrow field of immutable binding | ^^^^^^^^ cannot mutably borrow field of immutable binding
@ -28,7 +28,7 @@ error[E0594]: cannot assign to field `x.1` of immutable binding
--> $DIR/reassignment_immutable_fields_twice.rs:24:5 --> $DIR/reassignment_immutable_fields_twice.rs:24:5
| |
LL | let x: (u32, u32); LL | let x: (u32, u32);
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
... ...
LL | x.1 = 44; //~ ERROR LL | x.1 = 44; //~ ERROR
| ^^^^^^^^ cannot mutably borrow field of immutable binding | ^^^^^^^^ cannot mutably borrow field of immutable binding

View file

@ -2,7 +2,7 @@ error[E0596]: cannot borrow immutable local variable `x` as mutable
--> $DIR/huge_multispan_highlight.rs:100:18 --> $DIR/huge_multispan_highlight.rs:100:18
| |
LL | let x = "foo"; LL | let x = "foo";
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
... ...
LL | let y = &mut x; //~ ERROR cannot borrow LL | let y = &mut x; //~ ERROR cannot borrow
| ^ cannot borrow mutably | ^ cannot borrow mutably

View file

@ -5,7 +5,7 @@ LL | let x = 42;
| - | -
| | | |
| first assignment to `x` | first assignment to `x`
| consider changing this to `mut x` | help: make this binding mutable: `mut x`
LL | x = 43; LL | x = 43;
| ^^^^^^ cannot assign twice to immutable variable | ^^^^^^ cannot assign twice to immutable variable

View file

@ -2,7 +2,7 @@ error[E0596]: cannot borrow field `f.v` of immutable binding as mutable
--> $DIR/issue-35937.rs:17:5 --> $DIR/issue-35937.rs:17:5
| |
LL | let f = Foo { v: Vec::new() }; LL | let f = Foo { v: Vec::new() };
| - consider changing this to `mut f` | - help: make this binding mutable: `mut f`
LL | f.v.push("cat".to_string()); //~ ERROR cannot borrow LL | f.v.push("cat".to_string()); //~ ERROR cannot borrow
| ^^^ cannot mutably borrow field of immutable binding | ^^^ cannot mutably borrow field of immutable binding
@ -10,7 +10,7 @@ error[E0594]: cannot assign to field `s.x` of immutable binding
--> $DIR/issue-35937.rs:26:5 --> $DIR/issue-35937.rs:26:5
| |
LL | let s = S { x: 42 }; LL | let s = S { x: 42 };
| - consider changing this to `mut s` | - help: make this binding mutable: `mut s`
LL | s.x += 1; //~ ERROR cannot assign LL | s.x += 1; //~ ERROR cannot assign
| ^^^^^^^^ cannot mutably borrow field of immutable binding | ^^^^^^^^ cannot mutably borrow field of immutable binding
@ -18,7 +18,7 @@ error[E0594]: cannot assign to field `s.x` of immutable binding
--> $DIR/issue-35937.rs:30:5 --> $DIR/issue-35937.rs:30:5
| |
LL | fn bar(s: S) { LL | fn bar(s: S) {
| - consider changing this to `mut s` | - help: make this binding mutable: `mut s`
LL | s.x += 1; //~ ERROR cannot assign LL | s.x += 1; //~ ERROR cannot assign
| ^^^^^^^^ cannot mutably borrow field of immutable binding | ^^^^^^^^ cannot mutably borrow field of immutable binding

View file

@ -2,7 +2,7 @@ error[E0596]: cannot borrow field `z.x` of immutable binding as mutable
--> $DIR/issue-39544.rs:21:18 --> $DIR/issue-39544.rs:21:18
| |
LL | let z = Z { x: X::Y }; LL | let z = Z { x: X::Y };
| - consider changing this to `mut z` | - help: make this binding mutable: `mut z`
LL | let _ = &mut z.x; //~ ERROR cannot borrow LL | let _ = &mut z.x; //~ ERROR cannot borrow
| ^^^ cannot mutably borrow field of immutable binding | ^^^ cannot mutably borrow field of immutable binding
@ -77,7 +77,7 @@ error[E0596]: cannot borrow field `z.x` of immutable binding as mutable
--> $DIR/issue-39544.rs:51:18 --> $DIR/issue-39544.rs:51:18
| |
LL | pub fn with_arg(z: Z, w: &Z) { LL | pub fn with_arg(z: Z, w: &Z) {
| - consider changing this to `mut z` | - help: make this binding mutable: `mut z`
LL | let _ = &mut z.x; //~ ERROR cannot borrow LL | let _ = &mut z.x; //~ ERROR cannot borrow
| ^^^ cannot mutably borrow field of immutable binding | ^^^ cannot mutably borrow field of immutable binding

View file

@ -2,7 +2,7 @@ error[E0594]: cannot assign to immutable `Box` content `*y`
--> $DIR/immut-function-arguments.rs:15:5 --> $DIR/immut-function-arguments.rs:15:5
| |
LL | fn f(y: Box<isize>) { LL | fn f(y: Box<isize>) {
| - consider changing this to `mut y` | - help: make this binding mutable: `mut y`
LL | *y = 5; //[ast]~ ERROR cannot assign LL | *y = 5; //[ast]~ ERROR cannot assign
| ^^^^^^ cannot borrow as mutable | ^^^^^^ cannot borrow as mutable
@ -12,7 +12,7 @@ error[E0594]: cannot assign to immutable `Box` content `*q`
LL | let _frob = |q: Box<isize>| { *q = 2; }; //[ast]~ ERROR cannot assign LL | let _frob = |q: Box<isize>| { *q = 2; }; //[ast]~ ERROR cannot assign
| - ^^^^^^ cannot borrow as mutable | - ^^^^^^ cannot borrow as mutable
| | | |
| consider changing this to `mut q` | help: make this binding mutable: `mut q`
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -2,7 +2,7 @@ error[E0596]: cannot borrow immutable `Box` content `*x` as mutable
--> $DIR/issue-36400.rs:15:12 --> $DIR/issue-36400.rs:15:12
| |
LL | let x = Box::new(3); LL | let x = Box::new(3);
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
LL | f(&mut *x); //~ ERROR cannot borrow immutable LL | f(&mut *x); //~ ERROR cannot borrow immutable
| ^^ cannot borrow as mutable | ^^ cannot borrow as mutable

View file

@ -1,9 +1,9 @@
error[E0384]: cannot assign twice to immutable variable `b` error[E0384]: cannot assign twice to immutable variable `b`
--> $DIR/issue-45199.rs:19:5 --> $DIR/issue-45199.rs:20:5
| |
LL | let b: Box<isize>; LL | let b: Box<isize>;
| - consider changing this to `mut b` | - help: make this binding mutable: `mut b`
LL | //[mir]~^ NOTE consider changing this to `mut b` ...
LL | b = Box::new(1); //[ast]~ NOTE first assignment LL | b = Box::new(1); //[ast]~ NOTE first assignment
| - first assignment to `b` | - first assignment to `b`
LL | //[mir]~^ NOTE first assignment LL | //[mir]~^ NOTE first assignment
@ -11,23 +11,23 @@ LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable var
| ^ cannot assign twice to immutable variable | ^ cannot assign twice to immutable variable
error[E0384]: cannot assign twice to immutable variable `b` error[E0384]: cannot assign twice to immutable variable `b`
--> $DIR/issue-45199.rs:29:5 --> $DIR/issue-45199.rs:31:5
| |
LL | let b = Box::new(1); //[ast]~ NOTE first assignment LL | let b = Box::new(1); //[ast]~ NOTE first assignment
| - | -
| | | |
| first assignment to `b` | first assignment to `b`
| consider changing this to `mut b` | help: make this binding mutable: `mut b`
... ...
LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable
| ^ cannot assign twice to immutable variable | ^ cannot assign twice to immutable variable
error[E0384]: cannot assign to immutable argument `b` error[E0384]: cannot assign to immutable argument `b`
--> $DIR/issue-45199.rs:37:5 --> $DIR/issue-45199.rs:40:5
| |
LL | fn test_args(b: Box<i32>) { //[ast]~ NOTE first assignment LL | fn test_args(b: Box<i32>) { //[ast]~ NOTE first assignment
| - consider changing this to `mut b` | - help: make this binding mutable: `mut b`
LL | //[mir]~^ NOTE consider changing this to `mut b` ...
LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable
| ^ cannot assign to immutable argument | ^ cannot assign to immutable argument

View file

@ -1,5 +1,5 @@
error[E0384]: cannot assign twice to immutable variable `b` error[E0384]: cannot assign twice to immutable variable `b`
--> $DIR/issue-45199.rs:19:5 --> $DIR/issue-45199.rs:20:5
| |
LL | b = Box::new(1); //[ast]~ NOTE first assignment LL | b = Box::new(1); //[ast]~ NOTE first assignment
| --------------- first assignment to `b` | --------------- first assignment to `b`
@ -8,7 +8,7 @@ LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable var
| ^^^^^^^^^^^^^^^ cannot assign twice to immutable variable | ^^^^^^^^^^^^^^^ cannot assign twice to immutable variable
error[E0384]: cannot assign twice to immutable variable `b` error[E0384]: cannot assign twice to immutable variable `b`
--> $DIR/issue-45199.rs:29:5 --> $DIR/issue-45199.rs:31:5
| |
LL | let b = Box::new(1); //[ast]~ NOTE first assignment LL | let b = Box::new(1); //[ast]~ NOTE first assignment
| - first assignment to `b` | - first assignment to `b`
@ -17,11 +17,11 @@ LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable
| ^^^^^^^^^^^^^^^ cannot assign twice to immutable variable | ^^^^^^^^^^^^^^^ cannot assign twice to immutable variable
error[E0384]: cannot assign twice to immutable variable `b` error[E0384]: cannot assign twice to immutable variable `b`
--> $DIR/issue-45199.rs:37:5 --> $DIR/issue-45199.rs:40:5
| |
LL | fn test_args(b: Box<i32>) { //[ast]~ NOTE first assignment LL | fn test_args(b: Box<i32>) { //[ast]~ NOTE first assignment
| - first assignment to `b` | - first assignment to `b`
LL | //[mir]~^ NOTE consider changing this to `mut b` ...
LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable
| ^^^^^^^^^^^^^^^ cannot assign twice to immutable variable | ^^^^^^^^^^^^^^^ cannot assign twice to immutable variable

View file

@ -1,9 +1,9 @@
error[E0384]: cannot assign twice to immutable variable `b` error[E0384]: cannot assign twice to immutable variable `b`
--> $DIR/issue-45199.rs:19:5 --> $DIR/issue-45199.rs:20:5
| |
LL | let b: Box<isize>; LL | let b: Box<isize>;
| - consider changing this to `mut b` | - help: make this binding mutable: `mut b`
LL | //[mir]~^ NOTE consider changing this to `mut b` ...
LL | b = Box::new(1); //[ast]~ NOTE first assignment LL | b = Box::new(1); //[ast]~ NOTE first assignment
| - first assignment to `b` | - first assignment to `b`
LL | //[mir]~^ NOTE first assignment LL | //[mir]~^ NOTE first assignment
@ -11,23 +11,23 @@ LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable var
| ^ cannot assign twice to immutable variable | ^ cannot assign twice to immutable variable
error[E0384]: cannot assign twice to immutable variable `b` error[E0384]: cannot assign twice to immutable variable `b`
--> $DIR/issue-45199.rs:29:5 --> $DIR/issue-45199.rs:31:5
| |
LL | let b = Box::new(1); //[ast]~ NOTE first assignment LL | let b = Box::new(1); //[ast]~ NOTE first assignment
| - | -
| | | |
| first assignment to `b` | first assignment to `b`
| consider changing this to `mut b` | help: make this binding mutable: `mut b`
... ...
LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable
| ^ cannot assign twice to immutable variable | ^ cannot assign twice to immutable variable
error[E0384]: cannot assign to immutable argument `b` error[E0384]: cannot assign to immutable argument `b`
--> $DIR/issue-45199.rs:37:5 --> $DIR/issue-45199.rs:40:5
| |
LL | fn test_args(b: Box<i32>) { //[ast]~ NOTE first assignment LL | fn test_args(b: Box<i32>) { //[ast]~ NOTE first assignment
| - consider changing this to `mut b` | - help: make this binding mutable: `mut b`
LL | //[mir]~^ NOTE consider changing this to `mut b` ...
LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable
| ^ cannot assign to immutable argument | ^ cannot assign to immutable argument

View file

@ -13,7 +13,8 @@
fn test_drop_replace() { fn test_drop_replace() {
let b: Box<isize>; let b: Box<isize>;
//[mir]~^ NOTE consider changing this to `mut b` //[mir]~^ HELP make this binding mutable
//[mir]~| SUGGESTION mut b
b = Box::new(1); //[ast]~ NOTE first assignment b = Box::new(1); //[ast]~ NOTE first assignment
//[mir]~^ NOTE first assignment //[mir]~^ NOTE first assignment
b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable
@ -25,7 +26,8 @@ fn test_drop_replace() {
fn test_call() { fn test_call() {
let b = Box::new(1); //[ast]~ NOTE first assignment let b = Box::new(1); //[ast]~ NOTE first assignment
//[mir]~^ NOTE first assignment //[mir]~^ NOTE first assignment
//[mir]~| NOTE consider changing this to `mut b` //[mir]~| HELP make this binding mutable
//[mir]~| SUGGESTION mut b
b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable
//[mir]~^ ERROR cannot assign twice to immutable variable `b` //[mir]~^ ERROR cannot assign twice to immutable variable `b`
//[ast]~| NOTE cannot assign twice to immutable //[ast]~| NOTE cannot assign twice to immutable
@ -33,7 +35,8 @@ fn test_call() {
} }
fn test_args(b: Box<i32>) { //[ast]~ NOTE first assignment fn test_args(b: Box<i32>) { //[ast]~ NOTE first assignment
//[mir]~^ NOTE consider changing this to `mut b` //[mir]~^ HELP make this binding mutable
//[mir]~| SUGGESTION mut b
b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable
//[mir]~^ ERROR cannot assign to immutable argument `b` //[mir]~^ ERROR cannot assign to immutable argument `b`
//[ast]~| NOTE cannot assign twice to immutable //[ast]~| NOTE cannot assign twice to immutable

View file

@ -2,7 +2,7 @@ error[E0594]: cannot assign to field `_iter.node` of immutable binding
--> $DIR/issue-5500-1.rs:22:5 --> $DIR/issue-5500-1.rs:22:5
| |
LL | let _iter = TrieMapIterator{node: &a}; LL | let _iter = TrieMapIterator{node: &a};
| ----- consider changing this to `mut _iter` | ----- help: make this binding mutable: `mut _iter`
LL | / _iter.node = & //[ast]~ ERROR cannot assign to field `_iter.node` of immutable binding LL | / _iter.node = & //[ast]~ ERROR cannot assign to field `_iter.node` of immutable binding
LL | | //[mir]~^ ERROR cannot assign to field `_iter.node` of immutable binding (Ast) LL | | //[mir]~^ ERROR cannot assign to field `_iter.node` of immutable binding (Ast)
LL | | // MIR doesn't generate an error because the code isn't reachable. This is OK LL | | // MIR doesn't generate an error because the code isn't reachable. This is OK

View file

@ -2,7 +2,7 @@ error[E0594]: cannot assign to field `_iter.node` of immutable binding (Ast)
--> $DIR/issue-5500-1.rs:22:5 --> $DIR/issue-5500-1.rs:22:5
| |
LL | let _iter = TrieMapIterator{node: &a}; LL | let _iter = TrieMapIterator{node: &a};
| ----- consider changing this to `mut _iter` | ----- help: make this binding mutable: `mut _iter`
LL | / _iter.node = & //[ast]~ ERROR cannot assign to field `_iter.node` of immutable binding LL | / _iter.node = & //[ast]~ ERROR cannot assign to field `_iter.node` of immutable binding
LL | | //[mir]~^ ERROR cannot assign to field `_iter.node` of immutable binding (Ast) LL | | //[mir]~^ ERROR cannot assign to field `_iter.node` of immutable binding (Ast)
LL | | // MIR doesn't generate an error because the code isn't reachable. This is OK LL | | // MIR doesn't generate an error because the code isn't reachable. This is OK

View file

@ -12,7 +12,7 @@ error[E0384]: cannot assign to immutable argument `y`
--> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:14:5 --> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:14:5
| |
LL | fn foo(mut x: Ref, y: &u32) { LL | fn foo(mut x: Ref, y: &u32) {
| - consider changing this to `mut y` | - help: make this binding mutable: `mut y`
LL | y = x.b; //~ ERROR lifetime mismatch LL | y = x.b; //~ ERROR lifetime mismatch
| ^^^^^^^ cannot assign to immutable argument | ^^^^^^^ cannot assign to immutable argument

View file

@ -33,7 +33,7 @@ error[E0384]: cannot assign twice to immutable variable `x` (Mir)
--> $DIR/liveness-assign-imm-local-notes.rs:23:9 --> $DIR/liveness-assign-imm-local-notes.rs:23:9
| |
LL | let x; LL | let x;
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
... ...
LL | x = 2; LL | x = 2;
| ----- first assignment to `x` | ----- first assignment to `x`
@ -44,7 +44,7 @@ error[E0384]: cannot assign twice to immutable variable `x` (Mir)
--> $DIR/liveness-assign-imm-local-notes.rs:35:13 --> $DIR/liveness-assign-imm-local-notes.rs:35:13
| |
LL | let x; LL | let x;
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
... ...
LL | x = 2; LL | x = 2;
| ----- first assignment to `x` | ----- first assignment to `x`
@ -55,7 +55,7 @@ error[E0384]: cannot assign twice to immutable variable `x` (Mir)
--> $DIR/liveness-assign-imm-local-notes.rs:45:13 --> $DIR/liveness-assign-imm-local-notes.rs:45:13
| |
LL | let x; LL | let x;
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
... ...
LL | x = 1; //~ ERROR (Ast) [E0384] LL | x = 1; //~ ERROR (Ast) [E0384]
| ^^^^^ cannot assign twice to immutable variable | ^^^^^ cannot assign twice to immutable variable
@ -64,7 +64,7 @@ error[E0384]: cannot assign twice to immutable variable `x` (Mir)
--> $DIR/liveness-assign-imm-local-notes.rs:48:13 --> $DIR/liveness-assign-imm-local-notes.rs:48:13
| |
LL | let x; LL | let x;
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
... ...
LL | x = 1; //~ ERROR (Ast) [E0384] LL | x = 1; //~ ERROR (Ast) [E0384]
| ----- first assignment to `x` | ----- first assignment to `x`

View file

@ -1,8 +1,8 @@
error[E0384]: cannot assign twice to immutable variable `v` error[E0384]: cannot assign twice to immutable variable `v`
--> $DIR/liveness-assign-imm-local-in-loop.rs:18:9 --> $DIR/liveness-assign-imm-local-in-loop.rs:19:9
| |
LL | let v: isize; LL | let v: isize;
| - consider changing this to `mut v` | - help: make this binding mutable: `mut v`
... ...
LL | v = 1; //[ast]~ ERROR cannot assign twice to immutable variable LL | v = 1; //[ast]~ ERROR cannot assign twice to immutable variable
| ^^^^^ cannot assign twice to immutable variable | ^^^^^ cannot assign twice to immutable variable

View file

@ -1,5 +1,5 @@
error[E0384]: cannot assign twice to immutable variable `v` error[E0384]: cannot assign twice to immutable variable `v`
--> $DIR/liveness-assign-imm-local-in-loop.rs:18:9 --> $DIR/liveness-assign-imm-local-in-loop.rs:19:9
| |
LL | v = 1; //[ast]~ ERROR cannot assign twice to immutable variable LL | v = 1; //[ast]~ ERROR cannot assign twice to immutable variable
| ^^^^^ cannot assign twice to immutable variable | ^^^^^ cannot assign twice to immutable variable

View file

@ -1,8 +1,8 @@
error[E0384]: cannot assign twice to immutable variable `v` error[E0384]: cannot assign twice to immutable variable `v`
--> $DIR/liveness-assign-imm-local-in-loop.rs:18:9 --> $DIR/liveness-assign-imm-local-in-loop.rs:19:9
| |
LL | let v: isize; LL | let v: isize;
| - consider changing this to `mut v` | - help: make this binding mutable: `mut v`
... ...
LL | v = 1; //[ast]~ ERROR cannot assign twice to immutable variable LL | v = 1; //[ast]~ ERROR cannot assign twice to immutable variable
| ^^^^^ cannot assign twice to immutable variable | ^^^^^ cannot assign twice to immutable variable

View file

@ -13,7 +13,8 @@
fn test() { fn test() {
let v: isize; let v: isize;
//[mir]~^ NOTE consider changing this to `mut v` //[mir]~^ HELP make this binding mutable
//[mir]~| SUGGESTION mut v
loop { loop {
v = 1; //[ast]~ ERROR cannot assign twice to immutable variable v = 1; //[ast]~ ERROR cannot assign twice to immutable variable
//[mir]~^ ERROR cannot assign twice to immutable variable `v` //[mir]~^ ERROR cannot assign twice to immutable variable `v`

View file

@ -1,9 +1,9 @@
error[E0384]: cannot assign twice to immutable variable `v` error[E0384]: cannot assign twice to immutable variable `v`
--> $DIR/liveness-assign-imm-local-in-op-eq.rs:19:5 --> $DIR/liveness-assign-imm-local-in-op-eq.rs:20:5
| |
LL | let v: isize; LL | let v: isize;
| - consider changing this to `mut v` | - help: make this binding mutable: `mut v`
LL | //[mir]~^ NOTE consider changing this to `mut v` ...
LL | v = 2; //[ast]~ NOTE first assignment LL | v = 2; //[ast]~ NOTE first assignment
| ----- first assignment to `v` | ----- first assignment to `v`
LL | //[mir]~^ NOTE first assignment LL | //[mir]~^ NOTE first assignment

View file

@ -1,5 +1,5 @@
error[E0384]: cannot assign twice to immutable variable `v` error[E0384]: cannot assign twice to immutable variable `v`
--> $DIR/liveness-assign-imm-local-in-op-eq.rs:19:5 --> $DIR/liveness-assign-imm-local-in-op-eq.rs:20:5
| |
LL | v = 2; //[ast]~ NOTE first assignment LL | v = 2; //[ast]~ NOTE first assignment
| ----- first assignment to `v` | ----- first assignment to `v`

View file

@ -1,9 +1,9 @@
error[E0384]: cannot assign twice to immutable variable `v` error[E0384]: cannot assign twice to immutable variable `v`
--> $DIR/liveness-assign-imm-local-in-op-eq.rs:19:5 --> $DIR/liveness-assign-imm-local-in-op-eq.rs:20:5
| |
LL | let v: isize; LL | let v: isize;
| - consider changing this to `mut v` | - help: make this binding mutable: `mut v`
LL | //[mir]~^ NOTE consider changing this to `mut v` ...
LL | v = 2; //[ast]~ NOTE first assignment LL | v = 2; //[ast]~ NOTE first assignment
| ----- first assignment to `v` | ----- first assignment to `v`
LL | //[mir]~^ NOTE first assignment LL | //[mir]~^ NOTE first assignment

View file

@ -13,7 +13,8 @@
fn test() { fn test() {
let v: isize; let v: isize;
//[mir]~^ NOTE consider changing this to `mut v` //[mir]~^ HELP make this binding mutable
//[mir]~| SUGGESTION mut v
v = 2; //[ast]~ NOTE first assignment v = 2; //[ast]~ NOTE first assignment
//[mir]~^ NOTE first assignment //[mir]~^ NOTE first assignment
v += 1; //[ast]~ ERROR cannot assign twice to immutable variable v += 1; //[ast]~ ERROR cannot assign twice to immutable variable

View file

@ -1,11 +1,11 @@
error[E0384]: cannot assign twice to immutable variable `b` error[E0384]: cannot assign twice to immutable variable `b`
--> $DIR/liveness-assign-imm-local-with-drop.rs:19:5 --> $DIR/liveness-assign-imm-local-with-drop.rs:20:5
| |
LL | let b = Box::new(1); //[ast]~ NOTE first assignment LL | let b = Box::new(1); //[ast]~ NOTE first assignment
| - | -
| | | |
| first assignment to `b` | first assignment to `b`
| consider changing this to `mut b` | help: make this binding mutable: `mut b`
... ...
LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable
| ^ cannot assign twice to immutable variable | ^ cannot assign twice to immutable variable

View file

@ -1,5 +1,5 @@
error[E0384]: cannot assign twice to immutable variable `b` error[E0384]: cannot assign twice to immutable variable `b`
--> $DIR/liveness-assign-imm-local-with-drop.rs:19:5 --> $DIR/liveness-assign-imm-local-with-drop.rs:20:5
| |
LL | let b = Box::new(1); //[ast]~ NOTE first assignment LL | let b = Box::new(1); //[ast]~ NOTE first assignment
| - first assignment to `b` | - first assignment to `b`

View file

@ -1,11 +1,11 @@
error[E0384]: cannot assign twice to immutable variable `b` error[E0384]: cannot assign twice to immutable variable `b`
--> $DIR/liveness-assign-imm-local-with-drop.rs:19:5 --> $DIR/liveness-assign-imm-local-with-drop.rs:20:5
| |
LL | let b = Box::new(1); //[ast]~ NOTE first assignment LL | let b = Box::new(1); //[ast]~ NOTE first assignment
| - | -
| | | |
| first assignment to `b` | first assignment to `b`
| consider changing this to `mut b` | help: make this binding mutable: `mut b`
... ...
LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable
| ^ cannot assign twice to immutable variable | ^ cannot assign twice to immutable variable

View file

@ -14,7 +14,8 @@
fn test() { fn test() {
let b = Box::new(1); //[ast]~ NOTE first assignment let b = Box::new(1); //[ast]~ NOTE first assignment
//[mir]~^ NOTE first assignment //[mir]~^ NOTE first assignment
//[mir]~| NOTE consider changing this to `mut b` //[mir]~| HELP make this binding mutable
//[mir]~| SUGGESTION mut b
drop(b); drop(b);
b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable
//[mir]~^ ERROR cannot assign twice to immutable variable `b` //[mir]~^ ERROR cannot assign twice to immutable variable `b`

View file

@ -1,11 +1,11 @@
error[E0384]: cannot assign twice to immutable variable `v` error[E0384]: cannot assign twice to immutable variable `v`
--> $DIR/liveness-assign-imm-local-with-init.rs:19:5 --> $DIR/liveness-assign-imm-local-with-init.rs:20:5
| |
LL | let v: isize = 1; //[ast]~ NOTE first assignment LL | let v: isize = 1; //[ast]~ NOTE first assignment
| - | -
| | | |
| first assignment to `v` | first assignment to `v`
| consider changing this to `mut v` | help: make this binding mutable: `mut v`
... ...
LL | v = 2; //[ast]~ ERROR cannot assign twice to immutable variable LL | v = 2; //[ast]~ ERROR cannot assign twice to immutable variable
| ^^^^^ cannot assign twice to immutable variable | ^^^^^ cannot assign twice to immutable variable

View file

@ -1,5 +1,5 @@
error[E0384]: cannot assign twice to immutable variable `v` error[E0384]: cannot assign twice to immutable variable `v`
--> $DIR/liveness-assign-imm-local-with-init.rs:19:5 --> $DIR/liveness-assign-imm-local-with-init.rs:20:5
| |
LL | let v: isize = 1; //[ast]~ NOTE first assignment LL | let v: isize = 1; //[ast]~ NOTE first assignment
| - first assignment to `v` | - first assignment to `v`

View file

@ -1,11 +1,11 @@
error[E0384]: cannot assign twice to immutable variable `v` error[E0384]: cannot assign twice to immutable variable `v`
--> $DIR/liveness-assign-imm-local-with-init.rs:19:5 --> $DIR/liveness-assign-imm-local-with-init.rs:20:5
| |
LL | let v: isize = 1; //[ast]~ NOTE first assignment LL | let v: isize = 1; //[ast]~ NOTE first assignment
| - | -
| | | |
| first assignment to `v` | first assignment to `v`
| consider changing this to `mut v` | help: make this binding mutable: `mut v`
... ...
LL | v = 2; //[ast]~ ERROR cannot assign twice to immutable variable LL | v = 2; //[ast]~ ERROR cannot assign twice to immutable variable
| ^^^^^ cannot assign twice to immutable variable | ^^^^^ cannot assign twice to immutable variable

View file

@ -14,7 +14,8 @@
fn test() { fn test() {
let v: isize = 1; //[ast]~ NOTE first assignment let v: isize = 1; //[ast]~ NOTE first assignment
//[mir]~^ NOTE first assignment //[mir]~^ NOTE first assignment
//[mir]~| NOTE consider changing this to `mut v` //[mir]~| HELP make this binding mutable
//[mir]~| SUGGESTION mut v
v.clone(); v.clone();
v = 2; //[ast]~ ERROR cannot assign twice to immutable variable v = 2; //[ast]~ ERROR cannot assign twice to immutable variable
//[mir]~^ ERROR cannot assign twice to immutable variable `v` //[mir]~^ ERROR cannot assign twice to immutable variable `v`

View file

@ -2,7 +2,7 @@ error[E0596]: cannot borrow immutable local variable `foo` as mutable
--> $DIR/span-covering-argument-1.rs:15:19 --> $DIR/span-covering-argument-1.rs:15:19
| |
LL | let $s = 0; LL | let $s = 0;
| -- consider changing this to `mut $s` | -- help: make this binding mutable: `mut $s`
LL | *&mut $s = 0; LL | *&mut $s = 0;
| ^^ cannot borrow mutably | ^^ cannot borrow mutably
... ...

View file

@ -5,7 +5,7 @@ LL | let &mut x = foo;
| - | -
| | | |
| first assignment to `x` | first assignment to `x`
| consider changing this to `mut x` | help: make this binding mutable: `mut x`
LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable
| ^^^^^^ cannot assign twice to immutable variable | ^^^^^^ cannot assign twice to immutable variable

View file

@ -5,7 +5,7 @@ LL | let &mut x = foo;
| - | -
| | | |
| first assignment to `x` | first assignment to `x`
| consider changing this to `mut x` | help: make this binding mutable: `mut x`
LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable
| ^^^^^^ cannot assign twice to immutable variable | ^^^^^^ cannot assign twice to immutable variable

View file

@ -1,18 +1,18 @@
error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable
--> $DIR/mut-suggestion.rs:21:5 --> $DIR/mut-suggestion.rs:22:5
| |
LL | fn func(arg: S) { LL | fn func(arg: S) {
| --- help: consider changing this to be mutable: `mut arg` | --- help: consider changing this to be mutable: `mut arg`
LL | //~^ consider changing this to `mut arg` ...
LL | arg.mutate(); LL | arg.mutate();
| ^^^ cannot borrow as mutable | ^^^ cannot borrow as mutable
error[E0596]: cannot borrow `local` as mutable, as it is not declared as mutable error[E0596]: cannot borrow `local` as mutable, as it is not declared as mutable
--> $DIR/mut-suggestion.rs:29:5 --> $DIR/mut-suggestion.rs:31:5
| |
LL | let local = S; LL | let local = S;
| ----- help: consider changing this to be mutable: `mut local` | ----- help: consider changing this to be mutable: `mut local`
LL | //~^ consider changing this to `mut local` ...
LL | local.mutate(); LL | local.mutate();
| ^^^^^ cannot borrow as mutable | ^^^^^ cannot borrow as mutable

View file

@ -17,7 +17,8 @@ impl S {
} }
fn func(arg: S) { fn func(arg: S) {
//~^ consider changing this to `mut arg` //~^ HELP make this binding mutable
//~| SUGGESTION mut arg
arg.mutate(); arg.mutate();
//~^ ERROR cannot borrow immutable argument //~^ ERROR cannot borrow immutable argument
//~| cannot borrow mutably //~| cannot borrow mutably
@ -25,7 +26,8 @@ fn func(arg: S) {
fn main() { fn main() {
let local = S; let local = S;
//~^ consider changing this to `mut local` //~^ HELP make this binding mutable
//~| SUGGESTION mut local
local.mutate(); local.mutate();
//~^ ERROR cannot borrow immutable local variable //~^ ERROR cannot borrow immutable local variable
//~| cannot borrow mutably //~| cannot borrow mutably

View file

@ -1,18 +1,18 @@
error[E0596]: cannot borrow immutable argument `arg` as mutable error[E0596]: cannot borrow immutable argument `arg` as mutable
--> $DIR/mut-suggestion.rs:21:5 --> $DIR/mut-suggestion.rs:22:5
| |
LL | fn func(arg: S) { LL | fn func(arg: S) {
| --- consider changing this to `mut arg` | --- help: make this binding mutable: `mut arg`
LL | //~^ consider changing this to `mut arg` ...
LL | arg.mutate(); LL | arg.mutate();
| ^^^ cannot borrow mutably | ^^^ cannot borrow mutably
error[E0596]: cannot borrow immutable local variable `local` as mutable error[E0596]: cannot borrow immutable local variable `local` as mutable
--> $DIR/mut-suggestion.rs:29:5 --> $DIR/mut-suggestion.rs:31:5
| |
LL | let local = S; LL | let local = S;
| ----- consider changing this to `mut local` | ----- help: make this binding mutable: `mut local`
LL | //~^ consider changing this to `mut local` ...
LL | local.mutate(); LL | local.mutate();
| ^^^^^ cannot borrow mutably | ^^^^^ cannot borrow mutably

View file

@ -2,7 +2,7 @@ error[E0594]: cannot assign to field `nyan.how_hungry` of immutable binding
--> $DIR/mutable-class-fields.rs:28:3 --> $DIR/mutable-class-fields.rs:28:3
| |
LL | let nyan : cat = cat(52, 99); LL | let nyan : cat = cat(52, 99);
| ---- consider changing this to `mut nyan` | ---- help: make this binding mutable: `mut nyan`
LL | nyan.how_hungry = 0; //[ast]~ ERROR cannot assign LL | nyan.how_hungry = 0; //[ast]~ ERROR cannot assign
| ^^^^^^^^^^^^^^^^^^^ cannot mutably borrow field of immutable binding | ^^^^^^^^^^^^^^^^^^^ cannot mutably borrow field of immutable binding

View file

@ -2,7 +2,7 @@ error[E0596]: cannot borrow immutable argument `x` as mutable
--> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:63:24 --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:63:24
| |
LL | fn deref_mut_field1(x: Own<Point>) { LL | fn deref_mut_field1(x: Own<Point>) {
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
LL | let __isize = &mut x.y; //~ ERROR cannot borrow LL | let __isize = &mut x.y; //~ ERROR cannot borrow
| ^ cannot borrow mutably | ^ cannot borrow mutably
@ -28,7 +28,7 @@ error[E0596]: cannot borrow immutable argument `x` as mutable
--> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:98:5 --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:98:5
| |
LL | fn assign_field1<'a>(x: Own<Point>) { LL | fn assign_field1<'a>(x: Own<Point>) {
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
LL | x.y = 3; //~ ERROR cannot borrow LL | x.y = 3; //~ ERROR cannot borrow
| ^ cannot borrow mutably | ^ cannot borrow mutably
@ -54,7 +54,7 @@ error[E0596]: cannot borrow immutable argument `x` as mutable
--> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:119:5 --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:119:5
| |
LL | fn deref_mut_method1(x: Own<Point>) { LL | fn deref_mut_method1(x: Own<Point>) {
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
LL | x.set(0, 0); //~ ERROR cannot borrow LL | x.set(0, 0); //~ ERROR cannot borrow
| ^ cannot borrow mutably | ^ cannot borrow mutably
@ -70,7 +70,7 @@ error[E0596]: cannot borrow immutable argument `x` as mutable
--> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:139:6 --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:139:6
| |
LL | fn assign_method1<'a>(x: Own<Point>) { LL | fn assign_method1<'a>(x: Own<Point>) {
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
LL | *x.y_mut() = 3; //~ ERROR cannot borrow LL | *x.y_mut() = 3; //~ ERROR cannot borrow
| ^ cannot borrow mutably | ^ cannot borrow mutably

View file

@ -2,7 +2,7 @@ error[E0596]: cannot borrow immutable argument `x` as mutable
--> $DIR/borrowck-borrow-overloaded-deref-mut.rs:39:25 --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:39:25
| |
LL | fn deref_mut1(x: Own<isize>) { LL | fn deref_mut1(x: Own<isize>) {
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
LL | let __isize = &mut *x; //~ ERROR cannot borrow LL | let __isize = &mut *x; //~ ERROR cannot borrow
| ^ cannot borrow mutably | ^ cannot borrow mutably
@ -18,7 +18,7 @@ error[E0596]: cannot borrow immutable argument `x` as mutable
--> $DIR/borrowck-borrow-overloaded-deref-mut.rs:59:6 --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:59:6
| |
LL | fn assign1<'a>(x: Own<isize>) { LL | fn assign1<'a>(x: Own<isize>) {
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
LL | *x = 3; //~ ERROR cannot borrow LL | *x = 3; //~ ERROR cannot borrow
| ^ cannot borrow mutably | ^ cannot borrow mutably

View file

@ -11,7 +11,7 @@ error[E0596]: cannot borrow immutable `Box` content `*x` as mutable
--> $DIR/borrowck-object-mutability.rs:29:5 --> $DIR/borrowck-object-mutability.rs:29:5
| |
LL | fn owned_receiver(x: Box<Foo>) { LL | fn owned_receiver(x: Box<Foo>) {
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
LL | x.borrowed(); LL | x.borrowed();
LL | x.borrowed_mut(); //~ ERROR cannot borrow LL | x.borrowed_mut(); //~ ERROR cannot borrow
| ^ cannot borrow as mutable | ^ cannot borrow as mutable

View file

@ -2,7 +2,7 @@ error[E0595]: closure cannot assign to immutable local variable `x`
--> $DIR/unboxed-closure-immutable-capture.rs:23:5 --> $DIR/unboxed-closure-immutable-capture.rs:23:5
| |
LL | let x = 0; LL | let x = 0;
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
... ...
LL | || x = 1; //~ ERROR cannot assign LL | || x = 1; //~ ERROR cannot assign
| ^^ cannot borrow mutably | ^^ cannot borrow mutably
@ -11,7 +11,7 @@ error[E0595]: closure cannot assign to immutable local variable `x`
--> $DIR/unboxed-closure-immutable-capture.rs:25:5 --> $DIR/unboxed-closure-immutable-capture.rs:25:5
| |
LL | let x = 0; LL | let x = 0;
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
... ...
LL | || set(&mut x); //~ ERROR cannot assign LL | || set(&mut x); //~ ERROR cannot assign
| ^^ cannot borrow mutably | ^^ cannot borrow mutably
@ -20,7 +20,7 @@ error[E0595]: closure cannot assign to immutable local variable `x`
--> $DIR/unboxed-closure-immutable-capture.rs:26:5 --> $DIR/unboxed-closure-immutable-capture.rs:26:5
| |
LL | let x = 0; LL | let x = 0;
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
... ...
LL | || x = 1; //~ ERROR cannot assign LL | || x = 1; //~ ERROR cannot assign
| ^^ cannot borrow mutably | ^^ cannot borrow mutably
@ -29,7 +29,7 @@ error[E0595]: closure cannot assign to immutable local variable `x`
--> $DIR/unboxed-closure-immutable-capture.rs:28:5 --> $DIR/unboxed-closure-immutable-capture.rs:28:5
| |
LL | let x = 0; LL | let x = 0;
| - consider changing this to `mut x` | - help: make this binding mutable: `mut x`
... ...
LL | || set(&mut x); //~ ERROR cannot assign LL | || set(&mut x); //~ ERROR cannot assign
| ^^ cannot borrow mutably | ^^ cannot borrow mutably

View file

@ -2,7 +2,7 @@ error[E0595]: closure cannot assign to immutable local variable `tick1`
--> $DIR/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs:26:17 --> $DIR/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs:26:17
| |
LL | let tick1 = || { LL | let tick1 = || {
| ----- consider changing this to `mut tick1` | ----- help: make this binding mutable: `mut tick1`
... ...
LL | let tick2 = || { //~ ERROR closure cannot assign to immutable local variable `tick1` LL | let tick2 = || { //~ ERROR closure cannot assign to immutable local variable `tick1`
| ^^ cannot borrow mutably | ^^ cannot borrow mutably
@ -11,7 +11,7 @@ error[E0596]: cannot borrow immutable local variable `tick2` as mutable
--> $DIR/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs:30:5 --> $DIR/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs:30:5
| |
LL | let tick2 = || { //~ ERROR closure cannot assign to immutable local variable `tick1` LL | let tick2 = || { //~ ERROR closure cannot assign to immutable local variable `tick1`
| ----- consider changing this to `mut tick2` | ----- help: make this binding mutable: `mut tick2`
... ...
LL | tick2(); //~ ERROR cannot borrow LL | tick2(); //~ ERROR cannot borrow
| ^^^^^ cannot borrow mutably | ^^^^^ cannot borrow mutably

View file

@ -2,7 +2,7 @@ error[E0596]: cannot borrow immutable local variable `tick` as mutable
--> $DIR/unboxed-closures-infer-fnmut-missing-mut.rs:17:5 --> $DIR/unboxed-closures-infer-fnmut-missing-mut.rs:17:5
| |
LL | let tick = || counter += 1; LL | let tick = || counter += 1;
| ---- consider changing this to `mut tick` | ---- help: make this binding mutable: `mut tick`
LL | tick(); //~ ERROR cannot borrow immutable local variable `tick` as mutable LL | tick(); //~ ERROR cannot borrow immutable local variable `tick` as mutable
| ^^^^ cannot borrow mutably | ^^^^ cannot borrow mutably

View file

@ -2,7 +2,7 @@ error[E0596]: cannot borrow immutable local variable `tick` as mutable
--> $DIR/unboxed-closures-infer-fnmut-move-missing-mut.rs:17:5 --> $DIR/unboxed-closures-infer-fnmut-move-missing-mut.rs:17:5
| |
LL | let tick = move || counter += 1; LL | let tick = move || counter += 1;
| ---- consider changing this to `mut tick` | ---- help: make this binding mutable: `mut tick`
LL | tick(); //~ ERROR cannot borrow immutable local variable `tick` as mutable LL | tick(); //~ ERROR cannot borrow immutable local variable `tick` as mutable
| ^^^^ cannot borrow mutably | ^^^^ cannot borrow mutably

View file

@ -2,7 +2,7 @@ error[E0595]: closure cannot assign to immutable local variable `n`
--> $DIR/unboxed-closures-mutate-upvar.rs:24:27 --> $DIR/unboxed-closures-mutate-upvar.rs:24:27
| |
LL | let n = 0; LL | let n = 0;
| - consider changing this to `mut n` | - help: make this binding mutable: `mut n`
LL | let mut f = to_fn_mut(|| { //~ ERROR closure cannot assign LL | let mut f = to_fn_mut(|| { //~ ERROR closure cannot assign
| ^^ cannot borrow mutably | ^^ cannot borrow mutably

View file

@ -2,7 +2,7 @@ error[E0596]: cannot borrow immutable local variable `v` as mutable
--> $DIR/writing-to-immutable-vec.rs:14:5 --> $DIR/writing-to-immutable-vec.rs:14:5
| |
LL | let v: Vec<isize> = vec![1, 2, 3]; LL | let v: Vec<isize> = vec![1, 2, 3];
| - consider changing this to `mut v` | - help: make this binding mutable: `mut v`
LL | v[1] = 4; //~ ERROR cannot borrow immutable local variable `v` as mutable LL | v[1] = 4; //~ ERROR cannot borrow immutable local variable `v` as mutable
| ^ cannot borrow mutably | ^ cannot borrow mutably