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