Skip to content

Commit a06b243

Browse files
committed
Update tests for new NLL mutability errors
1 parent 13b5f69 commit a06b243

File tree

52 files changed

+1128
-88
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1128
-88
lines changed

src/test/compile-fail/E0594.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ static NUM: i32 = 18;
1515

1616
fn main() {
1717
NUM = 20; //[ast]~ ERROR E0594
18-
//[mir]~^ ERROR cannot assign to immutable item `NUM`
18+
//[mir]~^ ERROR cannot assign to immutable static item `NUM`
1919
}

src/test/compile-fail/borrowck/borrowck-assign-to-constants.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ static foo: isize = 5;
1616
fn main() {
1717
// assigning to various global constants
1818
foo = 6; //[ast]~ ERROR cannot assign to immutable static item
19-
//[mir]~^ ERROR cannot assign to immutable item `foo`
19+
//[mir]~^ ERROR cannot assign to immutable static item `foo`
2020
}

src/test/compile-fail/cannot-mutate-captured-non-mut-var.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ fn main() {
2222
let x = 1;
2323
to_fn_once(move|| { x = 2; });
2424
//[ast]~^ ERROR: cannot assign to immutable captured outer variable
25-
//[mir]~^^ ERROR: cannot assign to immutable item `x`
25+
//[mir]~^^ ERROR: cannot assign to `x`, as it is not declared as mutable
2626

2727
let s = std::io::stdin();
2828
to_fn_once(move|| { s.read_to_end(&mut Vec::new()); });
2929
//[ast]~^ ERROR: cannot borrow immutable captured outer variable
30-
//[mir]~^^ ERROR: cannot borrow immutable item `s` as mutable
30+
//[mir]~^^ ERROR: cannot borrow `s` as mutable, as it is not declared as mutable
3131
}

src/test/compile-fail/nll/constant-thread-locals-issue-47053.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
static FOO: isize = 5;
1818

1919
fn main() {
20-
FOO = 6; //~ ERROR cannot assign to immutable item `FOO` [E0594]
20+
FOO = 6; //~ ERROR cannot assign to immutable static item `FOO` [E0594]
2121
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ LL | | x; //~ value moved here
1414
| |_____move out of `x` occurs here
1515
| borrow later used here
1616

17-
error[E0596]: cannot borrow immutable item `y` as mutable
17+
error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable
1818
--> $DIR/augmented-assignments.rs:30:5
1919
|
2020
LL | let y = Int(2);

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

+4-11
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,14 @@ LL | give_any(|y| x = Some(y));
1414
| |
1515
| lifetime `'1` appears in this argument
1616

17-
error[E0594]: cannot assign to immutable item `x`
17+
error[E0594]: cannot assign to `x`, as it is not declared as mutable
1818
--> $DIR/issue-45983.rs:17:18
1919
|
20-
LL | give_any(|y| x = Some(y));
21-
| ^^^^^^^^^^^ cannot assign
22-
23-
error[E0596]: cannot borrow immutable item `x` as mutable
24-
--> $DIR/issue-45983.rs:17:14
25-
|
2620
LL | let x = None;
2721
| - help: consider changing this to be mutable: `mut x`
2822
LL | give_any(|y| x = Some(y));
29-
| ^^^^^^^^^^^^^^^ cannot borrow as mutable
23+
| ^^^^^^^^^^^ cannot assign
3024

31-
error: aborting due to 3 previous errors
25+
error: aborting due to 2 previous errors
3226

33-
Some errors occurred: E0594, E0596.
34-
For more information about an error, try `rustc --explain E0594`.
27+
For more information about this error, try `rustc --explain E0594`.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0596]: cannot borrow immutable item `b` as mutable
1+
error[E0596]: cannot borrow `b` as mutable, as it is not declared as mutable
22
--> $DIR/mut-borrow-of-mut-ref.rs:18:7
33
|
44
LL | fn f(b: &mut i32) {

0 commit comments

Comments
 (0)