]> git.proxmox.com Git - rustc.git/blame - src/test/mir-opt/match_false_edges.rs
New upstream version 1.44.1+dfsg1
[rustc.git] / src / test / mir-opt / match_false_edges.rs
CommitLineData
ff7c6d11 1// compile-flags: -Z borrowck=mir
abe05a73
XL
2
3fn guard() -> bool {
4 false
5}
6
74b04a01 7fn guard2(_: i32) -> bool {
abe05a73
XL
8 true
9}
10
11// no_mangle to make sure this gets instantiated even in an executable.
12#[no_mangle]
ba9703b0 13// EMIT_MIR rustc.full_tested_match.PromoteTemps.after.mir
abe05a73
XL
14pub 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]
ba9703b0 24// EMIT_MIR rustc.full_tested_match2.PromoteTemps.before.mir
abe05a73
XL
25pub 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
ba9703b0 33// EMIT_MIR rustc.main.PromoteTemps.before.mir
abe05a73
XL
34fn 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}