--- /dev/null
+fn a() -> &int {
+ let vec = [1, 2, 3, 4];
+ let tail = match vec {
+ [a, ..tail] => &tail[0], //~ ERROR illegal borrow
+ _ => fail ~"foo"
+ };
+ move tail
+}
+
+fn main() {
+ let fifth = a();
+ io::println(fmt!("%d", *fifth));
+}
--- /dev/null
+fn main() {
+ let a = [mut 1, 2, 3, 4];
+ let _ = match a {
+ [1, 2, ..move tail] => tail,
+ _ => core::util::unreachable()
+ };
+ a[0] = 0; //~ ERROR: use of moved variable
+}
--- /dev/null
+fn main() {
+ let x = @[1, 2, 3];
+ match x {
+ [2, .._] => core::util::unreachable(),
+ [1, ..tail] => {
+ assert tail == [2, 3];
+ }
+ [_] => core::util::unreachable(),
+ [] => core::util::unreachable()
+ }
+
+ let y = (~[(1, true), (2, false)], 0.5);
+ match y {
+ ([_, _, _], 0.5) => core::util::unreachable(),
+ ([(1, a), (b, false), ..tail], _) => {
+ assert a == true;
+ assert b == 2;
+ assert tail.is_empty();
+ }
+ ([..tail], _) => core::util::unreachable()
+ }
+}
--- /dev/null
+fn main() {
+ let x = &[1, 2, 3, 4, 5];
+ if !x.is_empty() {
+ let el = match x {
+ [1, ..ref tail] => &tail[0],
+ _ => core::util::unreachable()
+ };
+ io::println(fmt!("%d", *el));
+ }
+}