]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/match_test.rs
a5317f98ef1885df9f20df65aae3a88a0172671d
[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 _4) -> [false: bb7, otherwise: bb8];
24 //    }
25 //    bb1: {
26 //        falseEdges -> [real: bb12, imaginary: bb2];
27 //    }
28 //    bb2: {
29 //        falseEdges -> [real: bb13, imaginary: bb3];
30 //    }
31 //    bb3: {
32 //        falseEdges -> [real: bb14, imaginary: bb4];
33 //    }
34 //    bb4: {
35 //        falseEdges -> [real: bb15, imaginary: bb5];
36 //    }
37 //    bb5: {
38 //        unreachable;
39 //    }
40 //    bb6: {
41 //        falseEdges -> [real: bb4, imaginary: bb2];
42 //    }
43 //    bb7: {
44 //        _6 = Le(const 10i32, _1);
45 //        switchInt(move _6) -> [false: bb9, otherwise: bb10];
46 //    }
47 //    bb8: {
48 //        _5 = Lt(_1, const 10i32);
49 //        switchInt(move _5) -> [false: bb7, otherwise: bb1];
50 //    }
51 //    bb9: {
52 //        switchInt(_1) -> [-1i32: bb3, otherwise: bb4];
53 //    }
54 //    bb10: {
55 //        _7 = Le(_1, const 20i32);
56 //        switchInt(move _7) -> [false: bb9, otherwise: bb2];
57 //    }
58 //    bb11: {
59 //        _3 = const 0i32;
60 //        goto -> bb16;
61 //    }
62 //    bb12: {
63 //        _8 = &shallow _1;
64 //        StorageLive(_9);
65 //        _9 = _2;
66 //        FakeRead(ForMatchGuard, _8);
67 //        switchInt(move _9) -> [false: bb6, otherwise: bb11];
68 //    }
69 //    bb13: {
70 //        _3 = const 1i32;
71 //        goto -> bb16;
72 //    }
73 //    bb14: {
74 //        _3 = const 2i32;
75 //        goto -> bb16;
76 //    }
77 //    bb15: {
78 //        _3 = const 3i32;
79 //        goto -> bb16;
80 //    }
81 //    bb16: {
82 //        StorageDead(_9);
83 //        _0 = ();
84 //        StorageDead(_2);
85 //        StorageDead(_1);
86 //        return;
87 //    }
88 // END rustc.main.SimplifyCfg-initial.after.mir