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
}

src/test/compile-fail/borrowck-object-lifetime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn borrowed_receiver<'a>(x: &'a Foo) -> &'a () {
1717
}
1818

1919
fn owned_receiver(x: ~Foo) -> &() {
20-
x.borrowed() //~ ERROR borrowed value does not live long enough
20+
x.borrowed() //~ ERROR `*x` does not live long enough
2121
}
2222

2323
fn mut_owned_receiver(mut x: ~Foo) {

src/test/compile-fail/borrowck-vec-pattern-move-tail.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ fn main() {
1414
[1, 2, ..tail] => tail,
1515
_ => unreachable!()
1616
};
17-
a[0] = 0; //~ ERROR cannot assign to `a[]` because it is borrowed
17+
a[0] = 0; //~ ERROR cannot assign to `a[..]` because it is borrowed
1818
t[0];
1919
}

src/test/compile-fail/borrowck-vec-pattern-nesting.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn a() {
1212
let mut vec = ~[~1, ~2, ~3];
1313
match vec {
1414
[~ref _a] => {
15-
vec[0] = ~4; //~ ERROR cannot assign to `(*vec)[]` because it is borrowed
15+
vec[0] = ~4; //~ ERROR cannot assign
1616
}
1717
_ => fail!("foo")
1818
}
@@ -22,7 +22,7 @@ fn b() {
2222
let mut vec = ~[~1, ~2, ~3];
2323
match vec {
2424
[.._b] => {
25-
vec[0] = ~4; //~ ERROR cannot assign to `(*vec)[]` because it is borrowed
25+
vec[0] = ~4; //~ ERROR cannot assign
2626
}
2727
}
2828
}

src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
fn a() -> &int {
1212
let vec = ~[1, 2, 3, 4];
1313
let tail = match vec {
14-
[_a, ..tail] => &tail[0], //~ ERROR borrowed value does not live long enough
14+
[_a, ..tail] => &tail[0], //~ ERROR `vec[..]` does not live long enough
1515
_ => fail!("foo")
1616
};
1717
tail

src/test/compile-fail/issue-3154.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct thing<'a, Q> {
1313
}
1414

1515
fn thing<Q>(x: &Q) -> thing<Q> {
16-
thing{ x: x } //~ ERROR cannot infer an appropriate lifetime
16+
thing{ x: x } //~ ERROR cannot infer
1717
}
1818

1919
fn main() {

src/test/compile-fail/issue-4335.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
fn id<T>(t: T) -> T { t }
1212

1313
fn f<'r, T>(v: &'r T) -> 'r || -> T {
14-
id(|| *v) //~ ERROR cannot infer an appropriate lifetime
14+
id(|| *v) //~ ERROR cannot infer
1515
}
1616

