Skip to content

Commit 75da43d

Browse files
committed
Use new 'p @ ..' syntax in tests.
1 parent 891a736 commit 75da43d

36 files changed

+69
-85
lines changed

Diff for: src/test/mir-opt/uniform_array_move_out.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fn move_out_from_end() {
88

99
fn move_out_by_subslice() {
1010
let a = [box 1, box 2];
11-
let [_y..] = a;
11+
let [_y @ ..] = a;
1212
}
1313

1414
fn main() {

Diff for: src/test/ui/array-slice-vec/vec-matching-fold.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fn foldl<T, U, F>(values: &[T],
1111
U: Clone+Debug, T:Debug,
1212
F: FnMut(U, &T) -> U,
1313
{ match values {
14-
&[ref head, ref tail..] =>
14+
&[ref head, ref tail @ ..] =>
1515
foldl(tail, function(initial, head), function),
1616
&[] => {
1717
// FIXME: call guards
@@ -28,7 +28,7 @@ fn foldr<T, U, F>(values: &[T],
2828
F: FnMut(&T, U) -> U,
2929
{
3030
match values {
31-
&[ref head.., ref tail] =>
31+
&[ref head @ .., ref tail] =>
3232
foldr(head, function(tail, initial), function),
3333
&[] => {
3434
// FIXME: call guards

Diff for: src/test/ui/array-slice-vec/vec-matching-legal-tail-element-borrow.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub fn main() {
88
let x: &[isize] = &[1, 2, 3, 4, 5];
99
if !x.is_empty() {
1010
let el = match x {
11-
&[1, ref tail..] => &tail[0],
11+
&[1, ref tail @ ..] => &tail[0],
1212
_ => unreachable!()
1313
};
1414
println!("{}", *el);

Diff for: src/test/ui/array-slice-vec/vec-matching.rs

+6-21
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@ fn a() {
1414
fn b() {
1515
let x = [1, 2, 3];
1616
match x {
17-
[a, b, c..] => {
17+
[a, b, c @ ..] => {
1818
assert_eq!(a, 1);
1919
assert_eq!(b, 2);
2020
let expected: &[_] = &[3];
2121
assert_eq!(c, expected);
2222
}
2323
}
2424
match x {
25-
[a.., b, c] => {
25+
[a @ .., b, c] => {
2626
let expected: &[_] = &[1];
2727
assert_eq!(a, expected);
2828
assert_eq!(b, 2);
2929
assert_eq!(c, 3);
3030
}
3131
}
3232
match x {
33-
[a, b.., c] => {
33+
[a, b @ .., c] => {
3434
assert_eq!(a, 1);
3535
let expected: &[_] = &[2];
3636
assert_eq!(b, expected);
@@ -50,7 +50,7 @@ fn b() {
5050
fn b_slice() {
5151
let x : &[_] = &[1, 2, 3];
5252
match x {
53-
&[a, b, ref c..] => {
53+
&[a, b, ref c @ ..] => {
5454
assert_eq!(a, 1);
5555
assert_eq!(b, 2);
5656
let expected: &[_] = &[3];
@@ -59,7 +59,7 @@ fn b_slice() {
5959
_ => unreachable!()
6060
}
6161
match x {
62-
&[ref a.., b, c] => {
62+
&[ref a @ .., b, c] => {
6363
let expected: &[_] = &[1];
6464
assert_eq!(a, expected);
6565
assert_eq!(b, 2);
@@ -68,7 +68,7 @@ fn b_slice() {
6868
_ => unreachable!()
6969
}
7070
match x {
71-
&[a, ref b.., c] => {
71+
&[a, ref b @ .., c] => {
7272
assert_eq!(a, 1);
7373
let expected: &[_] = &[2];
7474
assert_eq!(b, expected);
@@ -134,26 +134,11 @@ fn e() {
134134
assert_eq!(c, 1);
135135
}
136136

137-
fn f() {
138-
let x = &[1, 2, 3, 4, 5];
139-
let [a, [b, [c, ..].., d].., e] = *x;
140-
assert_eq!((a, b, c, d, e), (1, 2, 3, 4, 5));
141-
142-
let x: &[isize] = x;
143-
let (a, b, c, d, e) = match *x {
144-
[a, [b, [c, ..].., d].., e] => (a, b, c, d, e),
145-
_ => unimplemented!()
146-
};
147-
148-
assert_eq!((a, b, c, d, e), (1, 2, 3, 4, 5));
149-
}
150-
151137
pub fn main() {
152138
a();
153139
b();
154140
b_slice();
155141
c();
156142
d();
157143
e();
158-
f();
159144
}

Diff for: src/test/ui/array-slice-vec/vec-tail-matching.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ pub fn main() {
1313
Foo { string: "baz" }
1414
];
1515
match x {
16-
[ref first, ref tail..] => {
16+
[ref first, ref tail @ ..] => {
1717
assert_eq!(first.string, "foo");
1818
assert_eq!(tail.len(), 2);
1919
assert_eq!(tail[0].string, "bar");
2020
assert_eq!(tail[1].string, "baz");
2121

2222
match *(tail as &[_]) {
23-
[Foo { .. }, _, Foo { .. }, ref _tail..] => {
23+
[Foo { .. }, _, Foo { .. }, ref _tail @ ..] => {
2424
unreachable!();
2525
}
2626
[Foo { string: ref a }, Foo { string: ref b }] => {

Diff for: src/test/ui/binding/irrefutable-slice-patterns.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#![feature(slice_patterns)]
55

66
fn foo(s: &[i32]) -> &[i32] {
7-
let &[ref xs..] = s;
7+
let &[ref xs @ ..] = s;
88
xs
99
}
1010

Diff for: src/test/ui/binding/zero_sized_subslice_match.rs

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

Diff for: src/test/ui/borrowck/borrowck-describe-lvalue.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -140,22 +140,22 @@ fn main() {
140140
let mut v = &[1, 2, 3, 4, 5];
141141
let x = &mut v;
142142
match v {
143-
&[x..] => println!("{:?}", x),
143+
&[x @ ..] => println!("{:?}", x),
144144
//~^ ERROR cannot use `v[..]` because it was mutably borrowed
145145
_ => panic!("other case"),
146146
}
147147
match v {
148-
&[_, x..] => println!("{:?}", x),
148+
&[_, x @ ..] => println!("{:?}", x),
149149
//~^ ERROR cannot use `v[..]` because it was mutably borrowed
150150
_ => panic!("other case"),
151151
}
152152
match v {
153-
&[x.., _] => println!("{:?}", x),
153+
&[x @ .., _] => println!("{:?}", x),
154154
//~^ ERROR cannot use `v[..]` because it was mutably borrowed
155155
_ => panic!("other case"),
156156
}
157157
match v {
158-
&[_, x.., _] => println!("{:?}", x),
158+
&[_, x @ .., _] => println!("{:?}", x),
159159
//~^ ERROR cannot use `v[..]` because it was mutably borrowed
160160
_ => panic!("other case"),
161161
}

Diff for: src/test/ui/borrowck/borrowck-move-out-from-array.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fn move_out_from_begin_and_end() {
1010
fn move_out_by_const_index_and_subslice() {
1111
let a = [box 1, box 2];
1212
let [_x, _] = a;
13-
let [_y..] = a; //~ ERROR [E0382]
13+
let [_y @ ..] = a; //~ ERROR [E0382]
1414
}
1515

1616
fn main() {}

Diff for: src/test/ui/borrowck/borrowck-move-out-of-vec-tail.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub fn main() {
1515
];
1616
let x: &[Foo] = &x;
1717
match *x {
18-
[_, ref tail..] => {
18+
[_, ref tail @ ..] => {
1919
match tail {
2020
//~^ ERROR cannot move out of type `[Foo]`
2121
&[Foo { string: a },

Diff for: src/test/ui/borrowck/borrowck-slice-pattern-element-loan-rpass.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
fn mut_head_tail<'a, A>(v: &'a mut [A]) -> Option<(&'a mut A, &'a mut [A])> {
77
match *v {
8-
[ref mut head, ref mut tail..] => {
8+
[ref mut head, ref mut tail @ ..] => {
99
Some((head, tail))
1010
}
1111
[] => None

Diff for: src/test/ui/borrowck/borrowck-slice-pattern-element-loan.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ fn const_index_mixed(s: &mut [i32]) {
7070

7171
fn const_index_and_subslice_ok(s: &mut [i32]) {
7272
if let [ref first, ref second, ..] = *s {
73-
if let [_, _, ref mut tail..] = *s {
73+
if let [_, _, ref mut tail @ ..] = *s {
7474
nop(&[first, second]);
7575
nop_subslice(tail);
7676
}
@@ -79,7 +79,7 @@ fn const_index_and_subslice_ok(s: &mut [i32]) {
7979

8080
fn const_index_and_subslice_err(s: &mut [i32]) {
8181
if let [ref first, ref second, ..] = *s {
82-
if let [_, ref mut tail..] = *s { //~ERROR
82+
if let [_, ref mut tail @ ..] = *s { //~ERROR
8383
nop(&[first, second]);
8484
nop_subslice(tail);
8585
}
@@ -88,7 +88,7 @@ fn const_index_and_subslice_err(s: &mut [i32]) {
8888

8989
fn const_index_and_subslice_from_end_ok(s: &mut [i32]) {
9090
if let [.., ref second, ref first] = *s {
91-
if let [ref mut tail.., _, _] = *s {
91+
if let [ref mut tail @ .., _, _] = *s {
9292
nop(&[first, second]);
9393
nop_subslice(tail);
9494
}
@@ -97,16 +97,16 @@ fn const_index_and_subslice_from_end_ok(s: &mut [i32]) {
9797

9898
fn const_index_and_subslice_from_end_err(s: &mut [i32]) {
9999
if let [.., ref second, ref first] = *s {
100-
if let [ref mut tail.., _] = *s { //~ERROR
100+
if let [ref mut tail @ .., _] = *s { //~ERROR
101101
nop(&[first, second]);
102102
nop_subslice(tail);
103103
}
104104
}
105105
}
106106

107107
fn subslices(s: &mut [i32]) {
108-
if let [_, _, _, ref s1..] = *s {
109-
if let [ref mut s2.., _, _, _] = *s { //~ERROR
108+
if let [_, _, _, ref s1 @ ..] = *s {
109+
if let [ref mut s2 @ .., _, _, _] = *s { //~ERROR
110110
nop_subslice(s1);
111111
nop_subslice(s2);
112112
}

Diff for: src/test/ui/borrowck/borrowck-vec-pattern-element-loan.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ fn a<'a>() -> &'a [isize] {
44
let vec = vec![1, 2, 3, 4];
55
let vec: &[isize] = &vec;
66
let tail = match vec {
7-
&[_, ref tail..] => tail,
7+
&[_, ref tail @ ..] => tail,
88
_ => panic!("a")
99
};
1010
tail //~ ERROR cannot return value referencing local variable `vec`
@@ -14,7 +14,7 @@ fn b<'a>() -> &'a [isize] {
1414
let vec = vec![1, 2, 3, 4];
1515
let vec: &[isize] = &vec;
1616
let init = match vec {
17-
&[ref init.., _] => init,
17+
&[ref init @ .., _] => init,
1818
_ => panic!("b")
1919
};
2020
init //~ ERROR cannot return value referencing local variable `vec`
@@ -24,7 +24,7 @@ fn c<'a>() -> &'a [isize] {
2424
let vec = vec![1, 2, 3, 4];
2525
let vec: &[isize] = &vec;
2626
let slice = match vec {
27-
&[_, ref slice.., _] => slice,
27+
&[_, ref slice @ .., _] => slice,
2828
_ => panic!("c")
2929
};
3030
slice //~ ERROR cannot return value referencing local variable `vec`

Diff for: src/test/ui/borrowck/borrowck-vec-pattern-loan-from-mut.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ fn a() {
44
let mut v = vec![1, 2, 3];
55
let vb: &mut [isize] = &mut v;
66
match vb {
7-
&mut [_a, ref tail..] => {
7+
&mut [_a, ref tail @ ..] => {
88
v.push(tail[0] + tail[1]); //~ ERROR cannot borrow
99
}
1010
_ => {}

Diff for: src/test/ui/borrowck/borrowck-vec-pattern-move-tail.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
fn main() {
66
let mut a = [1, 2, 3, 4];
77
let t = match a {
8-
[1, 2, ref tail..] => tail,
8+
[1, 2, ref tail @ ..] => tail,
99
_ => unreachable!()
1010
};
1111
println!("t[0]: {}", t[0]);

Diff for: src/test/ui/borrowck/borrowck-vec-pattern-nesting.rs

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

Diff for: src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.rs

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

Diff for: src/test/ui/drop/dynamic-drop-async.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ async fn subslice_pattern_from_end_with_drop(a: Rc<Allocator>, arg: bool, arg2:
217217
if arg {
218218
let [.., _x, _] = arr;
219219
} else {
220-
let [_, _y..] = arr;
220+
let [_, _y @ ..] = arr;
221221
}
222222
a.alloc().await;
223223
}
@@ -226,7 +226,7 @@ async fn subslice_pattern_reassign(a: Rc<Allocator>) {
226226
let mut ar = [a.alloc().await, a.alloc().await, a.alloc().await];
227227
let [_, _, _x] = ar;
228228
ar = [a.alloc().await, a.alloc().await, a.alloc().await];
229-
let [_, _y..] = ar;
229+
let [_, _y @ ..] = ar;
230230
a.alloc().await;
231231
}
232232

Diff for: src/test/ui/drop/dynamic-drop.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ fn subslice_pattern_from_end(a: &Allocator, arg: bool) {
237237
if arg {
238238
let[.., _x, _] = a;
239239
} else {
240-
let[_, _y..] = a;
240+
let[_, _y @ ..] = a;
241241
}
242242
}
243243

@@ -251,7 +251,7 @@ fn subslice_pattern_from_end_with_drop(a: &Allocator, arg: bool, arg2: bool) {
251251
if arg {
252252
let[.., _x, _] = a;
253253
} else {
254-
let[_, _y..] = a;
254+
let[_, _y @ ..] = a;
255255
}
256256
}
257257

@@ -266,7 +266,7 @@ fn subslice_pattern_reassign(a: &Allocator) {
266266
let mut ar = [a.alloc(), a.alloc(), a.alloc()];
267267
let[_, _, _x] = ar;
268268
ar = [a.alloc(), a.alloc(), a.alloc()];
269-
let[_, _y..] = ar;
269+
let[_, _y @ ..] = ar;
270270
}
271271

272272
fn panic_after_return(a: &Allocator) -> Ptr<'_> {

Diff for: src/test/ui/error-codes/E0528.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
fn main() {
44
let r = &[1, 2];
55
match r {
6-
&[a, b, c, rest..] => {
6+
&[a, b, c, rest @ ..] => {
77
//~^ ERROR E0528
88
}
99
}

Diff for: src/test/ui/feature-gates/feature-gate-slice-patterns.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ fn main() {
1010

1111
let x = [ 1, 2, 3, 4, 5 ];
1212
match x {
13-
[ xs.., 4, 5 ] => {} //~ ERROR syntax for subslices in slice patterns is not yet stabilized
14-
[ 1, xs.., 5 ] => {} //~ ERROR syntax for subslices in slice patterns is not yet stabilized
15-
[ 1, 2, xs.. ] => {} //~ ERROR syntax for subslices in slice patterns is not yet stabilized
13+
[ xs @ .., 4, 5 ] => {} //~ ERROR syntax for subslices in slice patterns is not yet stabilized
14+
[ 1, xs @ .., 5 ] => {} //~ ERROR syntax for subslices in slice patterns is not yet stabilized
15+
[ 1, 2, xs @ .. ] => {} //~ ERROR syntax for subslices in slice patterns is not yet stabilized
1616
}
1717
}

Diff for: src/test/ui/issues/issue-12369.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fn main() {
66
let v: isize = match &*sl {
77
&[] => 0,
88
&[a,b,c] => 3,
9-
&[a, ref rest..] => a,
10-
&[10,a, ref rest..] => 10 //~ ERROR: unreachable pattern
9+
&[a, ref rest @ ..] => a,
10+
&[10,a, ref rest @ ..] => 10 //~ ERROR: unreachable pattern
1111
};
1212
}

0 commit comments

Comments
 (0)