Skip to content

Commit fdb9625

Browse files
committed
---
yaml --- r: 14567 b: refs/heads/try c: 072b015 h: refs/heads/master i: 14565: ff779b9 14563: b63ff0b 14559: 1878402 v: v3
1 parent 4c485a9 commit fdb9625

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 1471b1f3ffd71eda0511df7ec6a9a0b94b55e958
5+
refs/heads/try: 072b0155151329b323540d521bffe3eb49873799
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
fn main() {
2+
// Make sure closing over can be a last use
3+
let q = ~10;
4+
let addr = ptr::addr_of(*q);
5+
let f = fn@() -> *int { ptr::addr_of(*q) };
6+
assert addr == f();
7+
8+
// But only when it really is the last use
9+
let q = ~20;
10+
let f = fn@() -> *int { ptr::addr_of(*q) };
11+
assert ptr::addr_of(*q) != f();
12+
13+
// Ensure function arguments and box arguments interact sanely.
14+
fn call_me(x: fn() -> int, y: ~int) { assert x() == *y; }
15+
let q = ~30;
16+
call_me({|| *q}, q);
17+
18+
// Check that no false positives are found in loops.
19+
let q = ~40, p = 10;
20+
while true {
21+
let i = q;
22+
p += *i;
23+
if p > 100 { break; }
24+
}
25+
26+
// Verify that blocks can't interfere with each other.
27+
fn two_blocks(a: fn(), b: fn()) { a(); b(); a(); b(); }
28+
let q = ~50;
29+
two_blocks({|| let a = q; assert *a == 50;},
30+
{|| let a = q; assert *a == 50;});
31+
}

0 commit comments

Comments
 (0)