about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorJakub Wieczorek <jakub@jakub.cc>2014-06-21 14:52:23 +0200
committerJakub Wieczorek <jakub@jakub.cc>2014-06-21 20:36:17 +0200
commitd4da4ba4b2f3412c7f9630c4d88ea3e121cd6f2a (patch)
treed050018ad9987c9e9fe9e8502b543d9f492ba33c /src/test
parentf556c8cbd8af182a9dd871a4a36692a0dba7cc2e (diff)
downloadrust-d4da4ba4b2f3412c7f9630c4d88ea3e121cd6f2a.tar.gz
rust-d4da4ba4b2f3412c7f9630c4d88ea3e121cd6f2a.zip
Fix a #14731 regression in missing_constructor() for vector patterns
Fixes #15080.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass/issue-15080.rs30
-rw-r--r--src/test/run-pass/vec-matching.rs8
2 files changed, 38 insertions, 0 deletions
diff --git a/src/test/run-pass/issue-15080.rs b/src/test/run-pass/issue-15080.rs
new file mode 100644
index 00000000000..b12f0c6462e
--- /dev/null
+++ b/src/test/run-pass/issue-15080.rs
@@ -0,0 +1,30 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+    let mut x = &[1, 2, 3, 4];
+
+    let mut result = vec!();
+    loop {
+        x = match x {
+            [1, n, 3, ..rest] => {
+                result.push(n);
+                rest
+            }
+            [n, ..rest] => {
+                result.push(n);
+                rest
+            }
+            [] =>
+                break
+        }
+    }
+    assert!(result.as_slice() == [2, 4]);
+}
diff --git a/src/test/run-pass/vec-matching.rs b/src/test/run-pass/vec-matching.rs
index 175f774bdfd..11143ba0c84 100644
--- a/src/test/run-pass/vec-matching.rs
+++ b/src/test/run-pass/vec-matching.rs
@@ -68,9 +68,17 @@ fn d() {
     assert_eq!(branch, 1);
 }
 
+fn e() {
+    match &[1, 2, 3] {
+        [1, 2] => (),
+        [..] => ()
+    }
+}
+
 pub fn main() {
     a();
     b();
     c();
     d();
+    e();
 }