1 // Here we test that rest patterns, i.e. `..`, are not allowed
2 // outside of slice (+ ident patterns witin those), tuple,
3 // and tuple struct patterns and that duplicates are caught in these contexts.
5 #![feature(slice_patterns, box_patterns)]
10 () => { .. } //~ ERROR `..` patterns are not allowed here
17 fn foo(..: u8) {} //~ ERROR `..` patterns are not allowed here
18 let ..; //~ ERROR `..` patterns are not allowed here
21 let box ..; //~ ERROR `..` patterns are not allowed here
25 1 | .. => {} //~ ERROR `..` patterns are not allowed here
29 let &..; //~ ERROR `..` patterns are not allowed here
30 let &mut ..; //~ ERROR `..` patterns are not allowed here
33 let x @ ..; //~ ERROR `..` patterns are not allowed here
34 let ref x @ ..; //~ ERROR `..` patterns are not allowed here
35 let ref mut x @ ..; //~ ERROR `..` patterns are not allowed here
38 let (..): (u8,); // OK.
39 let (..,): (u8,); // OK.
42 .., //~ ERROR `..` can only be used once per tuple pattern
43 .. //~ ERROR `..` can only be used once per tuple pattern
48 .. //~ ERROR `..` can only be used once per tuple pattern
53 // Tuple struct (same idea as for tuple patterns):
58 .., //~ ERROR `..` can only be used once per tuple struct pattern
59 .. //~ ERROR `..` can only be used once per tuple struct pattern
64 .. //~ ERROR `..` can only be used once per tuple struct pattern
68 let [..]: &[u8]; // OK.
69 let [..,]: &[u8]; // OK.
72 .., //~ ERROR `..` can only be used once per slice pattern
73 .. //~ ERROR `..` can only be used once per slice pattern
77 ref x @ .., //~ ERROR `..` can only be used once per slice pattern
78 ref mut y @ .., //~ ERROR `..` can only be used once per slice pattern
79 (ref z @ ..), //~ ERROR `..` patterns are not allowed here
80 .. //~ ERROR `..` can only be used once per slice pattern