]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/match_test.rs
Render const pointers in MIR more compactly
[rust.git] / src / test / mir-opt / match_test.rs
1 // Make sure redundant testing paths in `match` expressions are sorted out.
2
3 #![feature(exclusive_range_pattern)]
4
5 fn main() {
6     let x = 3;
7     let b = true;
8
9     // When `(0..=10).contains(x) && !b`, we should jump to the last arm
10     // without testing two other candidates.
11     match x {
12         0..10 if b => 0,
13         10..=20 => 1,
14         -1 => 2,
15         _ => 3,
16     };
17 }
18
19 // END RUST SOURCE
20 // START rustc.main.SimplifyCfg-initial.after.mir
21 //    bb0: {
22 //        ...
23 //        switchInt(move _6) -> [false: bb6, otherwise: bb5];
24 //    }
25 //    bb1: {
26 //        falseEdges -> [real: bb9, imaginary: bb2];
27 //    }
28 //    bb2: {
29 //        falseEdges -> [real: bb12, imaginary: bb3];
30 //    }
31 //    bb3: {
32 //        falseEdges -> [real: bb13, imaginary: bb4];
33 //    }
34 //    bb4: {
35 //        _3 = const 3i32;
36 //        goto -> bb14;
37 //    }
38 //    bb5: {
39 //        _7 = Lt(_1, const 10i32);
40 //        switchInt(move _7) -> [false: bb6, otherwise: bb1];
41 //    }
42 //    bb6: {
43 //        _4 = Le(const 10i32, _1);
44 //        switchInt(move _4) -> [false: bb8, otherwise: bb7];
45 //    }
46 //    bb7: {
47 //        _5 = Le(_1, const 20i32);
48 //        switchInt(move _5) -> [false: bb8, otherwise: bb2];
49 //    }
50 //    bb8: {
51 //        switchInt(_1) -> [-1i32: bb3, otherwise: bb4];
52 //    }
53 //    bb9: {
54 //        _8 = &shallow _1;
55 //        StorageLive(_9);
56 //        _9 = _2;
57 //        switchInt(move _9) -> [false: bb11, otherwise: bb10];
58 //    }
59 //    bb10: {
60 //        StorageDead(_9);
61 //        FakeRead(ForMatchGuard, _8);
62 //        _3 = const 0i32;
63 //        goto -> bb14;
64 //    }
65 //    bb11: {
66 //        StorageDead(_9);
67 //        falseEdges -> [real: bb4, imaginary: bb2];
68 //    }
69 //    bb12: {
70 //        _3 = const 1i32;
71 //        goto -> bb14;
72 //    }
73 //    bb13: {
74 //        _3 = const 2i32;
75 //        goto -> bb14;
76 //    }
77 //    bb14: {
78 //        StorageDead(_3);
79 //        _0 = ();
80 //        StorageDead(_2);
81 //        StorageDead(_1);
82 //        return;
83 //    }
84 // END rustc.main.SimplifyCfg-initial.after.mir