Skip to content

Commit dd74af1

Browse files
committed
---
yaml --- r: 63867 b: refs/heads/snap-stage3 c: d7544fe h: refs/heads/master i: 63865: 90689e7 63863: 359d100 v: v3
1 parent 48fd56f commit dd74af1

File tree

3 files changed

+89
-1
lines changed

3 files changed

+89
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: d4722e53332a854228a2db6a682da5e0017fe73e
4+
refs/heads/snap-stage3: d7544fe987104ad0a82b1929b819cfd7e2321bb2
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Tests correct kind-checking of the reason stack closures without the :Copy
12+
// bound must be noncopyable. For details see
13+
// http://smallcultfollowing.com/babysteps/blog/2013/04/30/the-case-of-the-recurring-closure/
14+
15+
struct R<'self> {
16+
// This struct is needed to create the
17+
// otherwise infinite type of a fn that
18+
// accepts itself as argument:
19+
c: &'self fn:Copy(&R, bool)
20+
}
21+
22+
fn innocent_looking_victim() {
23+
let mut x = Some(~"hello");
24+
do conspirator |f, writer| {
25+
if writer {
26+
x = None; //~ ERROR cannot implicitly borrow
27+
} else {
28+
match x {
29+
Some(ref msg) => {
30+
(f.c)(f, true);
31+
println(fmt!("%?", msg));
32+
},
33+
None => fail!("oops"),
34+
}
35+
}
36+
}
37+
}
38+
39+
fn conspirator(f: &fn:Copy(&R, bool)) {
40+
let r = R {c: f};
41+
f(&r, false)
42+
}
43+
44+
fn main() { innocent_looking_victim() }
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Tests correct kind-checking of the reason stack closures without the :Copy
12+
// bound must be noncopyable. For details see
13+
// http://smallcultfollowing.com/babysteps/blog/2013/04/30/the-case-of-the-recurring-closure/
14+
15+
struct R<'self> {
16+
// This struct is needed to create the
17+
// otherwise infinite type of a fn that
18+
// accepts itself as argument:
19+
c: &'self fn(&R, bool)
20+
}
21+
22+
fn innocent_looking_victim() {
23+
let mut x = Some(~"hello");
24+
do conspirator |f, writer| {
25+
if writer {
26+
x = None;
27+
} else {
28+
match x {
29+
Some(ref msg) => {
30+
(f.c)(f, true);
31+
println(fmt!("%?", msg));
32+
},
33+
None => fail!("oops"),
34+
}
35+
}
36+
}
37+
}
38+
39+
fn conspirator(f: &fn(&R, bool)) {
40+
let r = R {c: f};
41+
f(&r, false) //~ ERROR use of moved value
42+
}
43+
44+
fn main() { innocent_looking_victim() }

0 commit comments

Comments
 (0)