summary refs log tree commit diff
path: root/src/test/mir-opt/remove_fake_borrows.rs
blob: 144348450a91b5aa34edce9ca7980e2d5afee8b7 (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
109
110
111
112
113
114
115
116
117
118
119
120
// Test that the fake borrows for matches are removed after borrow checking.

// ignore-wasm32-bare

#![feature(nll)]

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: bb5, otherwise: bb2];
// }
// bb1: {
//     goto -> bb7;
// }
// bb2: {
//     goto -> bb8;
// }
// bb3: {
//     unreachable;
// }
// bb4: {
//     goto -> bb2;
// }
// bb5: {
//     switchInt((*(*((_1 as Some).0: &'<empty> &'<empty> i32)))) -> [0i32: bb1, otherwise: bb2];
// }
// bb6: {
//     _0 = const 0i32;
//     goto -> bb9;
// }
// bb7: {
//     _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;
//     FakeRead(ForMatchGuard, _4);
//     FakeRead(ForMatchGuard, _5);
//     FakeRead(ForMatchGuard, _6);
//     FakeRead(ForMatchGuard, _7);
//     switchInt(move _8) -> [false: bb4, otherwise: bb6];
// }
// bb8: {
//     _0 = const 1i32;
//     goto -> bb9;
// }
// bb9: {
//     StorageDead(_8);
//     return;
// }
// bb10 (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: bb5, otherwise: bb2];
// }
// bb1: {
//     goto -> bb7;
// }
// bb2: {
//     goto -> bb8;
// }
// bb3: {
//     unreachable;
// }
// bb4: {
//     goto -> bb2;
// }
// bb5: {
//     switchInt((*(*((_1 as Some).0: &'<empty> &'<empty> i32)))) -> [0i32: bb1, otherwise: bb2];
// }
// bb6: {
//     _0 = const 0i32;
//     goto -> bb9;
// }
// bb7: {
//     nop;
//     nop;
//     nop;
//     nop;
//     StorageLive(_8);
//     _8 = _2;
//     nop;
//     nop;
//     nop;
//     nop;
//     switchInt(move _8) -> [false: bb4, otherwise: bb6];
// }
// bb8: {
//     _0 = const 1i32;
//     goto -> bb9;
// }
// bb9: {
//     StorageDead(_8);
//     return;
// }
// bb10 (cleanup): {
//     resume;
// }
// END rustc.match_guard.CleanupNonCodegenStatements.after.mir