]> git.proxmox.com Git - rustc.git/blame - src/test/mir-opt/matches_reduce_branches.rs
Update upstream source from tag 'upstream/1.49.0_beta.4+dfsg1'
[rustc.git] / src / test / mir-opt / matches_reduce_branches.rs
CommitLineData
3dfed10e
XL
1// EMIT_MIR_FOR_EACH_BIT_WIDTH
2// EMIT_MIR matches_reduce_branches.foo.MatchBranchSimplification.diff
3// EMIT_MIR matches_reduce_branches.bar.MatchBranchSimplification.diff
29967ef6 4// EMIT_MIR matches_reduce_branches.match_nested_if.MatchBranchSimplification.diff
3dfed10e
XL
5
6fn foo(bar: Option<()>) {
7 if matches!(bar, None) {
8 ()
9 }
10}
11
12fn bar(i: i32) -> (bool, bool, bool, bool) {
13 let a;
14 let b;
15 let c;
16 let d;
17
18 match i {
19 7 => {
20 a = false;
21 b = true;
22 c = false;
23 d = true;
24 ()
25 }
26 _ => {
27 a = true;
28 b = false;
29 c = false;
30 d = true;
31 ()
32 }
33 };
34
35 (a, b, c, d)
36}
37
29967ef6
XL
38fn match_nested_if() -> bool {
39 let val = match () {
40 () if if if if true {true} else {false} {true} else {false} {true} else {false} => true,
41 _ => false,
42 };
43 val
44}
3dfed10e
XL
45
46fn main() {
47 let _ = foo(None);
48 let _ = foo(Some(()));
49 let _ = bar(0);
29967ef6 50 let _ = match_nested_if();
3dfed10e 51}