Skip to content

Commit 4f076b5

Browse files
committed
---
yaml --- r: 3176 b: refs/heads/master c: 5b34144 h: refs/heads/master v: v3
1 parent be3e04d commit 4f076b5

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: e7575b9f3a9a98ff107152971d36ab86e96cd8d8
2+
refs/heads/master: 5b341443da8a281e4ebd32a6a4da8b2f73c12f92
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// xfail-stage0
2+
// xfail-stage1
3+
// xfail-stage2
4+
// xfail-stage3
5+
6+
// works, but leaks in the compiler :(
7+
8+
import rusti::ivec_len;
9+
10+
native "rust-intrinsic" mod rusti {
11+
fn ivec_len[T](&T[] v) -> uint;
12+
}
13+
14+
fn main() {
15+
let int[] v = ~[];
16+
assert (ivec_len(v) == 0u); // zero-length
17+
auto x = ~[ 1, 2 ];
18+
assert (ivec_len(x) == 2u); // on stack
19+
auto y = ~[ 1, 2, 3, 4, 5 ];
20+
assert (ivec_len(y) == 5u); // on heap
21+
22+
v += ~[];
23+
assert (ivec_len(v) == 0u); // zero-length append
24+
x += ~[ 3 ];
25+
assert (ivec_len(x) == 3u); // on-stack append
26+
y += ~[ 6, 7, 8, 9 ];
27+
assert (ivec_len(y) == 9u); // on-heap append
28+
29+
auto vv = v + v;
30+
assert (ivec_len(vv) == 0u); // zero-length add
31+
auto xx = x + ~[ 4 ];
32+
assert (ivec_len(xx) == 4u); // on-stack add
33+
auto yy = y + ~[ 10, 11 ];
34+
assert (ivec_len(yy) == 11u); // on-heap add
35+
}
36+

0 commit comments

Comments
 (0)