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