]>
Commit | Line | Data |
---|---|---|
e1599b0c XL |
1 | // This test ensures that the "already bound identifier in a product pattern" |
2 | // correctly accounts for or-patterns. | |
3 | ||
4 | #![feature(or_patterns)] | |
5 | //~^ WARN the feature `or_patterns` is incomplete | |
6 | ||
7 | enum E<T> { A(T, T), B(T) } | |
8 | ||
9 | use E::*; | |
10 | ||
11 | fn main() { | |
12 | let (a, a) = (0, 1); // Standard duplication without an or-pattern. | |
13 | //~^ ERROR identifier `a` is bound more than once in the same pattern | |
14 | ||
15 | let (a, A(a, _) | B(a)) = (0, A(1, 2)); | |
16 | //~^ ERROR identifier `a` is bound more than once in the same pattern | |
17 | //~| ERROR identifier `a` is bound more than once in the same pattern | |
18 | ||
19 | let (A(a, _) | B(a), a) = (A(0, 1), 2); | |
20 | //~^ ERROR identifier `a` is bound more than once in the same pattern | |
21 | ||
22 | let A(a, a) | B(a) = A(0, 1); | |
23 | //~^ ERROR identifier `a` is bound more than once in the same pattern | |
24 | ||
25 | let B(a) | A(a, a) = A(0, 1); | |
26 | //~^ ERROR identifier `a` is bound more than once in the same pattern | |
27 | ||
28 | match A(0, 1) { | |
29 | B(a) | A(a, a) => {} // Let's ensure `match` has no funny business. | |
30 | //~^ ERROR identifier `a` is bound more than once in the same pattern | |
31 | } | |
32 | ||
33 | let B(A(a, _) | B(a)) | A(a, A(a, _) | B(a)) = B(B(1)); | |
34 | //~^ ERROR identifier `a` is bound more than once in the same pattern | |
35 | //~| ERROR identifier `a` is bound more than once in the same pattern | |
36 | //~| ERROR mismatched types | |
37 | ||
38 | let B(_) | A(A(a, _) | B(a), A(a, _) | B(a)) = B(B(1)); | |
39 | //~^ ERROR identifier `a` is bound more than once in the same pattern | |
40 | //~| ERROR identifier `a` is bound more than once in the same pattern | |
41 | //~| ERROR variable `a` is not bound in all patterns | |
42 | ||
43 | let B(A(a, _) | B(a)) | A(A(a, _) | B(a), A(a, _) | B(a)) = B(B(1)); | |
44 | //~^ ERROR identifier `a` is bound more than once in the same pattern | |
45 | //~| ERROR identifier `a` is bound more than once in the same pattern | |
46 | } |