blob: b5adb4a2b66940a110beea35e641fd758951f1b0 (
plain)
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
67
68
69
70
71
72
73
74
75
76
|
#![allow(unused)]
fn test_if() -> i32 {
let x = if true {
eprintln!("hello");
3;
}
else {
4;
};
x //~ ERROR mismatched types
}
fn test_if_without_binding() -> i32 {
if true { //~ ERROR mismatched types
eprintln!("hello");
3;
}
else { //~ ERROR mismatched types
4;
}
}
fn test_match() -> i32 {
let v = 1;
let res = match v {
1 => { 1; }
_ => { 2; }
};
res //~ ERROR mismatched types
}
fn test_match_match_without_binding() -> i32 {
let v = 1;
match v {
1 => { 1; } //~ ERROR mismatched types
_ => { 2; } //~ ERROR mismatched types
}
}
fn test_match_arm_different_types() -> i32 {
let v = 1;
let res = match v {
1 => { if 1 < 2 { 1 } else { 2 } }
_ => { 2; } //~ ERROR `match` arms have incompatible types
};
res
}
fn test_if_match_mixed() -> i32 {
let x = if true {
3;
} else {
match 1 {
1 => { 1 }
_ => { 2 }
};
};
x //~ ERROR mismatched types
}
fn test_if_match_mixed_failed() -> i32 {
let x = if true {
3;
} else {
// because this is a tailed expr, so we won't check deeper
match 1 {
1 => { 33; }
_ => { 44; }
}
};
x //~ ERROR mismatched types
}
fn main() {}
|