]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/pattern/rest-pat-semantic-disallowed.rs
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(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 //~^ ERROR type annotations needed
35 let ref x @
..; //~ ERROR `..` patterns are not allowed here
36 let ref mut x @
..; //~ ERROR `..` patterns are not allowed here
39 let (..): (u8,); // OK.
40 let (..,): (u8,); // OK.
43 .., //~ ERROR `..` can only be used once per tuple pattern
44 .. //~ ERROR `..` can only be used once per tuple pattern
49 .. //~ ERROR `..` can only be used once per tuple pattern
54 // Tuple struct (same idea as for tuple patterns):
59 .., //~ ERROR `..` can only be used once per tuple struct pattern
60 .. //~ ERROR `..` can only be used once per tuple struct pattern
65 .. //~ ERROR `..` can only be used once per tuple struct pattern
69 let [..]: &[u8]; // OK.
70 let [..,]: &[u8]; // OK.
73 .., //~ ERROR `..` can only be used once per slice pattern
74 .. //~ ERROR `..` can only be used once per slice pattern
78 ref x @
.., //~ ERROR `..` can only be used once per slice pattern
79 ref mut y @
.., //~ ERROR `..` can only be used once per slice pattern
80 (ref z @
..), //~ ERROR `..` patterns are not allowed here
81 .. //~ ERROR `..` can only be used once per slice pattern