1 // Here we test type checking of bindings when combined with or-patterns.
2 // Specifically, we ensure that introducing bindings of different types result in type errors.
6 A(isize, isize, usize),
10 match Blah::A(1, 1, 2) {
11 Blah::A(_, x, y) | Blah::B(x, y) => {} //~ ERROR mismatched types
14 match Some(Blah::A(1, 1, 2)) {
15 Some(Blah::A(_, x, y) | Blah::B(x, y)) => {} //~ ERROR mismatched types
19 (x, y) | (y, x) => {} //~ ERROR mismatched types
20 //~^ ERROR mismatched types
23 match Some((0u8, Some((1u16, 2u32)))) {
24 Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x)))) => {}
25 //~^ ERROR mismatched types
26 //~| ERROR mismatched types
27 //~| ERROR mismatched types
28 //~| ERROR mismatched types
32 if let Blah::A(_, x, y) | Blah::B(x, y) = Blah::A(1, 1, 2) {
33 //~^ ERROR mismatched types
36 if let Some(Blah::A(_, x, y) | Blah::B(x, y)) = Some(Blah::A(1, 1, 2)) {
37 //~^ ERROR mismatched types
40 if let (x, y) | (y, x) = (0u8, 1u16) {
41 //~^ ERROR mismatched types
42 //~| ERROR mismatched types
45 if let Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x))))
46 //~^ ERROR mismatched types
47 //~| ERROR mismatched types
48 //~| ERROR mismatched types
49 //~| ERROR mismatched types
50 = Some((0u8, Some((1u16, 2u32))))
53 let (Blah::A(_, x, y) | Blah::B(x, y)) = Blah::A(1, 1, 2);
54 //~^ ERROR mismatched types
56 let ((x, y) | (y, x)) = (0u8, 1u16);
57 //~^ ERROR mismatched types
58 //~| ERROR mismatched types
60 fn f1((Blah::A(_, x, y) | Blah::B(x, y)): Blah) {}
61 //~^ ERROR mismatched types
63 fn f2(((x, y) | (y, x)): (u8, u16)) {}
64 //~^ ERROR mismatched types
65 //~| ERROR mismatched types