File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed
branches/try/src/test/run-pass Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change 2
2
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5
- refs/heads/try: 1471b1f3ffd71eda0511df7ec6a9a0b94b55e958
5
+ refs/heads/try: 072b0155151329b323540d521bffe3eb49873799
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments