mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 14:31:55 +00:00
Use new 'p @ ..' syntax in tests.
This commit is contained in:
parent
891a736b02
commit
75da43dc87
@ -8,7 +8,7 @@ fn move_out_from_end() {
|
||||
|
||||
fn move_out_by_subslice() {
|
||||
let a = [box 1, box 2];
|
||||
let [_y..] = a;
|
||||
let [_y @ ..] = a;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -11,7 +11,7 @@ fn foldl<T, U, F>(values: &[T],
|
||||
U: Clone+Debug, T:Debug,
|
||||
F: FnMut(U, &T) -> U,
|
||||
{ match values {
|
||||
&[ref head, ref tail..] =>
|
||||
&[ref head, ref tail @ ..] =>
|
||||
foldl(tail, function(initial, head), function),
|
||||
&[] => {
|
||||
// FIXME: call guards
|
||||
@ -28,7 +28,7 @@ fn foldr<T, U, F>(values: &[T],
|
||||
F: FnMut(&T, U) -> U,
|
||||
{
|
||||
match values {
|
||||
&[ref head.., ref tail] =>
|
||||
&[ref head @ .., ref tail] =>
|
||||
foldr(head, function(tail, initial), function),
|
||||
&[] => {
|
||||
// FIXME: call guards
|
||||
|
@ -8,7 +8,7 @@ pub fn main() {
|
||||
let x: &[isize] = &[1, 2, 3, 4, 5];
|
||||
if !x.is_empty() {
|
||||
let el = match x {
|
||||
&[1, ref tail..] => &tail[0],
|
||||
&[1, ref tail @ ..] => &tail[0],
|
||||
_ => unreachable!()
|
||||
};
|
||||
println!("{}", *el);
|
||||
|
@ -14,7 +14,7 @@ fn a() {
|
||||
fn b() {
|
||||
let x = [1, 2, 3];
|
||||
match x {
|
||||
[a, b, c..] => {
|
||||
[a, b, c @ ..] => {
|
||||
assert_eq!(a, 1);
|
||||
assert_eq!(b, 2);
|
||||
let expected: &[_] = &[3];
|
||||
@ -22,7 +22,7 @@ fn b() {
|
||||
}
|
||||
}
|
||||
match x {
|
||||
[a.., b, c] => {
|
||||
[a @ .., b, c] => {
|
||||
let expected: &[_] = &[1];
|
||||
assert_eq!(a, expected);
|
||||
assert_eq!(b, 2);
|
||||
@ -30,7 +30,7 @@ fn b() {
|
||||
}
|
||||
}
|
||||
match x {
|
||||
[a, b.., c] => {
|
||||
[a, b @ .., c] => {
|
||||
assert_eq!(a, 1);
|
||||
let expected: &[_] = &[2];
|
||||
assert_eq!(b, expected);
|
||||
@ -50,7 +50,7 @@ fn b() {
|
||||
fn b_slice() {
|
||||
let x : &[_] = &[1, 2, 3];
|
||||
match x {
|
||||
&[a, b, ref c..] => {
|
||||
&[a, b, ref c @ ..] => {
|
||||
assert_eq!(a, 1);
|
||||
assert_eq!(b, 2);
|
||||
let expected: &[_] = &[3];
|
||||
@ -59,7 +59,7 @@ fn b_slice() {
|
||||
_ => unreachable!()
|
||||
}
|
||||
match x {
|
||||
&[ref a.., b, c] => {
|
||||
&[ref a @ .., b, c] => {
|
||||
let expected: &[_] = &[1];
|
||||
assert_eq!(a, expected);
|
||||
assert_eq!(b, 2);
|
||||
@ -68,7 +68,7 @@ fn b_slice() {
|
||||
_ => unreachable!()
|
||||
}
|
||||
match x {
|
||||
&[a, ref b.., c] => {
|
||||
&[a, ref b @ .., c] => {
|
||||
assert_eq!(a, 1);
|
||||
let expected: &[_] = &[2];
|
||||
assert_eq!(b, expected);
|
||||
@ -134,20 +134,6 @@ fn e() {
|
||||
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() {
|
||||
a();
|
||||
b();
|
||||
@ -155,5 +141,4 @@ pub fn main() {
|
||||
c();
|
||||
d();
|
||||
e();
|
||||
f();
|
||||
}
|
||||
|
@ -13,14 +13,14 @@ pub fn main() {
|
||||
Foo { string: "baz" }
|
||||
];
|
||||
match x {
|
||||
[ref first, ref tail..] => {
|
||||
[ref first, ref tail @ ..] => {
|
||||
assert_eq!(first.string, "foo");
|
||||
assert_eq!(tail.len(), 2);
|
||||
assert_eq!(tail[0].string, "bar");
|
||||
assert_eq!(tail[1].string, "baz");
|
||||
|
||||
match *(tail as &[_]) {
|
||||
[Foo { .. }, _, Foo { .. }, ref _tail..] => {
|
||||
[Foo { .. }, _, Foo { .. }, ref _tail @ ..] => {
|
||||
unreachable!();
|
||||
}
|
||||
[Foo { string: ref a }, Foo { string: ref b }] => {
|
||||
|
@ -4,7 +4,7 @@
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
fn foo(s: &[i32]) -> &[i32] {
|
||||
let &[ref xs..] = s;
|
||||
let &[ref xs @ ..] = s;
|
||||
xs
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,6 @@ fn main() {
|
||||
// The subslice used to go out of bounds for zero-sized array items, check that this doesn't
|
||||
// happen anymore
|
||||
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 ())
|
||||
}
|
||||
}
|
||||
|
@ -140,22 +140,22 @@ fn main() {
|
||||
let mut v = &[1, 2, 3, 4, 5];
|
||||
let x = &mut v;
|
||||
match v {
|
||||
&[x..] => println!("{:?}", x),
|
||||
&[x @ ..] => println!("{:?}", x),
|
||||
//~^ ERROR cannot use `v[..]` because it was mutably borrowed
|
||||
_ => panic!("other case"),
|
||||
}
|
||||
match v {
|
||||
&[_, x..] => println!("{:?}", x),
|
||||
&[_, x @ ..] => println!("{:?}", x),
|
||||
//~^ ERROR cannot use `v[..]` because it was mutably borrowed
|
||||
_ => panic!("other case"),
|
||||
}
|
||||
match v {
|
||||
&[x.., _] => println!("{:?}", x),
|
||||
&[x @ .., _] => println!("{:?}", x),
|
||||
//~^ ERROR cannot use `v[..]` because it was mutably borrowed
|
||||
_ => panic!("other case"),
|
||||
}
|
||||
match v {
|
||||
&[_, x.., _] => println!("{:?}", x),
|
||||
&[_, x @ .., _] => println!("{:?}", x),
|
||||
//~^ ERROR cannot use `v[..]` because it was mutably borrowed
|
||||
_ => panic!("other case"),
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ fn move_out_from_begin_and_end() {
|
||||
fn move_out_by_const_index_and_subslice() {
|
||||
let a = [box 1, box 2];
|
||||
let [_x, _] = a;
|
||||
let [_y..] = a; //~ ERROR [E0382]
|
||||
let [_y @ ..] = a; //~ ERROR [E0382]
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -15,7 +15,7 @@ pub fn main() {
|
||||
];
|
||||
let x: &[Foo] = &x;
|
||||
match *x {
|
||||
[_, ref tail..] => {
|
||||
[_, ref tail @ ..] => {
|
||||
match tail {
|
||||
//~^ ERROR cannot move out of type `[Foo]`
|
||||
&[Foo { string: a },
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
fn mut_head_tail<'a, A>(v: &'a mut [A]) -> Option<(&'a mut A, &'a mut [A])> {
|
||||
match *v {
|
||||
[ref mut head, ref mut tail..] => {
|
||||
[ref mut head, ref mut tail @ ..] => {
|
||||
Some((head, tail))
|
||||
}
|
||||
[] => None
|
||||
|
@ -70,7 +70,7 @@ fn const_index_mixed(s: &mut [i32]) {
|
||||
|
||||
fn const_index_and_subslice_ok(s: &mut [i32]) {
|
||||
if let [ref first, ref second, ..] = *s {
|
||||
if let [_, _, ref mut tail..] = *s {
|
||||
if let [_, _, ref mut tail @ ..] = *s {
|
||||
nop(&[first, second]);
|
||||
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]) {
|
||||
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_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]) {
|
||||
if let [.., ref second, ref first] = *s {
|
||||
if let [ref mut tail.., _, _] = *s {
|
||||
if let [ref mut tail @ .., _, _] = *s {
|
||||
nop(&[first, second]);
|
||||
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]) {
|
||||
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_subslice(tail);
|
||||
}
|
||||
@ -105,8 +105,8 @@ fn const_index_and_subslice_from_end_err(s: &mut [i32]) {
|
||||
}
|
||||
|
||||
fn subslices(s: &mut [i32]) {
|
||||
if let [_, _, _, ref s1..] = *s {
|
||||
if let [ref mut s2.., _, _, _] = *s { //~ERROR
|
||||
if let [_, _, _, ref s1 @ ..] = *s {
|
||||
if let [ref mut s2 @ .., _, _, _] = *s { //~ERROR
|
||||
nop_subslice(s1);
|
||||
nop_subslice(s2);
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ fn a<'a>() -> &'a [isize] {
|
||||
let vec = vec![1, 2, 3, 4];
|
||||
let vec: &[isize] = &vec;
|
||||
let tail = match vec {
|
||||
&[_, ref tail..] => tail,
|
||||
&[_, ref tail @ ..] => tail,
|
||||
_ => panic!("a")
|
||||
};
|
||||
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: &[isize] = &vec;
|
||||
let init = match vec {
|
||||
&[ref init.., _] => init,
|
||||
&[ref init @ .., _] => init,
|
||||
_ => panic!("b")
|
||||
};
|
||||
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: &[isize] = &vec;
|
||||
let slice = match vec {
|
||||
&[_, ref slice.., _] => slice,
|
||||
&[_, ref slice @ .., _] => slice,
|
||||
_ => panic!("c")
|
||||
};
|
||||
slice //~ ERROR cannot return value referencing local variable `vec`
|
||||
|
@ -4,7 +4,7 @@ fn a() {
|
||||
let mut v = vec![1, 2, 3];
|
||||
let vb: &mut [isize] = &mut v;
|
||||
match vb {
|
||||
&mut [_a, ref tail..] => {
|
||||
&mut [_a, ref tail @ ..] => {
|
||||
v.push(tail[0] + tail[1]); //~ ERROR cannot borrow
|
||||
}
|
||||
_ => {}
|
||||
|
@ -5,7 +5,7 @@
|
||||
fn main() {
|
||||
let mut a = [1, 2, 3, 4];
|
||||
let t = match a {
|
||||
[1, 2, ref tail..] => tail,
|
||||
[1, 2, ref tail @ ..] => tail,
|
||||
_ => unreachable!()
|
||||
};
|
||||
println!("t[0]: {}", t[0]);
|
||||
|
@ -19,7 +19,7 @@ fn b() {
|
||||
let mut vec = vec![box 1, box 2, box 3];
|
||||
let vec: &mut [Box<isize>] = &mut vec;
|
||||
match vec {
|
||||
&mut [ref _b..] => {
|
||||
&mut [ref _b @ ..] => {
|
||||
//~^ borrow of `vec[_]` occurs here
|
||||
vec[0] = box 4; //~ ERROR cannot assign
|
||||
//~^ NOTE assignment to borrowed `vec[_]` occurs here
|
||||
|
@ -4,7 +4,7 @@ fn a<'a>() -> &'a isize {
|
||||
let vec = vec![1, 2, 3, 4];
|
||||
let vec: &[isize] = &vec;
|
||||
let tail = match vec {
|
||||
&[_a, ref tail..] => &tail[0],
|
||||
&[_a, ref tail @ ..] => &tail[0],
|
||||
_ => panic!("foo")
|
||||
};
|
||||
tail //~ ERROR cannot return value referencing local variable `vec`
|
||||
|
@ -217,7 +217,7 @@ async fn subslice_pattern_from_end_with_drop(a: Rc<Allocator>, arg: bool, arg2:
|
||||
if arg {
|
||||
let [.., _x, _] = arr;
|
||||
} else {
|
||||
let [_, _y..] = arr;
|
||||
let [_, _y @ ..] = arr;
|
||||
}
|
||||
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 [_, _, _x] = ar;
|
||||
ar = [a.alloc().await, a.alloc().await, a.alloc().await];
|
||||
let [_, _y..] = ar;
|
||||
let [_, _y @ ..] = ar;
|
||||
a.alloc().await;
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ fn subslice_pattern_from_end(a: &Allocator, arg: bool) {
|
||||
if arg {
|
||||
let[.., _x, _] = a;
|
||||
} 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 {
|
||||
let[.., _x, _] = a;
|
||||
} 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[_, _, _x] = ar;
|
||||
ar = [a.alloc(), a.alloc(), a.alloc()];
|
||||
let[_, _y..] = ar;
|
||||
let[_, _y @ ..] = ar;
|
||||
}
|
||||
|
||||
fn panic_after_return(a: &Allocator) -> Ptr<'_> {
|
||||
|
@ -3,7 +3,7 @@
|
||||
fn main() {
|
||||
let r = &[1, 2];
|
||||
match r {
|
||||
&[a, b, c, rest..] => {
|
||||
&[a, b, c, rest @ ..] => {
|
||||
//~^ ERROR E0528
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ fn main() {
|
||||
|
||||
let x = [ 1, 2, 3, 4, 5 ];
|
||||
match x {
|
||||
[ 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, 2, xs.. ] => {} //~ 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, 2, xs @ .. ] => {} //~ ERROR syntax for subslices in slice patterns is not yet stabilized
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
};
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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] => {},
|
||||
}
|
||||
}
|
||||
|
@ -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");
|
||||
|
@ -19,10 +19,10 @@ fn main() {
|
||||
match [0, 1, 2] {
|
||||
[0] => {}, //~ ERROR pattern requires
|
||||
|
||||
[0, 1, x..] => {
|
||||
[0, 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
|
||||
|
@ -23,7 +23,7 @@ fn main() {
|
||||
let x: Vec<char> = vec!['a', 'b', 'c'];
|
||||
let x: &[char] = &x;
|
||||
match *x {
|
||||
['a', 'b', 'c', ref _tail..] => {}
|
||||
['a', 'b', 'c', ref _tail @ ..] => {}
|
||||
['a', 'b', 'c'] => {} //~ ERROR unreachable pattern
|
||||
_ => {}
|
||||
}
|
||||
|
@ -32,14 +32,14 @@ fn main() {
|
||||
let vec = vec![Some(42), None, Some(21)];
|
||||
let vec: &[Option<isize>] = &vec;
|
||||
match *vec { //~ ERROR non-exhaustive patterns: `[]` not covered
|
||||
[Some(..), None, ref tail..] => {}
|
||||
[Some(..), Some(..), ref tail..] => {}
|
||||
[Some(..), None, ref tail @ ..] => {}
|
||||
[Some(..), Some(..), ref tail @ ..] => {}
|
||||
[None] => {}
|
||||
}
|
||||
let vec = vec![1];
|
||||
let vec: &[isize] = &vec;
|
||||
match *vec {
|
||||
[_, ref tail..] => (),
|
||||
[_, ref tail @ ..] => (),
|
||||
[] => ()
|
||||
}
|
||||
let vec = vec![0.5f32];
|
||||
@ -53,10 +53,10 @@ fn main() {
|
||||
let vec = vec![Some(42), None, Some(21)];
|
||||
let vec: &[Option<isize>] = &vec;
|
||||
match *vec {
|
||||
[Some(..), None, ref tail..] => {}
|
||||
[Some(..), Some(..), ref tail..] => {}
|
||||
[None, None, ref tail..] => {}
|
||||
[None, Some(..), ref tail..] => {}
|
||||
[Some(..), None, ref tail @ ..] => {}
|
||||
[Some(..), Some(..), ref tail @ ..] => {}
|
||||
[None, None, ref tail @ ..] => {}
|
||||
[None, Some(..), ref tail @ ..] => {}
|
||||
[Some(_)] => {}
|
||||
[None] => {}
|
||||
[] => {}
|
||||
|
@ -77,7 +77,7 @@ fn vectors_with_nested_enums() {
|
||||
[Enum::Second(true), Enum::First] => (),
|
||||
[Enum::Second(true), Enum::Second(true)] => (),
|
||||
[Enum::Second(false), _] => (),
|
||||
[_, _, ref tail.., _] => ()
|
||||
[_, _, ref tail @ .., _] => ()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
fn main() {
|
||||
let a = Vec::new();
|
||||
match a {
|
||||
[1, tail.., tail..] => {}, //~ ERROR: expected one of `,` or `@`, found `..`
|
||||
[1, tail @ .., tail @ ..] => {}, //~ ERROR: expected one of `,` or `@`, found `..`
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,6 @@ pub fn main() {
|
||||
let sl: &[u8] = b"foo";
|
||||
|
||||
match sl { //~ ERROR non-exhaustive patterns
|
||||
[first, remainder..] => {},
|
||||
[first, remainder @ ..] => {},
|
||||
};
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ fn slice_pat() {
|
||||
let sl: &[u8] = b"foo";
|
||||
|
||||
match sl {
|
||||
[first, remainder..] => {
|
||||
[first, remainder @ ..] => {
|
||||
let _: &u8 = first;
|
||||
assert_eq!(first, &b'f');
|
||||
assert_eq!(remainder, b"oo");
|
||||
|
@ -25,7 +25,7 @@ pub fn main() {
|
||||
let (_, _,) = (1, 1,);
|
||||
let [_, _,] = [1, 1,];
|
||||
let [_, _, .., _,] = [1, 1, 1, 1,];
|
||||
let [_, _, _.., _,] = [1, 1, 1, 1,];
|
||||
let [_, _, _, ..,] = [1, 1, 1, 1,];
|
||||
|
||||
let x: Foo<isize,> = Foo::<isize,>(1);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user