]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/matches_reduce_branches.rs
Rollup merge of #75485 - RalfJung:pin, r=nagisa
[rust.git] / src / test / mir-opt / matches_reduce_branches.rs
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
4
5 fn foo(bar: Option<()>) {
6     if matches!(bar, None) {
7       ()
8     }
9 }
10
11 fn bar(i: i32) -> (bool, bool, bool, bool) {
12     let a;
13     let b;
14     let c;
15     let d;
16
17     match i {
18         7 => {
19             a = false;
20             b = true;
21             c = false;
22             d = true;
23             ()
24         }
25         _ => {
26             a = true;
27             b = false;
28             c = false;
29             d = true;
30             ()
31         }
32     };
33
34     (a, b, c, d)
35 }
36
37
38 fn main() {
39   let _ = foo(None);
40   let _ = foo(Some(()));
41   let _ = bar(0);
42 }