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