Skip to content

Commit 2d4df5b

Browse files
committed
NLL: Updates to diagnostic output in test/ui.
1 parent 7fd4b52 commit 2d4df5b

31 files changed

+163
-103
lines changed

src/test/ui/augmented-assignments.nll.stderr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ LL | | x; //~ value moved here
1717
error[E0596]: cannot borrow immutable item `y` as mutable
1818
--> $DIR/augmented-assignments.rs:30:5
1919
|
20+
LL | let y = Int(2);
21+
| - help: consider changing this to be mutable: `mut y`
22+
LL | //~^ consider changing this to `mut y`
2023
LL | y //~ error: cannot borrow immutable local variable `y` as mutable
2124
| ^ cannot borrow as mutable
2225

src/test/ui/borrowck/issue-45983.nll.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ error[E0594]: cannot assign to immutable item `x`
1414
--> $DIR/issue-45983.rs:17:18
1515
|
1616
LL | give_any(|y| x = Some(y));
17-
| ^^^^^^^^^^^ cannot mutate
18-
|
19-
= note: the value which is causing this path not to be mutable is...: `x`
17+
| ^^^^^^^^^^^ cannot assign
2018

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

src/test/ui/borrowck/mut-borrow-of-mut-ref.nll.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
error[E0596]: cannot borrow immutable item `b` as mutable
22
--> $DIR/mut-borrow-of-mut-ref.rs:18:7
33
|
4+
LL | fn f(b: &mut i32) {
5+
| - help: consider changing this to be mutable: `mut b`
46
LL | g(&mut b) //~ ERROR cannot borrow
57
| ^^^^^^ cannot borrow as mutable
68

src/test/ui/codemap_tests/huge_multispan_highlight.nll.stderr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
error[E0596]: cannot borrow immutable item `x` as mutable
22
--> $DIR/huge_multispan_highlight.rs:100:13
33
|
4+
LL | let x = "foo";
5+
| - help: consider changing this to be mutable: `mut x`
6+
...
47
LL | let y = &mut x; //~ ERROR cannot borrow
58
| ^^^^^^ cannot borrow as mutable
69

src/test/ui/did_you_mean/issue-31424.nll.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ LL | (&mut self).bar(); //~ ERROR cannot borrow
77
error[E0596]: cannot borrow immutable item `self` as mutable
88
--> $DIR/issue-31424.rs:23:9
99
|
10+
LL | fn bar(self: &mut Self) {
11+
| ---- help: consider changing this to be mutable: `mut self`
1012
LL | (&mut self).bar(); //~ ERROR cannot borrow
1113
| ^^^^^^^^^^^ cannot borrow as mutable
1214

src/test/ui/did_you_mean/issue-34126.nll.stderr

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ error[E0596]: cannot borrow immutable item `self` as mutable
22
--> $DIR/issue-34126.rs:16:18
33
|
44
LL | self.run(&mut self); //~ ERROR cannot borrow
5-
| ^^^^^^^^^ cannot borrow as mutable
5+
| ^^^^^^^^^
6+
| |
7+
| cannot borrow as mutable
8+
| try removing `&mut` here
69

710
error[E0502]: cannot borrow `self` as mutable because it is also borrowed as immutable
811
--> $DIR/issue-34126.rs:16:18

src/test/ui/did_you_mean/issue-34337.nll.stderr

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ error[E0596]: cannot borrow immutable item `key` as mutable
22
--> $DIR/issue-34337.rs:16:9
33
|
44
LL | get(&mut key); //~ ERROR cannot borrow
5-
| ^^^^^^^^ cannot borrow as mutable
5+
| ^^^^^^^^
6+
| |
7+
| cannot borrow as mutable
8+
| try removing `&mut` here
69

710
error: aborting due to previous error
811

src/test/ui/did_you_mean/issue-35937.nll.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
error[E0596]: cannot borrow immutable item `f.v` as mutable
22
--> $DIR/issue-35937.rs:17:5
33
|
4+
LL | let f = Foo { v: Vec::new() };
5+
| - help: consider changing this to be mutable: `mut f`
46
LL | f.v.push("cat".to_string()); //~ ERROR cannot borrow
57
| ^^^ cannot borrow as mutable
6-
|
7-
= note: the value which is causing this path not to be mutable is...: `f`
88

99
error[E0384]: cannot assign twice to immutable variable `s.x`
1010
--> $DIR/issue-35937.rs:26:5

src/test/ui/did_you_mean/issue-37139.nll.stderr

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ error[E0596]: cannot borrow immutable item `x` as mutable
22
--> $DIR/issue-37139.rs:22:18
33
|
44
LL | test(&mut x); //~ ERROR cannot borrow immutable
5-
| ^^^^^^ cannot borrow as mutable
5+
| ^^^^^^
6+
| |
7+
| cannot borrow as mutable
8+
| try removing `&mut` here
69

710
error: aborting due to previous error
811

src/test/ui/did_you_mean/issue-38147-1.nll.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
error[E0596]: cannot borrow immutable item `*self.s` as mutable
22
--> $DIR/issue-38147-1.rs:27:9
33
|
4+
LL | fn f(&self) {
5+
| ----- help: consider changing this to be a mutable reference: `&mut Foo<'_>`
46
LL | self.s.push('x'); //~ ERROR cannot borrow data mutably
5-
| ^^^^^^ cannot borrow as mutable
6-
|
7-
= note: the value which is causing this path not to be mutable is...: `*self`
7+
| ^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable
88

99
error: aborting due to previous error
1010

src/test/ui/did_you_mean/issue-38147-4.nll.stderr

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

99
error: aborting due to previous error
1010

src/test/ui/did_you_mean/issue-39544.nll.stderr

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,100 @@
11
error[E0596]: cannot borrow immutable item `z.x` as mutable
22
--> $DIR/issue-39544.rs:21:13
33
|
4+
LL | let z = Z { x: X::Y };
5+
| - help: consider changing this to be mutable: `mut z`
46
LL | let _ = &mut z.x; //~ ERROR cannot borrow
57
| ^^^^^^^^ cannot borrow as mutable
6-
|
7-
= note: the value which is causing this path not to be mutable is...: `z`
88

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

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

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

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

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

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

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

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

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

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

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

9599
error: aborting due to 12 previous errors
96100

src/test/ui/did_you_mean/issue-40823.nll.stderr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
error[E0596]: cannot borrow immutable item `*buf` as mutable
22
--> $DIR/issue-40823.rs:13:5
33
|
4+
LL | let mut buf = &[1, 2, 3, 4];
5+
| ------------- help: consider changing this to be a mutable reference: `&mut [1, 2, 3, 4]`
46
LL | buf.iter_mut(); //~ ERROR cannot borrow immutable borrowed content
5-
| ^^^ cannot borrow as mutable
7+
| ^^^ `buf` is a `&` reference, so the data it refers to cannot be borrowed as mutable
68

79
error: aborting due to previous error
810

src/test/ui/error-codes/E0389.nll.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0594]: cannot assign to data in a `&` reference
1+
error[E0594]: cannot assign to `fancy_ref.num` which is behind a `&` reference
22
--> $DIR/E0389.rs:18:5
33
|
44
LL | let fancy_ref = &(&mut fancy);

src/test/ui/issue-36400.nll.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
error[E0596]: cannot borrow immutable item `*x` as mutable
22
--> $DIR/issue-36400.rs:15:7
33
|
4+
LL | let x = Box::new(3);
5+
| - help: consider changing this to be mutable: `mut x`
46
LL | f(&mut *x); //~ ERROR cannot borrow immutable
57
| ^^^^^^^ cannot borrow as mutable
6-
|
7-
= note: the value which is causing this path not to be mutable is...: `x`
88

99
error: aborting due to previous error
1010

src/test/ui/lifetime-errors/ex3-both-anon-regions-using-fn-items.nll.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ LL | y.push(z); //~ ERROR lifetime mismatch
1515
error[E0596]: cannot borrow immutable item `y` as mutable
1616
--> $DIR/ex3-both-anon-regions-using-fn-items.rs:11:3
1717
|
18+
LL | fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) {
19+
| - help: consider changing this to be mutable: `mut y`
1820
LL | y.push(z); //~ ERROR lifetime mismatch
1921
| ^ cannot borrow as mutable
2022

src/test/ui/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ LL | y.push(z); //~ ERROR lifetime mismatch
1515
error[E0596]: cannot borrow immutable item `y` as mutable
1616
--> $DIR/ex3-both-anon-regions-using-trait-objects.rs:11:3
1717
|
18+
LL | fn foo(x:Box<Fn(&u8, &u8)> , y: Vec<&u8>, z: &u8) {
19+
| - help: consider changing this to be mutable: `mut y`
1820
LL | y.push(z); //~ ERROR lifetime mismatch
1921
| ^ cannot borrow as mutable
2022

src/test/ui/macros/span-covering-argument-1.nll.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
error[E0596]: cannot borrow immutable item `foo` as mutable
22
--> $DIR/span-covering-argument-1.rs:15:14
33
|
4+
LL | let $s = 0;
5+
| -- help: consider changing this to be mutable: `mut foo`
46
LL | *&mut $s = 0;
57
| ^^^^^^^ cannot borrow as mutable
68
...

src/test/ui/nll/issue-47388.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0594]: cannot assign to data in a `&` reference
1+
error[E0594]: cannot assign to `fancy_ref.num` which is behind a `&` reference
22
--> $DIR/issue-47388.rs:18:5
33
|
44
LL | let fancy_ref = &(&mut fancy);

src/test/ui/rfc-2005-default-binding-mode/enum.nll.stderr

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,20 @@
1-
error[E0594]: cannot assign to data in a `&` reference
1+
error[E0594]: cannot assign to `*x` which is behind a `&` reference
22
--> $DIR/enum.rs:19:5
33
|
4-
LL | let Wrap(x) = &Wrap(3);
5-
| - help: consider changing this to be a mutable reference: `&mut`
64
LL | *x += 1; //~ ERROR cannot assign to immutable
7-
| ^^^^^^^
5+
| ^^^^^^^ cannot assign
86

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

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

2519
error: aborting due to 3 previous errors
2620

src/test/ui/rfc-2005-default-binding-mode/explicit-mut.nll.stderr

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,20 @@
1-
error[E0594]: cannot assign to data in a `&` reference
1+
error[E0594]: cannot assign to `*n` which is behind a `&` reference
22
--> $DIR/explicit-mut.rs:17:13
33
|
4-
LL | Some(n) => {
5-
| - help: consider changing this to be a mutable reference: `&mut`
64
LL | *n += 1; //~ ERROR cannot assign to immutable
7-
| ^^^^^^^
5+
| ^^^^^^^ cannot assign
86

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

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

2519
error: aborting due to 3 previous errors
2620

0 commit comments

Comments
 (0)