]>
Commit | Line | Data |
---|---|---|
6a06907d XL |
1 | // This test tests the precedence of `|` (or-patterns) undelimited nested patterns. In particular, |
2 | // we want to reserve the syntactic space of a pattern followed by a type annotation for possible | |
3 | // future type ascription, so we need to make sure that any time a pattern is followed by type | |
4 | // annotation (for now), the pattern is not a top-level or-pattern. However, there are also a few | |
5 | // types of patterns that allow undelimited subpatterns that could cause the same ambiguity. | |
6 | // Currently, those should be impossible due to precedence rule. This test enforces that. | |
7 | ||
6a06907d XL |
8 | enum E { |
9 | A, | |
10 | B, | |
11 | } | |
12 | ||
13 | fn foo() { | |
14 | use E::*; | |
15 | ||
16 | // ok | |
17 | let b @ (A | B): E = A; | |
18 | ||
19 | let b @ A | B: E = A; //~ERROR `b` is not bound in all patterns | |
20 | //~^ ERROR top-level or-patterns are not allowed | |
21 | } | |
22 | ||
23 | enum F { | |
24 | A(usize), | |
25 | B(usize), | |
26 | } | |
27 | ||
28 | fn bar() { | |
29 | use F::*; | |
30 | ||
31 | // ok | |
32 | let (A(x) | B(x)): F = A(3); | |
33 | ||
34 | let &A(_) | B(_): F = A(3); //~ERROR mismatched types | |
35 | //~^ ERROR top-level or-patterns are not allowed | |
36 | let &&A(_) | B(_): F = A(3); //~ERROR mismatched types | |
37 | //~^ ERROR top-level or-patterns are not allowed | |
38 | let &mut A(_) | B(_): F = A(3); //~ERROR mismatched types | |
39 | //~^ ERROR top-level or-patterns are not allowed | |
40 | let &&mut A(_) | B(_): F = A(3); //~ERROR mismatched types | |
41 | //~^ ERROR top-level or-patterns are not allowed | |
42 | } | |
43 | ||
44 | fn main() {} |