about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-11-09 15:13:58 -0800
committerGitHub <noreply@github.com>2016-11-09 15:13:58 -0800
commit0b46947d35e9fdc35cd06dd889c3c3a892d7ddf8 (patch)
tree243eae5327969b906c60278f0fdd82c26e471000 /src/test
parentda2ce2276873242a101f205537e7ce297d68f8dd (diff)
parent1dad4b6bb5dcdcda8060d0a662824a50a9f22e82 (diff)
Auto merge of #37603 - arielb1:max-slice-length, r=nikomatsakis
_match: correct max_slice_length logic

The logic used to be wildly wrong, but before the HAIR patch its wrongness was in most cases hidden by another bug.

Fixes #37598.

r? @nikomatsakis
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/match-slice-patterns.rs24
-rw-r--r--src/test/run-pass/issue-37598.rs21
2 files changed, 45 insertions, 0 deletions
diff --git a/src/test/compile-fail/match-slice-patterns.rs b/src/test/compile-fail/match-slice-patterns.rs
new file mode 100644
index 00000000000..c0fc75f9713
--- /dev/null
+++ b/src/test/compile-fail/match-slice-patterns.rs
@@ -0,0 +1,24 @@
+// Copyright 2016 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.
+
+#![feature(advanced_slice_patterns, slice_patterns)]
+
+fn check(list: &[Option<()>]) {
+    match list {
+    //~^ ERROR `&[None, Some(_), None, _]` and `&[Some(_), Some(_), None, _]` not covered
+        &[] => {},
+        &[_] => {},
+        &[_, _] => {},
+        &[_, None, ..] => {},
+        &[.., Some(_), _] => {},
+    }
+}
+
+fn main() {}
diff --git a/src/test/run-pass/issue-37598.rs b/src/test/run-pass/issue-37598.rs
new file mode 100644
index 00000000000..d32d2fc2954
--- /dev/null
+++ b/src/test/run-pass/issue-37598.rs
@@ -0,0 +1,21 @@
+// Copyright 2016 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.
+
+#![feature(advanced_slice_patterns, slice_patterns)]
+
+fn check(list: &[u8]) {
+    match list {
+        &[] => {},
+        &[_u1, _u2, ref _next..] => {},
+        &[_u1] => {},
+    }
+}
+
+fn main() {}