1717
fn main() {

src/test/compile-fail/kindck-owned-trait-contains.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn main() {
2424

2525
let y = {
2626
let tmp0 = 3;
27-
let tmp1 = &tmp0; //~ ERROR borrowed value does not live long enough
27+
let tmp1 = &tmp0; //~ ERROR `tmp0` does not live long enough
2828
repeater(tmp1)
2929
};
3030
assert!(3 == *(y.get()));

src/test/compile-fail/moves-based-on-type-access-to-field.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ fn touch<A>(_a: &A) {}
1717

1818
fn f10() {
1919
let x = Foo { f: ~"hi", y: 3 };
20-
consume(x.f); //~ NOTE `x.f` moved here
20+
consume(x.f);
2121
touch(&x.y); //~ ERROR use of partially moved value: `x`
2222
}
2323

2424
fn f20() {
2525
let x = ~[~"hi"];
26-
consume(x[0]); //~ NOTE `(*x)[]` moved here
26+
consume(x[0]);
2727
touch(&x[0]); //~ ERROR use of partially moved value: `x`
2828
}
2929

src/test/compile-fail/mut-cant-alias.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ fn main() {
1414
let m = RefCell::new(0);
1515
let mut b = m.borrow_mut();
1616
let b1 = b.get();
17-
let b2 = b.get(); //~ ERROR cannot borrow `b` because it is already borrowed as mutable
17+
let b2 = b.get(); //~ ERROR cannot borrow
1818
}

src/test/compile-fail/mut-ptr-cant-outlive-ref.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ fn main() {
1515
let p;
1616
{
1717
let b = m.borrow();
18-
p = b.get(); //~ ERROR borrowed value does not live long enough
18+
p = b.get(); //~ ERROR `b` does not live long enough
1919
}
2020
}

src/test/compile-fail/regionck-closure-lifetimes.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn env<'a>(_: &'a uint, blk: |p: 'a |||) {
1818

1919
let mut state = 0;
2020
let statep = &mut state;
21-
blk(|| *statep = 1); //~ ERROR cannot infer an appropriate lifetime
21+
blk(|| *statep = 1); //~ ERROR cannot infer
2222
}
2323

2424
fn no_env_no_for<'a>(_: &'a uint, blk: |p: 'a |||) {
@@ -40,7 +40,7 @@ fn repeating_loop() {
4040
let state = 0;
4141

4242
loop {
43-
closure = || state; //~ ERROR cannot infer an appropriate lifetime
43+
closure = || state; //~ ERROR cannot infer
4444
break;
4545
}
4646

@@ -56,7 +56,7 @@ fn repeating_while() {
5656
let state = 0;
5757

5858
while true {
59-
closure = || state; //~ ERROR cannot infer an appropriate lifetime
59+
closure = || state; //~ ERROR cannot infer
6060
break;
6161
}
6262

src/test/compile-fail/regions-addr-of-arg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
// bounded by the current function call.
1313

1414
fn foo(a: int) {
15-
let _p: &'static int = &a; //~ ERROR borrowed value does not live long enough
15+
let _p: &'static int = &a; //~ ERROR `a` does not live long enough
1616
}
1717

1818
fn bar(a: int) {
1919
let _q: &int = &a;
2020
}
2121

2222
fn zed<'a>(a: int) -> &'a int {
23-
&a //~ ERROR borrowed value does not live long enough
23+
&a //~ ERROR `a` does not live long enough
2424
}
2525

2626
fn main() {

src/test/compile-fail/regions-addr-of-self.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ struct dog {
1414

1515
impl dog {
1616
pub fn chase_cat(&mut self) {
17-
let p: &'static mut uint = &mut self.cats_chased;
18-
//~^ ERROR cannot infer an appropriate lifetime
17+
let p: &'static mut uint = &mut self.cats_chased; //~ ERROR cannot infer
1918
*p += 1u;
2019
}
2120

src/test/compile-fail/regions-addr-of-upvar-self.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ struct dog {
1717
impl dog {
1818
pub fn chase_cat(&mut self) {
1919
let _f = || {
20-
let p: &'static mut uint = &mut self.food;
21-
//~^ ERROR cannot infer an appropriate lifetime
20+
let p: &'static mut uint = &mut self.food; //~ ERROR cannot infer
2221
*p = 3u;
2322
};
2423
}

src/test/compile-fail/regions-bounds.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ struct a_class<'a> { x:&'a int }
1717

1818
fn a_fn1<'a,'b>(e: an_enum<'a>) -> an_enum<'b> {
1919
return e; //~ ERROR mismatched types: expected `an_enum<'b>` but found `an_enum<'a>`
20-
//~^ ERROR cannot infer an appropriate lifetime
20+
//~^ ERROR cannot infer
2121
}
2222

2323
fn a_fn3<'a,'b>(e: a_class<'a>) -> a_class<'b> {
2424
return e; //~ ERROR mismatched types: expected `a_class<'b>` but found `a_class<'a>`
25-
//~^ ERROR cannot infer an appropriate lifetime
25+
//~^ ERROR cannot infer
2626
}
2727

2828
fn main() { }

src/test/compile-fail/regions-creating-enums3.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ enum ast<'a> {
1414
}
1515

1616
fn mk_add_bad1<'a,'b>(x: &'a ast<'a>, y: &'b ast<'b>) -> ast<'a> {
17-
add(x, y) //~ ERROR cannot infer an appropriate lifetime
17+
add(x, y) //~ ERROR cannot infer
1818
}
1919

2020
fn main() {

src/test/compile-fail/regions-creating-enums4.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ enum ast<'a> {
1414
}
1515

1616
fn mk_add_bad2<'a>(x: &'a ast<'a>, y: &'a ast<'a>, z: &ast) -> ast {
17-
add(x, y) //~ ERROR cannot infer an appropriate lifetime
17+
add(x, y) //~ ERROR cannot infer
1818
}
1919

2020
fn main() {

src/test/compile-fail/regions-escape-loop-via-variable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ fn main() {
1818

1919
loop {
2020
let x = 1 + *p;
21-
p = &x; //~ ERROR borrowed value does not live long enough
21+
p = &x; //~ ERROR `x` does not live long enough
2222
}
2323
}

src/test/compile-fail/regions-escape-loop-via-vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn broken() {
1414
let mut _y = ~[&mut x];
1515
while x < 10 {
1616
let mut z = x;
17-
_y.push(&mut z); //~ ERROR borrowed value does not live long enough
17+
_y.push(&mut z); //~ ERROR `z` does not live long enough
1818
x += 1; //~ ERROR cannot assign
1919
}
2020
}

src/test/compile-fail/regions-free-region-ordering-callee.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ fn ordering1<'a, 'b>(x: &'a &'b uint) -> &'a uint {
2020

2121
fn ordering2<'a, 'b>(x: &'a &'b uint, y: &'a uint) -> &'b uint {
2222
// However, it is not safe to assume that 'b <= 'a
23-
&*y //~ ERROR cannot infer an appropriate lifetime
23+
&*y //~ ERROR cannot infer
2424
}
2525

2626
fn ordering3<'a, 'b>(x: &'a uint, y: &'b uint) -> &'a &'b uint {
2727
// Do not infer an ordering from the return value.
2828
let z: &'b uint = &*x;
29-
//~^ ERROR cannot infer an appropriate lifetime
29+
//~^ ERROR cannot infer
3030
fail!();
3131
}
3232

src/test/compile-fail/regions-free-region-ordering-caller1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn call1<'a>(x: &'a uint) {
1818
let y: uint = 3;
1919
let z: &'a & uint = &(&y);
2020
//~^ ERROR borrowed value does not live long enough
21-
//~^^ ERROR borrowed value does not live long enough
21+
//~^^ ERROR `y` does not live long enough
2222
}
2323

2424
fn main() {}

src/test/compile-fail/regions-free-region-ordering-incorrect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl<'b, T> Node<'b, T> {
2424
fn get<'a>(&'a self) -> &'b T {
2525
match self.next {
2626
Some(ref next) => next.get(),
27-
None => &self.val //~ ERROR cannot infer an appropriate lifetime
27+
None => &self.val //~ ERROR cannot infer
2828
}
2929
}
3030
}

src/test/compile-fail/regions-freevar.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ fn wants_static_fn(_x: 'static ||) {}
1212

1313
fn main() {
1414
let i = 3;
15-
wants_static_fn(|| {
16-
//~^ ERROR cannot infer an appropriate lifetime due to conflicting requirements
15+
wants_static_fn(|| { //~ ERROR cannot infer
1716
info!("i={}", i);
1817
})
1918
}

0 commit comments

Comments
 (0)