1 // This test ensures that the "already bound identifier in a product pattern"
2 // correctly accounts for or-patterns.
4 enum E<T> { A(T, T), B(T) }
9 let (a, a) = (0, 1); // Standard duplication without an or-pattern.
10 //~^ ERROR identifier `a` is bound more than once in the same pattern
12 let (a, A(a, _) | B(a)) = (0, A(1, 2));
13 //~^ ERROR identifier `a` is bound more than once in the same pattern
14 //~| ERROR identifier `a` is bound more than once in the same pattern
16 let (A(a, _) | B(a), a) = (A(0, 1), 2);
17 //~^ ERROR identifier `a` is bound more than once in the same pattern
19 let (A(a, a) | B(a)) = A(0, 1);
20 //~^ ERROR identifier `a` is bound more than once in the same pattern
22 let (B(a) | A(a, a)) = A(0, 1);
23 //~^ ERROR identifier `a` is bound more than once in the same pattern
26 B(a) | A(a, a) => {} // Let's ensure `match` has no funny business.
27 //~^ ERROR identifier `a` is bound more than once in the same pattern
30 let (B(A(a, _) | B(a)) | A(a, A(a, _) | B(a))) = B(B(1));
31 //~^ ERROR identifier `a` is bound more than once in the same pattern
32 //~| ERROR identifier `a` is bound more than once in the same pattern
33 //~| ERROR mismatched types
35 let (B(_) | A(A(a, _) | B(a), A(a, _) | B(a))) = B(B(1));
36 //~^ ERROR identifier `a` is bound more than once in the same pattern
37 //~| ERROR identifier `a` is bound more than once in the same pattern
38 //~| ERROR variable `a` is not bound in all patterns
40 let (B(A(a, _) | B(a)) | A(A(a, _) | B(a), A(a, _) | B(a))) = B(B(1));
41 //~^ ERROR identifier `a` is bound more than once in the same pattern
42 //~| ERROR identifier `a` is bound more than once in the same pattern