]> git.proxmox.com Git - rustc.git/blob - src/test/mir-opt/early_otherwise_branch_noopt.rs
New upstream version 1.48.0~beta.8+dfsg1
[rustc.git] / src / test / mir-opt / early_otherwise_branch_noopt.rs
1 // compile-flags: -Z mir-opt-level=3
2
3 // must not optimize as it does not follow the pattern of
4 // left and right hand side being the same variant
5
6 // EMIT_MIR early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff
7 fn noopt1(x: Option<u32>, y: Option<u32>) -> u32 {
8 match (x, y) {
9 (Some(a), Some(b)) => 0,
10 (Some(a), None) => 1,
11 (None, Some(b)) => 2,
12 (None, None) => 3,
13 }
14 }
15
16 // must not optimize as the types being matched on are not identical
17 // EMIT_MIR early_otherwise_branch_noopt.noopt2.EarlyOtherwiseBranch.diff
18 fn noopt2(x: Option<u32>, y: Option<bool>) -> u32 {
19 match (x, y) {
20 (Some(a), Some(b)) => 0,
21 _ => 1,
22 }
23 }
24
25 fn main() {
26 noopt1(None, Some(0));
27 noopt2(None, Some(true));
28 }