Skip to content

Commit 9d4f436

Browse files
Jakub Wieczorekgraydon
authored andcommitted
---
yaml --- r: 38072 b: refs/heads/try c: 6c83fe4 h: refs/heads/master v: v3
1 parent 4dae40f commit 9d4f436

File tree

5 files changed

+54
-1
lines changed

5 files changed

+54
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 09bb07bed9166105ea961a42b5fff7739ae0d2e9
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
5-
refs/heads/try: 6530fd340119362e346f28c03e1efc772c18fbba
5+
refs/heads/try: 6c83fe4c24b7c0e6c6ff6916c8b4a9d9973e46a9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
fn a() -> &int {
2+
let vec = [1, 2, 3, 4];
3+
let tail = match vec {
4+
[a, ..tail] => &tail[0], //~ ERROR illegal borrow
5+
_ => fail ~"foo"
6+
};
7+
move tail
8+
}
9+
10+
fn main() {
11+
let fifth = a();
12+
io::println(fmt!("%d", *fifth));
13+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
fn main() {
2+
let a = [mut 1, 2, 3, 4];
3+
let _ = match a {
4+
[1, 2, ..move tail] => tail,
5+
_ => core::util::unreachable()
6+
};
7+
a[0] = 0; //~ ERROR: use of moved variable
8+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
fn main() {
2+
let x = @[1, 2, 3];
3+
match x {
4+
[2, .._] => core::util::unreachable(),
5+
[1, ..tail] => {
6+
assert tail == [2, 3];
7+
}
8+
[_] => core::util::unreachable(),
9+
[] => core::util::unreachable()
10+
}
11+
12+
let y = (~[(1, true), (2, false)], 0.5);
13+
match y {
14+
([_, _, _], 0.5) => core::util::unreachable(),
15+
([(1, a), (b, false), ..tail], _) => {
16+
assert a == true;
17+
assert b == 2;
18+
assert tail.is_empty();
19+
}
20+
([..tail], _) => core::util::unreachable()
21+
}
22+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
fn main() {
2+
let x = &[1, 2, 3, 4, 5];
3+
if !x.is_empty() {
4+
let el = match x {
5+
[1, ..ref tail] => &tail[0],
6+
_ => core::util::unreachable()
7+
};
8+
io::println(fmt!("%d", *el));
9+
}
10+
}

0 commit comments

Comments
 (0)