Skip to content

Commit 94009de

Browse files
author
Jorge Aparicio
committed
---
yaml --- r: 171243 b: refs/heads/batch c: 7d5b045 h: refs/heads/master i: 171241: 3f8d764 171239: 0d6defd v: v3
1 parent 831d4ac commit 94009de

File tree

102 files changed

+196
-613
lines changed

Some content is hidden

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

102 files changed

+196
-613
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2929
refs/heads/issue-18208-method-dispatch-2: 9e1eae4fb9b6527315b4441cf8a0f5ca911d1671
3030
refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3131
refs/heads/issue-18208-method-dispatch-3-quick-reject: 2009f85b9f99dedcec4404418eda9ddba90258a2
32-
refs/heads/batch: ca17d0812686012307e364a4dce7b84af6886f91
32+
refs/heads/batch: 7d5b0454e9ee5ea9b99c6315174b498df60a7bb5
3333
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: 496dc4eae7de9d14cd49511a9acfbf5f11ae6c3f
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928

branches/batch/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| {

branches/batch/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
}

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

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

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

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

branches/batch/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

branches/batch/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!()

branches/batch/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`

branches/batch/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
}

branches/batch/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() {

branches/batch/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
}

branches/batch/src/test/compile-fail/borrowck-closures-two-mut.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
fn a() {
1717
let mut x = 3i;
18-
let c1 = || x = 4;
19-
let c2 = || x = 5; //~ ERROR cannot borrow `x` as mutable more than once
18+
let c1 = |&mut:| x = 4;
19+
let c2 = |&mut:| x = 5; //~ ERROR cannot borrow `x` as mutable more than once
2020
}
2121

2222
fn set(x: &mut int) {
@@ -25,20 +25,20 @@ fn set(x: &mut int) {
2525

2626
fn b() {
2727
let mut x = 3i;
28-
let c1 = || set(&mut x);
29-
let c2 = || set(&mut x); //~ ERROR cannot borrow `x` as mutable more than once
28+
let c1 = |&mut:| set(&mut x);
29+
let c2 = |&mut:| set(&mut x); //~ ERROR cannot borrow `x` as mutable more than once
3030
}
3131

3232
fn c() {
3333
let mut x = 3i;
34-
let c1 = || x = 5;
35-
let c2 = || set(&mut x); //~ ERROR cannot borrow `x` as mutable more than once
34+
let c1 = |&mut:| x = 5;
35+
let c2 = |&mut:| set(&mut x); //~ ERROR cannot borrow `x` as mutable more than once
3636
}
3737

3838
fn d() {
3939
let mut x = 3i;
40-
let c1 = || x = 5;
41-
let c2 = || { let _y = || set(&mut x); }; // (nested closure)
40+
let c1 = |&mut:| x = 5;
41+
let c2 = |&mut:| { let _y = |&mut:| set(&mut x); }; // (nested closure)
4242
//~^ ERROR cannot borrow `x` as mutable more than once
4343
}
4444

@@ -48,8 +48,8 @@ fn g() {
4848
}
4949

5050
let mut x = box Foo { f: box 3 };
51-
let c1 = || set(&mut *x.f);
52-
let c2 = || set(&mut *x.f);
51+
let c1 = |&mut:| set(&mut *x.f);
52+
let c2 = |&mut:| set(&mut *x.f);
5353
//~^ ERROR cannot borrow `x` as mutable more than once
5454
}
5555

branches/batch/src/test/compile-fail/borrowck-closures-unique-imm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub fn main() {
1616
let mut this = &mut Foo {
1717
x: 1,
1818
};
19-
let r = || {
19+
let mut r = |&mut:| {
2020
let p = &this.x;
2121
&mut this.x; //~ ERROR cannot borrow
2222
};

branches/batch/src/test/compile-fail/borrowck-closures-unique.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,27 @@ fn set(x: &mut int) -> int {
2323
}
2424

2525
fn a(x: &mut int) {
26-
let c1 = || get(x);
27-
let c2 = || get(x);
26+
let c1 = |&mut:| get(x);
27+
let c2 = |&mut:| get(x);
2828
}
2929

3030
fn b(x: &mut int) {
31-
let c1 = || get(x);
32-
let c2 = || set(x); //~ ERROR closure requires unique access to `x`
31+
let c1 = |&mut:| get(x);
32+
let c2 = |&mut:| set(x); //~ ERROR closure requires unique access to `x`
3333
}
3434

3535
fn c(x: &mut int) {
36-
let c1 = || get(x);
37-
let c2 = || { get(x); set(x); }; //~ ERROR closure requires unique access to `x`
36+
let c1 = |&mut:| get(x);
37+
let c2 = |&mut:| { get(x); set(x); }; //~ ERROR closure requires unique access to `x`
3838
}
3939

4040
fn d(x: &mut int) {
41-
let c1 = || set(x);
42-
let c2 = || set(x); //~ ERROR closure requires unique access to `x`
41+
let c1 = |&mut:| set(x);
42+
let c2 = |&mut:| set(x); //~ ERROR closure requires unique access to `x`
4343
}
4444

4545
fn e(x: &mut int) {
46-
let c1: || = || x = panic!(); //~ ERROR closure cannot assign to immutable local variable
46+
let c1 = |&mut:| x = panic!(); //~ ERROR closure cannot assign to immutable local variable
4747
}
4848

4949
fn main() {

branches/batch/src/test/compile-fail/borrowck-closures-use-after-free.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl Drop for Foo {
2525

2626
fn main() {
2727
let mut ptr = box Foo { x: 0 };
28-
let test = |foo: &Foo| {
28+
let mut test = |&mut: foo: &Foo| {
2929
ptr = box Foo { x: ptr.x + 1 };
3030
};
3131
test(&*ptr); //~ ERROR cannot borrow `*ptr`

branches/batch/src/test/compile-fail/borrowck-init-in-called-fn-expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
fn main() {
12-
let j: || -> int = || {
12+
let j = |&:| -> int {
1313
let i: int;
1414
i //~ ERROR use of possibly uninitialized variable: `i`
1515
};

branches/batch/src/test/compile-fail/borrowck-init-in-fn-expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
fn main() {
12-
let f: || -> int = || {
12+
let f = |&:| -> int {
1313
let i: int;
1414
i //~ ERROR use of possibly uninitialized variable: `i`
1515
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct Foo {
1616
}
1717

1818
impl Foo {
19-
pub fn foo(&mut self, fun: |&int|) {
19+
pub fn foo<F>(&mut self, mut fun: F) where F: FnMut(&int) {
2020
for f in self.n.iter() {
2121
fun(f);
2222
}

0 commit comments

Comments
 (0)