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

0 commit comments

Comments
 (0)