Skip to content

Commit 3805c54

Browse files
committed
test -- update tests with new error messages
1 parent 1bd7b18 commit 3805c54

Some content is hidden

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

49 files changed

+92
-85
lines changed

src/test/compile-fail/arc-rw-read-mode-shouldnt-escape.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn main() {
1515
let mut y = None;
1616
x.write_downgrade(|write_mode| {
1717
y = Some(x.downgrade(write_mode));
18-
//~^ ERROR cannot infer an appropriate lifetime
18+
//~^ ERROR cannot infer
1919
});
2020
y.unwrap();
2121
// Adding this line causes a method unification failure instead

src/test/compile-fail/borrowck-assign-comp-idx.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ fn b() {
3232

3333
let mut p = ~[1];
3434

35-
borrow(p, || {
36-
p[0] = 5; //~ ERROR cannot assign to
37-
});
35+
borrow(
36+
p,
37+
|| p[0] = 5); //~ ERROR cannot borrow `p` as mutable
3838
}
3939

4040
fn c() {

src/test/compile-fail/borrowck-autoref-3261.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ impl X {
2121

2222
fn main() {
2323
let mut x = X(Right(main));
24-
(&mut x).with(|opt| {
25-
match opt {
26-
&Right(ref f) => {
27-
x = X(Left((0,0))); //~ ERROR cannot assign to `x`
28-
(*f)()
29-
},
30-
_ => fail!()
31-
}
32-
})
24+
(&mut x).with(
25+
|opt| { //~ ERROR cannot borrow `x` as mutable more than once at a time
26+
match opt {
27+
&Right(ref f) => {
28+
x = X(Left((0,0)));
29+
(*f)()
30+
},
31+
_ => fail!()
32+
}
33+
})
3334
}

src/test/compile-fail/borrowck-borrow-mut-object-twice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ trait Foo {
1818

1919
fn test(x: &mut Foo) {
2020
let _y = x.f1();
21-
x.f2(); //~ ERROR cannot borrow `*x` because it is already borrowed as mutable
21+
x.f2(); //~ ERROR cannot borrow `*x` as mutable
2222
}
2323

2424
fn main() {}

src/test/compile-fail/borrowck-insert-during-each.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ impl Foo {
2323
}
2424

2525
fn bar(f: &mut Foo) {
26-
f.foo(|a| {
27-
f.n.insert(*a); //~ ERROR cannot borrow
28-
})
26+
f.foo(
27+
|a| { //~ ERROR closure requires unique access to `f`
28+
f.n.insert(*a);
29+
})
2930
}
3031

3132
fn main() {

src/test/compile-fail/borrowck-loan-blocks-move-cc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ fn box_imm() {
2121
info!("v={}", *v);
2222
//~^ ERROR cannot move `v` into closure
2323
});
24+
}
2425

26+
fn box_imm_explicit() {
2527
let v = ~3;
2628
let _w = &v;
2729
task::spawn(proc() {

src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ fn borrow(v: &int, f: |x: &int|) {
1414

1515
fn box_imm() {
1616
let mut v = ~3;
17-
borrow(v, |w| {
18-
v = ~4; //~ ERROR cannot assign to `v` because it is borrowed
19-
assert_eq!(*v, 3);
20-
assert_eq!(*w, 4);
21-
})
17+
borrow(v,
18+
|w| { //~ ERROR cannot borrow `v` as mutable
19+
v = ~4;
20+
assert_eq!(*v, 3);
21+
assert_eq!(*w, 4);
22+
})
2223
}
2324

2425
fn main() {

src/test/compile-fail/borrowck-loan-rcvr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ fn a() {
3232
p.impurem();
3333

3434
// But in this case we do not honor the loan:
35-
p.blockm(|| {
36-
p.x = 10; //~ ERROR cannot assign
35+
p.blockm(|| { //~ ERROR cannot borrow `p` as mutable
36+
p.x = 10;
3737
})
3838
}
3939

src/test/compile-fail/borrowck-loan-vec-content.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ fn has_mut_vec_and_does_not_try_to_change_it() {
2323

2424
fn has_mut_vec_but_tries_to_change_it() {
2525
let mut v = ~[1, 2, 3];
26-
takes_imm_elt(&v[0], || {
27-
v[1] = 4; //~ ERROR cannot assign
28-
})
26+
takes_imm_elt(
27+
&v[0],
28+
|| { //~ ERROR cannot borrow `v` as mutable
29+
v[1] = 4;
30+
})
2931
}
3032

3133
fn main() {

src/test/compile-fail/borrowck-move-by-capture.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@
99
// except according to those terms.
1010

1111
pub fn main() {
12-
// FIXME(#2202) - Due to the way that borrowck treats closures,
13-
// you get two error reports here.
1412
let bar = ~3;
15-
let _g = || { //~ ERROR capture of moved value
16-
let _h: proc() -> int = proc() *bar; //~ ERROR capture of moved value
13+
let _g = || {
14+
let _h: proc() -> int = proc() *bar; //~ ERROR cannot move out of captured outer variable
1715
};
1816
}

0 commit comments

Comments
 (0)