summary refs log tree commit diff
path: root/src/test/mir-opt/remove_fake_borrows.rs
blob: 965897ad541e78f362328754b06da3d47e0c6c4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Test that the fake borrows for matches are removed after borrow checking.

// ignore-wasm32-bare compiled with panic=abort by default

fn match_guard(x: Option<&&i32>, c: bool) -> i32 {
    match x {
        Some(0) if c => 0,
        _ => 1,
    }
}

fn main() {
    match_guard(None, true);
}

// END RUST SOURCE

// START rustc.match_guard.CleanupNonCodegenStatements.before.mir
// bb0: {
//     FakeRead(ForMatchedPlace, _1);
//     _3 = discriminant(_1);
//     switchInt(move _3) -> [1isize: bb3, otherwise: bb2];
// }
// bb1: {
//     goto -> bb4;
// }
// bb2: {
//     _0 = const 1i32;
//     goto -> bb7;
// }
// bb3: {
//     switchInt((*(*((_1 as Some).0: &'<empty> &'<empty> i32)))) -> [0i32: bb1, otherwise: bb2];
// }
// bb4: {
//     _4 = &shallow _1;
//     _5 = &shallow ((_1 as Some).0: &'<empty> &'<empty> i32);
//     _6 = &shallow (*((_1 as Some).0: &'<empty> &'<empty> i32));
//     _7 = &shallow (*(*((_1 as Some).0: &'<empty> &'<empty> i32)));
//     StorageLive(_8);
//     _8 = _2;
//     switchInt(move _8) -> [false: bb6, otherwise: bb5];
// }
// bb5: {
//     StorageDead(_8);
//     FakeRead(ForMatchGuard, _4);
//     FakeRead(ForMatchGuard, _5);
//     FakeRead(ForMatchGuard, _6);
//     FakeRead(ForMatchGuard, _7);
//     _0 = const 0i32;
//     goto -> bb7;
// }
// bb6: {
//     StorageDead(_8);
//     goto -> bb2;
// }
// bb7: {
//     return;
// }
// bb8 (cleanup): {
//     resume;
// }
// END rustc.match_guard.CleanupNonCodegenStatements.before.mir

// START rustc.match_guard.CleanupNonCodegenStatements.after.mir
// bb0: {
//     nop;
//     _3 = discriminant(_1);
//     switchInt(move _3) -> [1isize: bb3, otherwise: bb2];
// }
// bb1: {
//     goto -> bb4;
// }
// bb2: {
//     _0 = const 1i32;
//     goto -> bb7;
// }
// bb3: {
//     switchInt((*(*((_1 as Some).0: &'<empty> &'<empty> i32)))) -> [0i32: bb1, otherwise: bb2];
// }
// bb4: {
//     nop;
//     nop;
//     nop;
//     nop;
//     StorageLive(_8);
//     _8 = _2;
//     switchInt(move _8) -> [false: bb6, otherwise: bb5];
// }
// bb5: {
//     StorageDead(_8);
//     nop;
//     nop;
//     nop;
//     nop;
//     _0 = const 0i32;
//     goto -> bb7;
// }
// bb6: {
//     StorageDead(_8);
//     goto -> bb2;
// }
// bb7: {
//     return;
// }
// bb8 (cleanup): {
//     resume;
// }
// END rustc.match_guard.CleanupNonCodegenStatements.after.mir