Skip to content

Commit 7d5b045

Browse files
author
Jorge Aparicio
committed
fix cfail tests
1 parent ca17d08 commit 7d5b045

File tree

101 files changed

+195
-612
lines changed

Some content is hidden

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

101 files changed

+195
-612
lines changed

src/test/compile-fail/access-mode-in-closures.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
struct sty(Vec<int> );
1313

14-
fn unpack(_unpack: |v: &sty| -> Vec<int> ) {}
14+
fn unpack<F>(_unpack: F) where F: FnOnce(&sty) -> Vec<int> {}
1515

1616
fn main() {
1717
let _foo = unpack(|s| {

src/test/compile-fail/assign-to-method.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ fn cat(in_x : uint, in_y : int) -> cat {
2727

2828
fn main() {
2929
let nyan : cat = cat(52u, 99);
30-
nyan.speak = || println!("meow"); //~ ERROR attempted to take value of method
30+
nyan.speak = |&:| println!("meow"); //~ ERROR attempted to take value of method
3131
}

src/test/compile-fail/block-coerce-no-2.rs

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/test/compile-fail/block-coerce-no.rs

Lines changed: 0 additions & 26 deletions
This file was deleted.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn a() {
2424
println!("{}", *q);
2525
}
2626

27-
fn borrow(_x: &[int], _f: ||) {}
27+
fn borrow<F>(_x: &[int], _f: F) where F: FnOnce() {}
2828

2929
fn b() {
3030
// here we alias the mutable vector into an imm slice and try to

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ enum Either<T, U> { Left(T), Right(U) }
1313
struct X(Either<(uint,uint), fn()>);
1414

1515
impl X {
16-
pub fn with(&self, blk: |x: &Either<(uint,uint), fn()>|) {
16+
pub fn with<F>(&self, blk: F) where F: FnOnce(&Either<(uint, uint), fn()>) {
1717
let X(ref e) = *self;
1818
blk(e)
1919
}
@@ -25,7 +25,7 @@ fn main() {
2525
|opt| { //~ ERROR cannot borrow `x` as mutable more than once at a time
2626
match opt {
2727
&Either::Right(ref f) => {
28-
x = X(Either::Left((0,0)));
28+
x = X(Either::Left((0, 0)));
2929
(*f)()
3030
},
3131
_ => panic!()

src/test/compile-fail/borrowck-block-unint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
fn force(f: ||) { f(); }
11+
fn force<F>(f: F) where F: FnOnce() { f(); }
1212
fn main() {
1313
let x: int;
1414
force(|| { //~ ERROR capture of possibly uninitialized variable: `x`

src/test/compile-fail/borrowck-call-is-borrow-issue-12224.rs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,53 +10,54 @@
1010

1111
// Ensure that invoking a closure counts as a unique immutable borrow
1212

13+
#![feature(unboxed_closures)]
1314

14-
type Fn<'a> = ||:'a;
15+
type Fn<'a> = Box<FnMut() + 'a>;
1516

1617
struct Test<'a> {
17-
f: ||: 'a
18+
f: Box<FnMut() + 'a>
1819
}
1920

20-
fn call(f: |Fn|) {
21-
f(|| {
22-
//~^ ERROR: closure requires unique access to `f` but it is already borrowed
23-
f(|| {})
21+
fn call<F>(mut f: F) where F: FnMut(Fn) {
22+
f(box || {
23+
//~^ ERROR: cannot borrow `f` as mutable more than once
24+
f(box || {})
2425
});
2526
}
2627

2728
fn test1() {
28-
call(|a| {
29-
a();
29+
call(|mut a| {
30+
a.call_mut(());
3031
});
3132
}
3233

33-
fn test2(f: &||) {
34-
(*f)(); //~ ERROR: closure invocation in a `&` reference
34+
fn test2<F>(f: &F) where F: FnMut() {
35+
(*f)(); //~ ERROR: cannot borrow immutable dereference of `&`-pointer `*f` as mutable
3536
}
3637

37-
fn test3(f: &mut ||) {
38+
fn test3<F>(f: &mut F) where F: FnMut() {
3839
(*f)();
3940
}
4041

4142
fn test4(f: &Test) {
42-
(f.f)() //~ ERROR: closure invocation in a `&` reference
43+
f.f.call_mut(()) //~ ERROR: cannot borrow immutable dereference of `Box` `*f.f` as mutable
4344
}
4445

4546
fn test5(f: &mut Test) {
46-
(f.f)()
47+
f.f.call_mut(())
4748
}
4849

4950
fn test6() {
50-
let f = || {};
51-
(|| {
51+
let mut f = |&mut:| {};
52+
(|&mut:| {
5253
f();
5354
})();
5455
}
5556

5657
fn test7() {
57-
fn foo(_: |g: |int|, b: int|) {}
58-
let f = |g: |int|, b: int| {};
59-
f(|a| { //~ ERROR: cannot borrow `f` as immutable because previous closure
58+
fn foo<F>(_: F) where F: FnMut(Box<FnMut(int)>, int) {}
59+
let mut f = |&mut: g: Box<FnMut(int)>, b: int| {};
60+
f(box |a| { //~ ERROR: cannot borrow `f` as immutable because it is also borrowed as mutable
6061
foo(f); //~ ERROR: cannot move out of captured outer variable
6162
}, 3);
6263
}

src/test/compile-fail/borrowck-closures-mut-and-imm.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,37 +22,37 @@ fn set(x: &mut int) {
2222

2323
fn a() {
2424
let mut x = 3i;
25-
let c1 = || x = 4;
26-
let c2 = || x * 5; //~ ERROR cannot borrow `x`
25+
let c1 = |&mut:| x = 4;
26+
let c2 = |&mut:| x * 5; //~ ERROR cannot borrow `x`
2727
}
2828

2929
fn b() {
3030
let mut x = 3i;
31-
let c1 = || set(&mut x);
32-
let c2 = || get(&x); //~ ERROR cannot borrow `x`
31+
let c1 = |&mut:| set(&mut x);
32+
let c2 = |&mut:| get(&x); //~ ERROR cannot borrow `x`
3333
}
3434

3535
fn c() {
3636
let mut x = 3i;
37-
let c1 = || set(&mut x);
38-
let c2 = || x * 5; //~ ERROR cannot borrow `x`
37+
let c1 = |&mut:| set(&mut x);
38+
let c2 = |&mut:| x * 5; //~ ERROR cannot borrow `x`
3939
}
4040

4141
fn d() {
4242
let mut x = 3i;
43-
let c2 = || x * 5;
43+
let c2 = |&mut:| x * 5;
4444
x = 5; //~ ERROR cannot assign
4545
}
4646

4747
fn e() {
4848
let mut x = 3i;
49-
let c1 = || get(&x);
49+
let c1 = |&mut:| get(&x);
5050
x = 5; //~ ERROR cannot assign
5151
}
5252

5353
fn f() {
5454
let mut x = box 3i;
55-
let c1 = || get(&*x);
55+
let c1 = |&mut:| get(&*x);
5656
*x = 5; //~ ERROR cannot assign
5757
}
5858

@@ -62,7 +62,7 @@ fn g() {
6262
}
6363

6464
let mut x = box Foo { f: box 3 };
65-
let c1 = || get(&*x.f);
65+
let c1 = |&mut:| get(&*x.f);
6666
*x.f = 5; //~ ERROR cannot assign to `*x.f`
6767
}
6868

@@ -72,8 +72,8 @@ fn h() {
7272
}
7373

7474
let mut x = box Foo { f: box 3 };
75-
let c1 = || get(&*x.f);
76-
let c2 = || *x.f = 5; //~ ERROR cannot borrow `x` as mutable
75+
let c1 = |&mut:| get(&*x.f);
76+
let c2 = |&mut:| *x.f = 5; //~ ERROR cannot borrow `x` as mutable
7777
}
7878

7979
fn main() {

src/test/compile-fail/borrowck-closures-mut-of-imm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ fn set(x: &mut int) {
2020
}
2121

2222
fn a(x: &int) {
23-
let c1 = || set(&mut *x);
23+
let c1 = |&mut:| set(&mut *x);
2424
//~^ ERROR cannot borrow
25-
let c2 = || set(&mut *x);
25+
let c2 = |&mut:| set(&mut *x);
2626
//~^ ERROR cannot borrow
2727
//~| ERROR closure requires unique access
2828
}

0 commit comments

Comments
 (0)