Skip to content

Commit 98d6269

Browse files
committed
Use new 'p @ ..' syntax in tests.
1 parent 179de7c commit 98d6269

36 files changed

+69
-85
lines changed

src/test/mir-opt/uniform_array_move_out.rs

Lines changed: 1 addition & 1 deletion
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() {

src/test/run-pass/array-slice-vec/vec-matching-fold.rs

Lines changed: 2 additions & 2 deletions
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

src/test/run-pass/array-slice-vec/vec-matching-legal-tail-element-borrow.rs

Lines changed: 1 addition & 1 deletion
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);

src/test/run-pass/array-slice-vec/vec-matching.rs

Lines changed: 6 additions & 21 deletions
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
}

src/test/run-pass/array-slice-vec/vec-tail-matching.rs

Lines changed: 2 additions & 2 deletions
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 }] => {

src/test/run-pass/binding/irrefutable-slice-patterns.rs

Lines changed: 1 addition & 1 deletion
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

src/test/run-pass/binding/zero_sized_subslice_match.rs

Lines changed: 1 addition & 1 deletion
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
}

src/test/run-pass/borrowck/borrowck-slice-pattern-element-loan.rs

Lines changed: 1 addition & 1 deletion
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

src/test/run-pass/drop/dynamic-drop-async.rs

Lines changed: 2 additions & 2 deletions
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

src/test/run-pass/drop/dynamic-drop.rs

Lines changed: 3 additions & 3 deletions
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<'_> {

0 commit comments

Comments
 (0)