summaryrefslogtreecommitdiffstats
path: root/tests/ui/pattern/rest-pat-syntactic.rs
blob: 4da5a2db76743ddaa01cf60729afc219d57e658a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Here we test that `..` is allowed in all pattern locations *syntactically*.
// The semantic test is in `rest-pat-semantic-disallowed.rs`.

// check-pass

fn main() {}

macro_rules! accept_pat {
    ($p:pat) => {}
}

accept_pat!(..);

#[cfg(FALSE)]
fn rest_patterns() {
    // Top level:
    fn foo(..: u8) {}
    let ..;

    // Box patterns:
    let box ..;
    //~^ WARN box pattern syntax is experimental
    //~| WARN unstable syntax

    // In or-patterns:
    match x {
        .. | .. => {}
    }

    // Ref patterns:
    let &..;
    let &mut ..;

    // Ident patterns:
    let x @ ..;
    let ref x @ ..;
    let ref mut x @ ..;

    // Tuple:
    let (..); // This is interpreted as a tuple pattern, not a parenthesis one.
    let (..,); // Allowing trailing comma.
    let (.., .., ..); // Duplicates also.
    let (.., P, ..); // Including with things in between.

    // Tuple struct (same idea as for tuple patterns):
    let A(..);
    let A(..,);
    let A(.., .., ..);
    let A(.., P, ..);

    // Array/Slice (like with tuple patterns):
    let [..];
    let [..,];
    let [.., .., ..];
    let [.., P, ..];

    // Random walk to guard against special casing:
    match x {
        .. |
        [
            (
                box .., //~ WARN box pattern syntax is experimental
                &(..),
                &mut ..,
                x @ ..
            ),
            ref x @ ..,
        ] |
        ref mut x @ ..
        => {}
    }
    //~| WARN unstable syntax
}