]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/match_false_edges.rs
Rollup merge of #99864 - klensy:bootstrap-art-dupe, r=jyn514
[rust.git] / src / test / mir-opt / match_false_edges.rs
1 fn guard() -> bool {
2     false
3 }
4
5 fn guard2(_: i32) -> bool {
6     true
7 }
8
9 // no_mangle to make sure this gets instantiated even in an executable.
10 #[no_mangle]
11 // EMIT_MIR match_false_edges.full_tested_match.PromoteTemps.after.mir
12 pub fn full_tested_match() {
13     let _ = match Some(42) {
14         Some(x) if guard() => (1, x),
15         Some(y) => (2, y),
16         None => (3, 3),
17     };
18 }
19
20 // no_mangle to make sure this gets instantiated even in an executable.
21 #[no_mangle]
22 // EMIT_MIR match_false_edges.full_tested_match2.PromoteTemps.before.mir
23 pub fn full_tested_match2() {
24     let _ = match Some(42) {
25         Some(x) if guard() => (1, x),
26         None => (3, 3),
27         Some(y) => (2, y),
28     };
29 }
30
31 // EMIT_MIR match_false_edges.main.PromoteTemps.before.mir
32 fn main() {
33     let _ = match Some(1) {
34         Some(_w) if guard() => 1,
35         _x => 2,
36         Some(y) if guard2(y) => 3,
37         _z => 4,
38     };
39 }