1
Fork 0

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

@ -8,7 +8,7 @@ fn move_out_from_end() {
fn move_out_by_subslice() { fn move_out_by_subslice() {
let a = [box 1, box 2]; let a = [box 1, box 2];
let [_y..] = a; let [_y @ ..] = a;
} }
fn main() { fn main() {

View file

@ -11,7 +11,7 @@ fn foldl<T, U, F>(values: &[T],
U: Clone+Debug, T:Debug, U: Clone+Debug, T:Debug,
F: FnMut(U, &T) -> U, F: FnMut(U, &T) -> U,
{ match values { { match values {
&[ref head, ref tail..] => &[ref head, ref tail @ ..] =>
foldl(tail, function(initial, head), function), foldl(tail, function(initial, head), function),
&[] => { &[] => {
// FIXME: call guards // FIXME: call guards
@ -28,7 +28,7 @@ fn foldr<T, U, F>(values: &[T],
F: FnMut(&T, U) -> U, F: FnMut(&T, U) -> U,
{ {
match values { match values {
&[ref head.., ref tail] => &[ref head @ .., ref tail] =>
foldr(head, function(tail, initial), function), foldr(head, function(tail, initial), function),
&[] => { &[] => {
// FIXME: call guards // FIXME: call guards

View file

@ -8,7 +8,7 @@ pub fn main() {
let x: &[isize] = &[1, 2, 3, 4, 5]; let x: &[isize] = &[1, 2, 3, 4, 5];
if !x.is_empty() { if !x.is_empty() {
let el = match x { let el = match x {
&[1, ref tail..] => &tail[0], &[1, ref tail @ ..] => &tail[0],
_ => unreachable!() _ => unreachable!()
}; };
println!("{}", *el); println!("{}", *el);

View file

@ -14,7 +14,7 @@ fn a() {
fn b() { fn b() {
let x = [1, 2, 3]; let x = [1, 2, 3];
match x { match x {
[a, b, c..] => { [a, b, c @ ..] => {
assert_eq!(a, 1); assert_eq!(a, 1);
assert_eq!(b, 2); assert_eq!(b, 2);
let expected: &[_] = &[3]; let expected: &[_] = &[3];
@ -22,7 +22,7 @@ fn b() {
} }
} }
match x { match x {
[a.., b, c] => { [a @ .., b, c] => {
let expected: &[_] = &[1]; let expected: &[_] = &[1];
assert_eq!(a, expected); assert_eq!(a, expected);
assert_eq!(b, 2); assert_eq!(b, 2);
@ -30,7 +30,7 @@ fn b() {
} }
} }
match x { match x {
[a, b.., c] => { [a, b @ .., c] => {
assert_eq!(a, 1); assert_eq!(a, 1);
let expected: &[_] = &[2]; let expected: &[_] = &[2];
assert_eq!(b, expected); assert_eq!(b, expected);
@ -50,7 +50,7 @@ fn b() {
fn b_slice() { fn b_slice() {
let x : &[_] = &[1, 2, 3]; let x : &[_] = &[1, 2, 3];
match x { match x {
&[a, b, ref c..] => { &[a, b, ref c @ ..] => {
assert_eq!(a, 1); assert_eq!(a, 1);
assert_eq!(b, 2); assert_eq!(b, 2);
let expected: &[_] = &[3]; let expected: &[_] = &[3];
@ -59,7 +59,7 @@ fn b_slice() {
_ => unreachable!() _ => unreachable!()
} }
match x { match x {
&[ref a.., b, c] => { &[ref a @ .., b, c] => {
let expected: &[_] = &[1]; let expected: &[_] = &[1];
assert_eq!(a, expected); assert_eq!(a, expected);
assert_eq!(b, 2); assert_eq!(b, 2);
@ -68,7 +68,7 @@ fn b_slice() {
_ => unreachable!() _ => unreachable!()
} }
match x { match x {
&[a, ref b.., c] => { &[a, ref b @ .., c] => {
assert_eq!(a, 1); assert_eq!(a, 1);
let expected: &[_] = &[2]; let expected: &[_] = &[2];
assert_eq!(b, expected); assert_eq!(b, expected);
@ -134,20 +134,6 @@ fn e() {
assert_eq!(c, 1); assert_eq!(c, 1);
} }
fn f() {
let x = &[1, 2, 3, 4, 5];
let [a, [b, [c, ..].., d].., e] = *x;
assert_eq!((a, b, c, d, e), (1, 2, 3, 4, 5));
let x: &[isize] = x;
let (a, b, c, d, e) = match *x {
[a, [b, [c, ..].., d].., e] => (a, b, c, d, e),
_ => unimplemented!()
};
assert_eq!((a, b, c, d, e), (1, 2, 3, 4, 5));
}
pub fn main() { pub fn main() {
a(); a();
b(); b();
@ -155,5 +141,4 @@ pub fn main() {
c(); c();
d(); d();
e(); e();
f();
} }

View file

@ -13,14 +13,14 @@ pub fn main() {
Foo { string: "baz" } Foo { string: "baz" }
]; ];
match x { match x {
[ref first, ref tail..] => { [ref first, ref tail @ ..] => {
assert_eq!(first.string, "foo"); assert_eq!(first.string, "foo");
assert_eq!(tail.len(), 2); assert_eq!(tail.len(), 2);
assert_eq!(tail[0].string, "bar"); assert_eq!(tail[0].string, "bar");
assert_eq!(tail[1].string, "baz"); assert_eq!(tail[1].string, "baz");
match *(tail as &[_]) { match *(tail as &[_]) {
[Foo { .. }, _, Foo { .. }, ref _tail..] => { [Foo { .. }, _, Foo { .. }, ref _tail @ ..] => {
unreachable!(); unreachable!();
} }
[Foo { string: ref a }, Foo { string: ref b }] => { [Foo { string: ref a }, Foo { string: ref b }] => {

View file

@ -4,7 +4,7 @@
#![feature(slice_patterns)] #![feature(slice_patterns)]
fn foo(s: &[i32]) -> &[i32] { fn foo(s: &[i32]) -> &[i32] {
let &[ref xs..] = s; let &[ref xs @ ..] = s;
xs xs
} }

View file

@ -7,6 +7,6 @@ fn main() {
// The subslice used to go out of bounds for zero-sized array items, check that this doesn't // The subslice used to go out of bounds for zero-sized array items, check that this doesn't
// happen anymore // happen anymore
match x { match x {
[_, ref y..] => assert_eq!(&x[1] as *const (), &y[0] as *const ()) [_, ref y @ ..] => assert_eq!(&x[1] as *const (), &y[0] as *const ())
} }
} }

View file

@ -140,22 +140,22 @@ fn main() {
let mut v = &[1, 2, 3, 4, 5]; let mut v = &[1, 2, 3, 4, 5];
let x = &mut v; let x = &mut v;
match v { match v {
&[x..] => println!("{:?}", x), &[x @ ..] => println!("{:?}", x),
//~^ ERROR cannot use `v[..]` because it was mutably borrowed //~^ ERROR cannot use `v[..]` because it was mutably borrowed
_ => panic!("other case"), _ => panic!("other case"),
} }
match v { match v {
&[_, x..] => println!("{:?}", x), &[_, x @ ..] => println!("{:?}", x),
//~^ ERROR cannot use `v[..]` because it was mutably borrowed //~^ ERROR cannot use `v[..]` because it was mutably borrowed
_ => panic!("other case"), _ => panic!("other case"),
} }
match v { match v {
&[x.., _] => println!("{:?}", x), &[x @ .., _] => println!("{:?}", x),
//~^ ERROR cannot use `v[..]` because it was mutably borrowed //~^ ERROR cannot use `v[..]` because it was mutably borrowed
_ => panic!("other case"), _ => panic!("other case"),
} }
match v { match v {
&[_, x.., _] => println!("{:?}", x), &[_, x @ .., _] => println!("{:?}", x),
//~^ ERROR cannot use `v[..]` because it was mutably borrowed //~^ ERROR cannot use `v[..]` because it was mutably borrowed
_ => panic!("other case"), _ => panic!("other case"),
} }

View file

@ -10,7 +10,7 @@ fn move_out_from_begin_and_end() {
fn move_out_by_const_index_and_subslice() { fn move_out_by_const_index_and_subslice() {
let a = [box 1, box 2]; let a = [box 1, box 2];
let [_x, _] = a; let [_x, _] = a;
let [_y..] = a; //~ ERROR [E0382] let [_y @ ..] = a; //~ ERROR [E0382]
} }
fn main() {} fn main() {}

View file

@ -15,7 +15,7 @@ pub fn main() {
]; ];
let x: &[Foo] = &x; let x: &[Foo] = &x;
match *x { match *x {
[_, ref tail..] => { [_, ref tail @ ..] => {
match tail { match tail {
//~^ ERROR cannot move out of type `[Foo]` //~^ ERROR cannot move out of type `[Foo]`
&[Foo { string: a }, &[Foo { string: a },

View file

@ -5,7 +5,7 @@
fn mut_head_tail<'a, A>(v: &'a mut [A]) -> Option<(&'a mut A, &'a mut [A])> { fn mut_head_tail<'a, A>(v: &'a mut [A]) -> Option<(&'a mut A, &'a mut [A])> {
match *v { match *v {
[ref mut head, ref mut tail..] => { [ref mut head, ref mut tail @ ..] => {
Some((head, tail)) Some((head, tail))
} }
[] => None [] => None

View file

@ -70,7 +70,7 @@ fn const_index_mixed(s: &mut [i32]) {
fn const_index_and_subslice_ok(s: &mut [i32]) { fn const_index_and_subslice_ok(s: &mut [i32]) {
if let [ref first, ref second, ..] = *s { if let [ref first, ref second, ..] = *s {
if let [_, _, ref mut tail..] = *s { if let [_, _, ref mut tail @ ..] = *s {
nop(&[first, second]); nop(&[first, second]);
nop_subslice(tail); nop_subslice(tail);
} }
@ -79,7 +79,7 @@ fn const_index_and_subslice_ok(s: &mut [i32]) {
fn const_index_and_subslice_err(s: &mut [i32]) { fn const_index_and_subslice_err(s: &mut [i32]) {
if let [ref first, ref second, ..] = *s { if let [ref first, ref second, ..] = *s {
if let [_, ref mut tail..] = *s { //~ERROR if let [_, ref mut tail @ ..] = *s { //~ERROR
nop(&[first, second]); nop(&[first, second]);
nop_subslice(tail); nop_subslice(tail);
} }
@ -88,7 +88,7 @@ fn const_index_and_subslice_err(s: &mut [i32]) {
fn const_index_and_subslice_from_end_ok(s: &mut [i32]) { fn const_index_and_subslice_from_end_ok(s: &mut [i32]) {
if let [.., ref second, ref first] = *s { if let [.., ref second, ref first] = *s {
if let [ref mut tail.., _, _] = *s { if let [ref mut tail @ .., _, _] = *s {
nop(&[first, second]); nop(&[first, second]);
nop_subslice(tail); nop_subslice(tail);
} }
@ -97,7 +97,7 @@ fn const_index_and_subslice_from_end_ok(s: &mut [i32]) {
fn const_index_and_subslice_from_end_err(s: &mut [i32]) { fn const_index_and_subslice_from_end_err(s: &mut [i32]) {
if let [.., ref second, ref first] = *s { if let [.., ref second, ref first] = *s {
if let [ref mut tail.., _] = *s { //~ERROR if let [ref mut tail @ .., _] = *s { //~ERROR
nop(&[first, second]); nop(&[first, second]);
nop_subslice(tail); nop_subslice(tail);
} }
@ -105,8 +105,8 @@ fn const_index_and_subslice_from_end_err(s: &mut [i32]) {
} }
fn subslices(s: &mut [i32]) { fn subslices(s: &mut [i32]) {
if let [_, _, _, ref s1..] = *s { if let [_, _, _, ref s1 @ ..] = *s {
if let [ref mut s2.., _, _, _] = *s { //~ERROR if let [ref mut s2 @ .., _, _, _] = *s { //~ERROR
nop_subslice(s1); nop_subslice(s1);
nop_subslice(s2); nop_subslice(s2);
} }

View file

@ -4,7 +4,7 @@ fn a<'a>() -> &'a [isize] {
let vec = vec![1, 2, 3, 4]; let vec = vec![1, 2, 3, 4];
let vec: &[isize] = &vec; let vec: &[isize] = &vec;
let tail = match vec { let tail = match vec {
&[_, ref tail..] => tail, &[_, ref tail @ ..] => tail,
_ => panic!("a") _ => panic!("a")
}; };
tail //~ ERROR cannot return value referencing local variable `vec` tail //~ ERROR cannot return value referencing local variable `vec`
@ -14,7 +14,7 @@ fn b<'a>() -> &'a [isize] {
let vec = vec![1, 2, 3, 4]; let vec = vec![1, 2, 3, 4];
let vec: &[isize] = &vec; let vec: &[isize] = &vec;
let init = match vec { let init = match vec {
&[ref init.., _] => init, &[ref init @ .., _] => init,
_ => panic!("b") _ => panic!("b")
}; };
init //~ ERROR cannot return value referencing local variable `vec` init //~ ERROR cannot return value referencing local variable `vec`
@ -24,7 +24,7 @@ fn c<'a>() -> &'a [isize] {
let vec = vec![1, 2, 3, 4]; let vec = vec![1, 2, 3, 4];
let vec: &[isize] = &vec; let vec: &[isize] = &vec;
let slice = match vec { let slice = match vec {
&[_, ref slice.., _] => slice, &[_, ref slice @ .., _] => slice,
_ => panic!("c") _ => panic!("c")
}; };
slice //~ ERROR cannot return value referencing local variable `vec` slice //~ ERROR cannot return value referencing local variable `vec`

View file

@ -4,7 +4,7 @@ fn a() {
let mut v = vec![1, 2, 3]; let mut v = vec![1, 2, 3];
let vb: &mut [isize] = &mut v; let vb: &mut [isize] = &mut v;
match vb { match vb {
&mut [_a, ref tail..] => { &mut [_a, ref tail @ ..] => {
v.push(tail[0] + tail[1]); //~ ERROR cannot borrow v.push(tail[0] + tail[1]); //~ ERROR cannot borrow
} }
_ => {} _ => {}

View file

@ -5,7 +5,7 @@
fn main() { fn main() {
let mut a = [1, 2, 3, 4]; let mut a = [1, 2, 3, 4];
let t = match a { let t = match a {
[1, 2, ref tail..] => tail, [1, 2, ref tail @ ..] => tail,
_ => unreachable!() _ => unreachable!()
}; };
println!("t[0]: {}", t[0]); println!("t[0]: {}", t[0]);

View file

@ -19,7 +19,7 @@ fn b() {
let mut vec = vec![box 1, box 2, box 3]; let mut vec = vec![box 1, box 2, box 3];
let vec: &mut [Box<isize>] = &mut vec; let vec: &mut [Box<isize>] = &mut vec;
match vec { match vec {
&mut [ref _b..] => { &mut [ref _b @ ..] => {
//~^ borrow of `vec[_]` occurs here //~^ borrow of `vec[_]` occurs here
vec[0] = box 4; //~ ERROR cannot assign vec[0] = box 4; //~ ERROR cannot assign
//~^ NOTE assignment to borrowed `vec[_]` occurs here //~^ NOTE assignment to borrowed `vec[_]` occurs here

View file

@ -4,7 +4,7 @@ fn a<'a>() -> &'a isize {
let vec = vec![1, 2, 3, 4]; let vec = vec![1, 2, 3, 4];
let vec: &[isize] = &vec; let vec: &[isize] = &vec;
let tail = match vec { let tail = match vec {
&[_a, ref tail..] => &tail[0], &[_a, ref tail @ ..] => &tail[0],
_ => panic!("foo") _ => panic!("foo")
}; };
tail //~ ERROR cannot return value referencing local variable `vec` tail //~ ERROR cannot return value referencing local variable `vec`

View file

@ -217,7 +217,7 @@ async fn subslice_pattern_from_end_with_drop(a: Rc<Allocator>, arg: bool, arg2:
if arg { if arg {
let [.., _x, _] = arr; let [.., _x, _] = arr;
} else { } else {
let [_, _y..] = arr; let [_, _y @ ..] = arr;
} }
a.alloc().await; a.alloc().await;
} }
@ -226,7 +226,7 @@ async fn subslice_pattern_reassign(a: Rc<Allocator>) {
let mut ar = [a.alloc().await, a.alloc().await, a.alloc().await]; let mut ar = [a.alloc().await, a.alloc().await, a.alloc().await];
let [_, _, _x] = ar; let [_, _, _x] = ar;
ar = [a.alloc().await, a.alloc().await, a.alloc().await]; ar = [a.alloc().await, a.alloc().await, a.alloc().await];
let [_, _y..] = ar; let [_, _y @ ..] = ar;
a.alloc().await; a.alloc().await;
} }

View file

@ -237,7 +237,7 @@ fn subslice_pattern_from_end(a: &Allocator, arg: bool) {
if arg { if arg {
let[.., _x, _] = a; let[.., _x, _] = a;
} else { } else {
let[_, _y..] = a; let[_, _y @ ..] = a;
} }
} }
@ -251,7 +251,7 @@ fn subslice_pattern_from_end_with_drop(a: &Allocator, arg: bool, arg2: bool) {
if arg { if arg {
let[.., _x, _] = a; let[.., _x, _] = a;
} else { } else {
let[_, _y..] = a; let[_, _y @ ..] = a;
} }
} }
@ -266,7 +266,7 @@ fn subslice_pattern_reassign(a: &Allocator) {
let mut ar = [a.alloc(), a.alloc(), a.alloc()]; let mut ar = [a.alloc(), a.alloc(), a.alloc()];
let[_, _, _x] = ar; let[_, _, _x] = ar;
ar = [a.alloc(), a.alloc(), a.alloc()]; ar = [a.alloc(), a.alloc(), a.alloc()];
let[_, _y..] = ar; let[_, _y @ ..] = ar;
} }
fn panic_after_return(a: &Allocator) -> Ptr<'_> { fn panic_after_return(a: &Allocator) -> Ptr<'_> {

View file

@ -3,7 +3,7 @@
fn main() { fn main() {
let r = &[1, 2]; let r = &[1, 2];
match r { match r {
&[a, b, c, rest..] => { &[a, b, c, rest @ ..] => {
//~^ ERROR E0528 //~^ ERROR E0528
} }
} }

View file

@ -10,8 +10,8 @@ fn main() {
let x = [ 1, 2, 3, 4, 5 ]; let x = [ 1, 2, 3, 4, 5 ];
match x { match x {
[ xs.., 4, 5 ] => {} //~ ERROR syntax for subslices in slice patterns is not yet stabilized [ xs @ .., 4, 5 ] => {} //~ ERROR syntax for subslices in slice patterns is not yet stabilized
[ 1, xs.., 5 ] => {} //~ ERROR syntax for subslices in slice patterns is not yet stabilized [ 1, xs @ .., 5 ] => {} //~ ERROR syntax for subslices in slice patterns is not yet stabilized
[ 1, 2, xs.. ] => {} //~ ERROR syntax for subslices in slice patterns is not yet stabilized [ 1, 2, xs @ .. ] => {} //~ ERROR syntax for subslices in slice patterns is not yet stabilized
} }
} }

View file

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

View file

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

View file

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

View file

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

View file

@ -2,5 +2,5 @@
fn main() { fn main() {
let x: &[u32] = &[]; 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?) // check-pass
#![allow(dead_code)]
#![feature(slice_patterns)] #![feature(slice_patterns)]
fn check(list: &[u8]) { fn check(list: &[u8]) {
match list { match list {
&[] => {}, &[] => {},
&[_u1, _u2, ref _next..] => {}, &[_u1, _u2, ref _next @ ..] => {},
&[_u1] => {}, &[_u1] => {},
} }
} }

View file

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

View file

@ -19,10 +19,10 @@ fn main() {
match [0, 1, 2] { match [0, 1, 2] {
[0] => {}, //~ ERROR pattern requires [0] => {}, //~ ERROR pattern requires
[0, 1, x..] => { [0, 1, x @ ..] => {
let a: [_; 1] = x; let a: [_; 1] = x;
} }
[0, 1, 2, 3, x..] => {} //~ ERROR pattern requires [0, 1, 2, 3, x @ ..] => {} //~ ERROR pattern requires
}; };
match does_not_exist { //~ ERROR cannot find value `does_not_exist` in this scope match does_not_exist { //~ ERROR cannot find value `does_not_exist` in this scope

View file

@ -23,7 +23,7 @@ fn main() {
let x: Vec<char> = vec!['a', 'b', 'c']; let x: Vec<char> = vec!['a', 'b', 'c'];
let x: &[char] = &x; let x: &[char] = &x;
match *x { match *x {
['a', 'b', 'c', ref _tail..] => {} ['a', 'b', 'c', ref _tail @ ..] => {}
['a', 'b', 'c'] => {} //~ ERROR unreachable pattern ['a', 'b', 'c'] => {} //~ ERROR unreachable pattern
_ => {} _ => {}
} }

View file

@ -32,14 +32,14 @@ fn main() {
let vec = vec![Some(42), None, Some(21)]; let vec = vec![Some(42), None, Some(21)];
let vec: &[Option<isize>] = &vec; let vec: &[Option<isize>] = &vec;
match *vec { //~ ERROR non-exhaustive patterns: `[]` not covered match *vec { //~ ERROR non-exhaustive patterns: `[]` not covered
[Some(..), None, ref tail..] => {} [Some(..), None, ref tail @ ..] => {}
[Some(..), Some(..), ref tail..] => {} [Some(..), Some(..), ref tail @ ..] => {}
[None] => {} [None] => {}
} }
let vec = vec![1]; let vec = vec![1];
let vec: &[isize] = &vec; let vec: &[isize] = &vec;
match *vec { match *vec {
[_, ref tail..] => (), [_, ref tail @ ..] => (),
[] => () [] => ()
} }
let vec = vec![0.5f32]; let vec = vec![0.5f32];
@ -53,10 +53,10 @@ fn main() {
let vec = vec![Some(42), None, Some(21)]; let vec = vec![Some(42), None, Some(21)];
let vec: &[Option<isize>] = &vec; let vec: &[Option<isize>] = &vec;
match *vec { match *vec {
[Some(..), None, ref tail..] => {} [Some(..), None, ref tail @ ..] => {}
[Some(..), Some(..), ref tail..] => {} [Some(..), Some(..), ref tail @ ..] => {}
[None, None, ref tail..] => {} [None, None, ref tail @ ..] => {}
[None, Some(..), ref tail..] => {} [None, Some(..), ref tail @ ..] => {}
[Some(_)] => {} [Some(_)] => {}
[None] => {} [None] => {}
[] => {} [] => {}

View file

@ -77,7 +77,7 @@ fn vectors_with_nested_enums() {
[Enum::Second(true), Enum::First] => (), [Enum::Second(true), Enum::First] => (),
[Enum::Second(true), Enum::Second(true)] => (), [Enum::Second(true), Enum::Second(true)] => (),
[Enum::Second(false), _] => (), [Enum::Second(false), _] => (),
[_, _, ref tail.., _] => () [_, _, ref tail @ .., _] => ()
} }
} }

View file

@ -1,7 +1,7 @@
fn main() { fn main() {
let a = Vec::new(); let a = Vec::new();
match a { match a {
[1, tail.., tail..] => {}, //~ ERROR: expected one of `,` or `@`, found `..` [1, tail @ .., tail @ ..] => {}, //~ ERROR: expected one of `,` or `@`, found `..`
_ => () _ => ()
} }
} }

View file

@ -4,6 +4,6 @@ pub fn main() {
let sl: &[u8] = b"foo"; let sl: &[u8] = b"foo";
match sl { //~ ERROR non-exhaustive patterns match sl { //~ ERROR non-exhaustive patterns
[first, remainder..] => {}, [first, remainder @ ..] => {},
}; };
} }

View file

@ -5,7 +5,7 @@ fn slice_pat() {
let sl: &[u8] = b"foo"; let sl: &[u8] = b"foo";
match sl { match sl {
[first, remainder..] => { [first, remainder @ ..] => {
let _: &u8 = first; let _: &u8 = first;
assert_eq!(first, &b'f'); assert_eq!(first, &b'f');
assert_eq!(remainder, b"oo"); assert_eq!(remainder, b"oo");

View file

@ -25,7 +25,7 @@ pub fn main() {
let (_, _,) = (1, 1,); let (_, _,) = (1, 1,);
let [_, _,] = [1, 1,]; let [_, _,] = [1, 1,];
let [_, _, .., _,] = [1, 1, 1, 1,]; let [_, _, .., _,] = [1, 1, 1, 1,];
let [_, _, _.., _,] = [1, 1, 1, 1,]; let [_, _, _, ..,] = [1, 1, 1, 1,];
let x: Foo<isize,> = Foo::<isize,>(1); let x: Foo<isize,> = Foo::<isize,>(1);