]> git.proxmox.com Git - rustc.git/blame - src/test/ui/or-patterns/already-bound-name.rs
New upstream version 1.52.0~beta.3+dfsg1
[rustc.git] / src / test / ui / or-patterns / already-bound-name.rs
CommitLineData
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)]
e1599b0c
XL
5
6enum E<T> { A(T, T), B(T) }
7
8use E::*;
9
10fn main() {
11 let (a, a) = (0, 1); // Standard duplication without an or-pattern.
12 //~^ ERROR identifier `a` is bound more than once in the same pattern
13
14 let (a, A(a, _) | B(a)) = (0, A(1, 2));
15 //~^ ERROR identifier `a` is bound more than once in the same pattern
16 //~| ERROR identifier `a` is bound more than once in the same pattern
17
18 let (A(a, _) | B(a), a) = (A(0, 1), 2);
19 //~^ ERROR identifier `a` is bound more than once in the same pattern
20
6a06907d 21 let (A(a, a) | B(a)) = A(0, 1);
e1599b0c
XL
22 //~^ ERROR identifier `a` is bound more than once in the same pattern
23
6a06907d 24 let (B(a) | A(a, a)) = A(0, 1);
e1599b0c
XL
25 //~^ ERROR identifier `a` is bound more than once in the same pattern
26
27 match A(0, 1) {
28 B(a) | A(a, a) => {} // Let's ensure `match` has no funny business.
29 //~^ ERROR identifier `a` is bound more than once in the same pattern
30 }
31
6a06907d 32 let (B(A(a, _) | B(a)) | A(a, A(a, _) | B(a))) = B(B(1));
e1599b0c
XL
33 //~^ ERROR identifier `a` is bound more than once in the same pattern
34 //~| ERROR identifier `a` is bound more than once in the same pattern
35 //~| ERROR mismatched types
36
6a06907d 37 let (B(_) | A(A(a, _) | B(a), A(a, _) | B(a))) = B(B(1));
e1599b0c
XL
38 //~^ ERROR identifier `a` is bound more than once in the same pattern
39 //~| ERROR identifier `a` is bound more than once in the same pattern
40 //~| ERROR variable `a` is not bound in all patterns
41
6a06907d 42 let (B(A(a, _) | B(a)) | A(A(a, _) | B(a), A(a, _) | B(a))) = B(B(1));
e1599b0c
XL
43 //~^ ERROR identifier `a` is bound more than once in the same pattern
44 //~| ERROR identifier `a` is bound more than once in the same pattern
45}