Use new 'p @ ..' syntax in tests.

This commit is contained in:
Mazdak Farrokhzad 2019-07-08 01:47:46 +02:00
parent 891a736b02
commit 75da43dc87
36 changed files with 69 additions and 85 deletions

View file

@ -6,7 +6,7 @@ fn main() {
let v: isize = match &*sl {
&[] => 0,
&[a,b,c] => 3,
&[a, ref rest..] => a,
&[10,a, ref rest..] => 10 //~ ERROR: unreachable pattern
&[a, ref rest @ ..] => a,
&[10,a, ref rest @ ..] => 10 //~ ERROR: unreachable pattern
};
}

View file

@ -7,11 +7,11 @@ fn main() {
let mut result = vec![];
loop {
x = match *x {
[1, n, 3, ref rest..] => {
[1, n, 3, ref rest @ ..] => {
result.push(n);
rest
}
[n, ref rest..] => {
[n, ref rest @ ..] => {
result.push(n);
rest
}

View file

@ -9,6 +9,6 @@ fn count_members(v: &[usize]) -> usize {
match *v {
[] => 0,
[_] => 1,
[_, ref xs..] => 1 + count_members(xs)
[_, ref xs @ ..] => 1 + count_members(xs)
}
}

View file

@ -7,8 +7,8 @@ fn main() {
}, 42_usize);
assert_eq!(match [0u8; 1024] {
[1, _..] => 0_usize,
[0, _..] => 1_usize,
[1, ..] => 0_usize,
[0, ..] => 1_usize,
_ => 2_usize
}, 1_usize);
}

View file

@ -2,5 +2,5 @@
fn main() {
let x: &[u32] = &[];
let &[[ref _a, ref _b..]..] = x; //~ ERROR refutable pattern
let &[[ref _a, ref _b @ ..] @ ..] = x; //~ ERROR refutable pattern
}

View file

@ -1,11 +1,10 @@
// build-pass (FIXME(62277): could be check-pass?)
#![allow(dead_code)]
// check-pass
#![feature(slice_patterns)]
fn check(list: &[u8]) {
match list {
&[] => {},
&[_u1, _u2, ref _next..] => {},
&[_u1, _u2, ref _next @ ..] => {},
&[_u1] => {},
}
}

View file

@ -24,7 +24,7 @@ fn main() {
assert_eq!(d, "baz");
let out = bar("baz", "foo");
let [a, xs.., d] = out;
let [a, xs @ .., d] = out;
assert_eq!(a, "baz");
assert_eq!(xs, ["foo", "foo"]);
assert_eq!(d, "baz");