Skip to content

Commit

Permalink
Update tests for new NLL mutability errors
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewjasper committed Jul 20, 2018
1 parent 13b5f69 commit a06b243
Show file tree
Hide file tree
Showing 52 changed files with 1,128 additions and 88 deletions.
2 changes: 1 addition & 1 deletion src/test/compile-fail/E0594.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ static NUM: i32 = 18;

fn main() {
NUM = 20; //[ast]~ ERROR E0594
//[mir]~^ ERROR cannot assign to immutable item `NUM`
//[mir]~^ ERROR cannot assign to immutable static item `NUM`
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ static foo: isize = 5;
fn main() {
// assigning to various global constants
foo = 6; //[ast]~ ERROR cannot assign to immutable static item
//[mir]~^ ERROR cannot assign to immutable item `foo`
//[mir]~^ ERROR cannot assign to immutable static item `foo`
}
4 changes: 2 additions & 2 deletions src/test/compile-fail/cannot-mutate-captured-non-mut-var.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ fn main() {
let x = 1;
to_fn_once(move|| { x = 2; });
//[ast]~^ ERROR: cannot assign to immutable captured outer variable
//[mir]~^^ ERROR: cannot assign to immutable item `x`
//[mir]~^^ ERROR: cannot assign to `x`, as it is not declared as mutable

let s = std::io::stdin();
to_fn_once(move|| { s.read_to_end(&mut Vec::new()); });
//[ast]~^ ERROR: cannot borrow immutable captured outer variable
//[mir]~^^ ERROR: cannot borrow immutable item `s` as mutable
//[mir]~^^ ERROR: cannot borrow `s` as mutable, as it is not declared as mutable
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
static FOO: isize = 5;

fn main() {
FOO = 6; //~ ERROR cannot assign to immutable item `FOO` [E0594]
FOO = 6; //~ ERROR cannot assign to immutable static item `FOO` [E0594]
}
2 changes: 1 addition & 1 deletion src/test/ui/augmented-assignments.nll.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ LL | | x; //~ value moved here
| |_____move out of `x` occurs here
| borrow later used here

error[E0596]: cannot borrow immutable item `y` as mutable
error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable
--> $DIR/augmented-assignments.rs:30:5
|
LL | let y = Int(2);
Expand Down
15 changes: 4 additions & 11 deletions src/test/ui/borrowck/issue-45983.nll.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,14 @@ LL | give_any(|y| x = Some(y));
| |
| lifetime `'1` appears in this argument

error[E0594]: cannot assign to immutable item `x`
error[E0594]: cannot assign to `x`, as it is not declared as mutable
--> $DIR/issue-45983.rs:17:18
|
LL | give_any(|y| x = Some(y));
| ^^^^^^^^^^^ 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
| ^^^^^^^^^^^ cannot assign

error: aborting due to 3 previous errors
error: aborting due to 2 previous errors

Some errors occurred: E0594, E0596.
For more information about an error, try `rustc --explain E0594`.
For more information about this error, try `rustc --explain E0594`.
2 changes: 1 addition & 1 deletion src/test/ui/borrowck/mut-borrow-of-mut-ref.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0596]: cannot borrow immutable item `b` as mutable
error[E0596]: cannot borrow `b` as mutable, as it is not declared as mutable
--> $DIR/mut-borrow-of-mut-ref.rs:18:7
|
LL | fn f(b: &mut i32) {
Expand Down
Loading

0 comments on commit a06b243

Please sign in to comment.