diff options
| author | Ariel Ben-Yehuda <ariel.byd@gmail.com> | 2016-11-05 13:32:35 +0200 |
|---|---|---|
| committer | Ariel Ben-Yehuda <ariel.byd@gmail.com> | 2016-11-05 13:32:35 +0200 |
| commit | d3ddb85eb1de721373b96d86a1a2dbf33dda3497 (patch) | |
| tree | 3eedba999aee942667ab2e81d6414cb3afbf912c /src/test | |
| parent | 81601cd3a393d1cb8ca82eb1b2270d24c5d7724f (diff) | |
_match: correct max_slice_length logic
The logic used to be wildly wrong, but before the HAIR patch its wrongness was hidden by another bug. Fixes #37598.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/match-slice-patterns.rs | 24 | ||||
| -rw-r--r-- | src/test/run-pass/issue-37598.rs | 21 |
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() {} |
