Skip to content

Commit

Permalink
NLL: Updates to diagnostic output in test/ui.
Browse files Browse the repository at this point in the history
  • Loading branch information
pnkfelix committed Jun 19, 2018
1 parent 7fd4b52 commit 2d4df5b
Show file tree
Hide file tree
Showing 31 changed files with 163 additions and 103 deletions.
3 changes: 3 additions & 0 deletions src/test/ui/augmented-assignments.nll.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ LL | | x; //~ value moved here
error[E0596]: cannot borrow immutable item `y` as mutable
--> $DIR/augmented-assignments.rs:30:5
|
LL | let y = Int(2);
| - 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
| ^ cannot borrow as mutable

Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/borrowck/issue-45983.nll.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ error[E0594]: cannot assign to immutable item `x`
--> $DIR/issue-45983.rs:17:18
|
LL | give_any(|y| x = Some(y));
| ^^^^^^^^^^^ cannot mutate
|
= note: the value which is causing this path not to be mutable is...: `x`
| ^^^^^^^^^^^ cannot assign

error[E0596]: cannot borrow immutable item `x` as mutable
--> $DIR/issue-45983.rs:17:14
|
LL | let x = None;
| - help: consider changing this to be mutable: `mut x`
LL | give_any(|y| x = Some(y));
| ^^^^^^^^^^^^^^^ cannot borrow as mutable

Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/borrowck/mut-borrow-of-mut-ref.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
error[E0596]: cannot borrow immutable item `b` as mutable
--> $DIR/mut-borrow-of-mut-ref.rs:18:7
|
LL | fn f(b: &mut i32) {
| - help: consider changing this to be mutable: `mut b`
LL | g(&mut b) //~ ERROR cannot borrow
| ^^^^^^ cannot borrow as mutable

Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/codemap_tests/huge_multispan_highlight.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
error[E0596]: cannot borrow immutable item `x` as mutable
--> $DIR/huge_multispan_highlight.rs:100:13
|
LL | let x = "foo";
| - help: consider changing this to be mutable: `mut x`
...
LL | let y = &mut x; //~ ERROR cannot borrow
| ^^^^^^ cannot borrow as mutable

Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/did_you_mean/issue-31424.nll.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ LL | (&mut self).bar(); //~ ERROR cannot borrow
error[E0596]: cannot borrow immutable item `self` as mutable
--> $DIR/issue-31424.rs:23:9
|
LL | fn bar(self: &mut Self) {
| ---- help: consider changing this to be mutable: `mut self`
LL | (&mut self).bar(); //~ ERROR cannot borrow
| ^^^^^^^^^^^ cannot borrow as mutable

Expand Down
5 changes: 4 additions & 1 deletion src/test/ui/did_you_mean/issue-34126.nll.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ error[E0596]: cannot borrow immutable item `self` as mutable
--> $DIR/issue-34126.rs:16:18
|
LL | self.run(&mut self); //~ ERROR cannot borrow
| ^^^^^^^^^ cannot borrow as mutable
| ^^^^^^^^^
| |
| cannot borrow as mutable
| try removing `&mut` here

error[E0502]: cannot borrow `self` as mutable because it is also borrowed as immutable
--> $DIR/issue-34126.rs:16:18
Expand Down
5 changes: 4 additions & 1 deletion src/test/ui/did_you_mean/issue-34337.nll.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ error[E0596]: cannot borrow immutable item `key` as mutable
--> $DIR/issue-34337.rs:16:9
|
LL | get(&mut key); //~ ERROR cannot borrow
| ^^^^^^^^ cannot borrow as mutable
| ^^^^^^^^
| |
| cannot borrow as mutable
| try removing `&mut` here

error: aborting due to previous error

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/did_you_mean/issue-35937.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
error[E0596]: cannot borrow immutable item `f.v` as mutable
--> $DIR/issue-35937.rs:17:5
|
LL | let f = Foo { v: Vec::new() };
| - help: consider changing this to be mutable: `mut f`
LL | f.v.push("cat".to_string()); //~ ERROR cannot borrow
| ^^^ cannot borrow as mutable
|
= note: the value which is causing this path not to be mutable is...: `f`

error[E0384]: cannot assign twice to immutable variable `s.x`
--> $DIR/issue-35937.rs:26:5
Expand Down
5 changes: 4 additions & 1 deletion src/test/ui/did_you_mean/issue-37139.nll.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ error[E0596]: cannot borrow immutable item `x` as mutable
--> $DIR/issue-37139.rs:22:18
|
LL | test(&mut x); //~ ERROR cannot borrow immutable
| ^^^^^^ cannot borrow as mutable
| ^^^^^^
| |
| cannot borrow as mutable
| try removing `&mut` here

error: aborting due to previous error

Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/did_you_mean/issue-38147-1.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
error[E0596]: cannot borrow immutable item `*self.s` as mutable
--> $DIR/issue-38147-1.rs:27:9
|
LL | fn f(&self) {
| ----- help: consider changing this to be a mutable reference: `&mut Foo<'_>`
LL | self.s.push('x'); //~ ERROR cannot borrow data mutably
| ^^^^^^ cannot borrow as mutable
|
= note: the value which is causing this path not to be mutable is...: `*self`
| ^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable

error: aborting due to previous error

Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/did_you_mean/issue-38147-4.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
error[E0596]: cannot borrow immutable item `*f.s` as mutable
--> $DIR/issue-38147-4.rs:16:5
|
LL | fn f(x: usize, f: &Foo) {
| ---- help: consider changing this to be a mutable reference: `&mut Foo<'_>`
LL | f.s.push('x'); //~ ERROR cannot borrow data mutably
| ^^^ cannot borrow as mutable
|
= note: the value which is causing this path not to be mutable is...: `*f`
| ^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable

error: aborting due to previous error

Expand Down
70 changes: 37 additions & 33 deletions src/test/ui/did_you_mean/issue-39544.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,96 +1,100 @@
error[E0596]: cannot borrow immutable item `z.x` as mutable
--> $DIR/issue-39544.rs:21:13
|
LL | let z = Z { x: X::Y };
| - help: consider changing this to be mutable: `mut z`
LL | let _ = &mut z.x; //~ ERROR cannot borrow
| ^^^^^^^^ cannot borrow as mutable
|
= note: the value which is causing this path not to be mutable is...: `z`

error[E0596]: cannot borrow immutable item `self.x` as mutable
--> $DIR/issue-39544.rs:26:17
|
LL | fn foo<'z>(&'z self) {
| -------- help: consider changing this to be a mutable reference: `&mut Z`
LL | let _ = &mut self.x; //~ ERROR cannot borrow
| ^^^^^^^^^^^ cannot borrow as mutable
|
= note: the value which is causing this path not to be mutable is...: `*self`
| ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable

error[E0596]: cannot borrow immutable item `self.x` as mutable
--> $DIR/issue-39544.rs:30:17
|
LL | fn foo1(&self, other: &Z) {
| ----- help: consider changing this to be a mutable reference: `&mut Z`
LL | let _ = &mut self.x; //~ ERROR cannot borrow
| ^^^^^^^^^^^ cannot borrow as mutable
|
= note: the value which is causing this path not to be mutable is...: `*self`
| ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable

error[E0596]: cannot borrow immutable item `other.x` as mutable
--> $DIR/issue-39544.rs:31:17
|
LL | fn foo1(&self, other: &Z) {
| -- help: consider changing this to be a mutable reference: `&mut Z`
LL | let _ = &mut self.x; //~ ERROR cannot borrow
LL | let _ = &mut other.x; //~ ERROR cannot borrow
| ^^^^^^^^^^^^ cannot borrow as mutable
|
= note: the value which is causing this path not to be mutable is...: `*other`
| ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable

error[E0596]: cannot borrow immutable item `self.x` as mutable
--> $DIR/issue-39544.rs:35:17
|
LL | fn foo2<'a>(&'a self, other: &Z) {
| -------- help: consider changing this to be a mutable reference: `&mut Z`
LL | let _ = &mut self.x; //~ ERROR cannot borrow
| ^^^^^^^^^^^ cannot borrow as mutable
|
= note: the value which is causing this path not to be mutable is...: `*self`
| ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable

error[E0596]: cannot borrow immutable item `other.x` as mutable
--> $DIR/issue-39544.rs:36:17
|
LL | fn foo2<'a>(&'a self, other: &Z) {
| -- help: consider changing this to be a mutable reference: `&mut Z`
LL | let _ = &mut self.x; //~ ERROR cannot borrow
LL | let _ = &mut other.x; //~ ERROR cannot borrow
| ^^^^^^^^^^^^ cannot borrow as mutable
|
= note: the value which is causing this path not to be mutable is...: `*other`
| ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable

error[E0596]: cannot borrow immutable item `self.x` as mutable
--> $DIR/issue-39544.rs:40:17
|
LL | fn foo3<'a>(self: &'a Self, other: &Z) {
| -------- help: consider changing this to be a mutable reference: `&mut Z`
LL | let _ = &mut self.x; //~ ERROR cannot borrow
| ^^^^^^^^^^^ cannot borrow as mutable
|
= note: the value which is causing this path not to be mutable is...: `*self`
| ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable

error[E0596]: cannot borrow immutable item `other.x` as mutable
--> $DIR/issue-39544.rs:41:17
|
LL | fn foo3<'a>(self: &'a Self, other: &Z) {
| -- help: consider changing this to be a mutable reference: `&mut Z`
LL | let _ = &mut self.x; //~ ERROR cannot borrow
LL | let _ = &mut other.x; //~ ERROR cannot borrow
| ^^^^^^^^^^^^ cannot borrow as mutable
|
= note: the value which is causing this path not to be mutable is...: `*other`
| ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable

error[E0596]: cannot borrow immutable item `other.x` as mutable
--> $DIR/issue-39544.rs:45:17
|
LL | fn foo4(other: &Z) {
| -- help: consider changing this to be a mutable reference: `&mut Z`
LL | let _ = &mut other.x; //~ ERROR cannot borrow
| ^^^^^^^^^^^^ cannot borrow as mutable
|
= note: the value which is causing this path not to be mutable is...: `*other`
| ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable

error[E0596]: cannot borrow immutable item `z.x` as mutable
--> $DIR/issue-39544.rs:51:13
|
LL | pub fn with_arg(z: Z, w: &Z) {
| - help: consider changing this to be mutable: `mut z`
LL | let _ = &mut z.x; //~ ERROR cannot borrow
| ^^^^^^^^ cannot borrow as mutable
|
= note: the value which is causing this path not to be mutable is...: `z`

error[E0596]: cannot borrow immutable item `w.x` as mutable
--> $DIR/issue-39544.rs:52:13
|
LL | pub fn with_arg(z: Z, w: &Z) {
| -- help: consider changing this to be a mutable reference: `&mut Z`
LL | let _ = &mut z.x; //~ ERROR cannot borrow
LL | let _ = &mut w.x; //~ ERROR cannot borrow
| ^^^^^^^^ cannot borrow as mutable
|
= note: the value which is causing this path not to be mutable is...: `*w`
| ^^^^^^^^ `w` is a `&` reference, so the data it refers to cannot be borrowed as mutable

error[E0594]: cannot assign to immutable item `*x.0`
error[E0594]: cannot assign to `*x.0` which is behind a `&` reference
--> $DIR/issue-39544.rs:58:5
|
LL | *x.0 = 1;
| ^^^^^^^^ cannot mutate
| ^^^^^^^^ cannot assign

error: aborting due to 12 previous errors

Expand Down
4 changes: 3 additions & 1 deletion src/test/ui/did_you_mean/issue-40823.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
error[E0596]: cannot borrow immutable item `*buf` as mutable
--> $DIR/issue-40823.rs:13:5
|
LL | let mut buf = &[1, 2, 3, 4];
| ------------- help: consider changing this to be a mutable reference: `&mut [1, 2, 3, 4]`
LL | buf.iter_mut(); //~ ERROR cannot borrow immutable borrowed content
| ^^^ cannot borrow as mutable
| ^^^ `buf` is a `&` reference, so the data it refers to cannot be borrowed as mutable

error: aborting due to previous error

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/error-codes/E0389.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0594]: cannot assign to data in a `&` reference
error[E0594]: cannot assign to `fancy_ref.num` which is behind a `&` reference
--> $DIR/E0389.rs:18:5
|
LL | let fancy_ref = &(&mut fancy);
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/issue-36400.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
error[E0596]: cannot borrow immutable item `*x` as mutable
--> $DIR/issue-36400.rs:15:7
|
LL | let x = Box::new(3);
| - help: consider changing this to be mutable: `mut x`
LL | f(&mut *x); //~ ERROR cannot borrow immutable
| ^^^^^^^ cannot borrow as mutable
|
= note: the value which is causing this path not to be mutable is...: `x`

error: aborting due to previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ LL | y.push(z); //~ ERROR lifetime mismatch
error[E0596]: cannot borrow immutable item `y` as mutable
--> $DIR/ex3-both-anon-regions-using-fn-items.rs:11:3
|
LL | fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) {
| - help: consider changing this to be mutable: `mut y`
LL | y.push(z); //~ ERROR lifetime mismatch
| ^ cannot borrow as mutable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ LL | y.push(z); //~ ERROR lifetime mismatch
error[E0596]: cannot borrow immutable item `y` as mutable
--> $DIR/ex3-both-anon-regions-using-trait-objects.rs:11:3
|
LL | fn foo(x:Box<Fn(&u8, &u8)> , y: Vec<&u8>, z: &u8) {
| - help: consider changing this to be mutable: `mut y`
LL | y.push(z); //~ ERROR lifetime mismatch
| ^ cannot borrow as mutable

Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/macros/span-covering-argument-1.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
error[E0596]: cannot borrow immutable item `foo` as mutable
--> $DIR/span-covering-argument-1.rs:15:14
|
LL | let $s = 0;
| -- help: consider changing this to be mutable: `mut foo`
LL | *&mut $s = 0;
| ^^^^^^^ cannot borrow as mutable
...
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/nll/issue-47388.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0594]: cannot assign to data in a `&` reference
error[E0594]: cannot assign to `fancy_ref.num` which is behind a `&` reference
--> $DIR/issue-47388.rs:18:5
|
LL | let fancy_ref = &(&mut fancy);
Expand Down
18 changes: 6 additions & 12 deletions src/test/ui/rfc-2005-default-binding-mode/enum.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
error[E0594]: cannot assign to data in a `&` reference
error[E0594]: cannot assign to `*x` which is behind a `&` reference
--> $DIR/enum.rs:19:5
|
LL | let Wrap(x) = &Wrap(3);
| - help: consider changing this to be a mutable reference: `&mut`
LL | *x += 1; //~ ERROR cannot assign to immutable
| ^^^^^^^
| ^^^^^^^ cannot assign

error[E0594]: cannot assign to data in a `&` reference
error[E0594]: cannot assign to `*x` which is behind a `&` reference
--> $DIR/enum.rs:23:9
|
LL | if let Some(x) = &Some(3) {
| - help: consider changing this to be a mutable reference: `&mut`
LL | *x += 1; //~ ERROR cannot assign to immutable
| ^^^^^^^
| ^^^^^^^ cannot assign

error[E0594]: cannot assign to data in a `&` reference
error[E0594]: cannot assign to `*x` which is behind a `&` reference
--> $DIR/enum.rs:29:9
|
LL | while let Some(x) = &Some(3) {
| - help: consider changing this to be a mutable reference: `&mut`
LL | *x += 1; //~ ERROR cannot assign to immutable
| ^^^^^^^
| ^^^^^^^ cannot assign

error: aborting due to 3 previous errors

Expand Down
18 changes: 6 additions & 12 deletions src/test/ui/rfc-2005-default-binding-mode/explicit-mut.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
error[E0594]: cannot assign to data in a `&` reference
error[E0594]: cannot assign to `*n` which is behind a `&` reference
--> $DIR/explicit-mut.rs:17:13
|
LL | Some(n) => {
| - help: consider changing this to be a mutable reference: `&mut`
LL | *n += 1; //~ ERROR cannot assign to immutable
| ^^^^^^^
| ^^^^^^^ cannot assign

error[E0594]: cannot assign to data in a `&` reference
error[E0594]: cannot assign to `*n` which is behind a `&` reference
--> $DIR/explicit-mut.rs:25:13
|
LL | Some(n) => {
| - help: consider changing this to be a mutable reference: `&mut`
LL | *n += 1; //~ ERROR cannot assign to immutable
| ^^^^^^^
| ^^^^^^^ cannot assign

error[E0594]: cannot assign to data in a `&` reference
error[E0594]: cannot assign to `*n` which is behind a `&` reference
--> $DIR/explicit-mut.rs:33:13
|
LL | Some(n) => {
| - help: consider changing this to be a mutable reference: `&mut`
LL | *n += 1; //~ ERROR cannot assign to immutable
| ^^^^^^^
| ^^^^^^^ cannot assign

error: aborting due to 3 previous errors

Expand Down
Loading

0 comments on commit 2d4df5b

Please sign in to comment.