Skip to content

Commit efa2252

Browse files
committed
add a test that current fails b/c we do not preserve boxes
1 parent be48cd8 commit efa2252

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// compile-flags:--borrowck=err
2+
// exec-env:RUST_POISON_ON_FREE=1
3+
4+
fn borrow(x: &int, f: fn(x: &int)) {
5+
let before = *x;
6+
f(x);
7+
let after = *x;
8+
assert before == after;
9+
}
10+
11+
fn main() {
12+
let mut x = @3;
13+
borrow(x) {|b_x|
14+
assert *b_x == 3;
15+
assert ptr::addr_of(*x) == ptr::addr_of(*b_x);
16+
x = @22;
17+
18+
#debug["ptr::addr_of(*b_x) = %x", ptr::addr_of(*b_x) as uint];
19+
assert *b_x == 3;
20+
assert ptr::addr_of(*x) != ptr::addr_of(*b_x);
21+
}
22+
}

0 commit comments

Comments
 (0)