1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
// Here we test type checking of bindings when combined with or-patterns.
// Specifically, we ensure that introducing bindings of different types result in type errors.
fn main() {
enum Blah {
A(isize, isize, usize),
B(isize, isize),
}
match Blah::A(1, 1, 2) {
Blah::A(_, x, y) | Blah::B(x, y) => {} //~ ERROR mismatched types
}
match Some(Blah::A(1, 1, 2)) {
Some(Blah::A(_, x, y) | Blah::B(x, y)) => {} //~ ERROR mismatched types
}
match (0u8, 1u16) {
(x, y) | (y, x) => {} //~ ERROR mismatched types
//~^ ERROR mismatched types
}
match Some((0u8, Some((1u16, 2u32)))) {
Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x)))) => {}
//~^ ERROR mismatched types
//~| ERROR mismatched types
//~| ERROR mismatched types
//~| ERROR mismatched types
_ => {}
}
if let Blah::A(_, x, y) | Blah::B(x, y) = Blah::A(1, 1, 2) {
//~^ ERROR mismatched types
}
if let Some(Blah::A(_, x, y) | Blah::B(x, y)) = Some(Blah::A(1, 1, 2)) {
//~^ ERROR mismatched types
}
if let (x, y) | (y, x) = (0u8, 1u16) {
//~^ ERROR mismatched types
//~| ERROR mismatched types
}
if let Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x))))
//~^ ERROR mismatched types
//~| ERROR mismatched types
//~| ERROR mismatched types
//~| ERROR mismatched types
= Some((0u8, Some((1u16, 2u32))))
{}
let (Blah::A(_, x, y) | Blah::B(x, y)) = Blah::A(1, 1, 2);
//~^ ERROR mismatched types
let ((x, y) | (y, x)) = (0u8, 1u16);
//~^ ERROR mismatched types
//~| ERROR mismatched types
fn f1((Blah::A(_, x, y) | Blah::B(x, y)): Blah) {}
//~^ ERROR mismatched types
fn f2(((x, y) | (y, x)): (u8, u16)) {}
//~^ ERROR mismatched types
//~| ERROR mismatched types
}
|