File tree Expand file tree Collapse file tree 1 file changed +70
-0
lines changed Expand file tree Collapse file tree 1 file changed +70
-0
lines changed Original file line number Diff line number Diff line change 1+ // Here we test that `..` is allowed in all pattern locations *syntactically*.
2+ // The semantic test is in `rest-pat-semantic-disallowed.rs`.
3+
4+ // check-pass
5+
6+ fn main ( ) { }
7+
8+ macro_rules! accept_pat {
9+ ( $p: pat) => { }
10+ }
11+
12+ accept_pat ! ( ..) ;
13+
14+ #[ cfg( FALSE ) ]
15+ fn rest_patterns ( ) {
16+ // Top level:
17+ fn foo ( ..: u8 ) { }
18+ let ..;
19+
20+ // Box patterns:
21+ let box ..;
22+
23+ // In or-patterns:
24+ match x {
25+ .. | .. => { }
26+ }
27+
28+ // Ref patterns:
29+ let & ..;
30+ let & mut ..;
31+
32+ // Ident patterns:
33+ let x @ ..;
34+ let ref x @ ..;
35+ let ref mut x @ ..;
36+
37+ // Tuple:
38+ let ( ..) ; // This is interpreted as a tuple pattern, not a parenthesis one.
39+ let ( .., ) ; // Allowing trailing comma.
40+ let ( .., .., ..) ; // Duplicates also.
41+ let ( .., P , ..) ; // Including with things in between.
42+
43+ // Tuple struct (same idea as for tuple patterns):
44+ let A ( ..) ;
45+ let A ( .., ) ;
46+ let A ( .., .., ..) ;
47+ let A ( .., P , ..) ;
48+
49+ // Array/Slice (like with tuple patterns):
50+ let [ ..] ;
51+ let [ .., ] ;
52+ let [ .., .., ..] ;
53+ let [ .., P , ..] ;
54+
55+ // Random walk to guard against special casing:
56+ match x {
57+ .. |
58+ [
59+ (
60+ box ..,
61+ & ( ..) ,
62+ & mut ..,
63+ x @ ..
64+ ) ,
65+ ref x @ ..,
66+ ] |
67+ ref mut x @ ..
68+ => { }
69+ }
70+ }
You can’t perform that action at this time.
0 commit comments