Skip to content

Commit 832bbcf

Browse files
committed
---
yaml --- r: 11561 b: refs/heads/master c: 072b015 h: refs/heads/master i: 11559: 4cc351f v: v3
1 parent aba0cc0 commit 832bbcf

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
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 1471b1f3ffd71eda0511df7ec6a9a0b94b55e958
2+
refs/heads/master: 072b0155151329b323540d521bffe3eb49873799
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
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)