-
Notifications
You must be signed in to change notification settings - Fork 12.5k
/
inline-closure-borrows-arg.rs
59 lines (55 loc) · 1.3 KB
/
inline-closure-borrows-arg.rs
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
// compile-flags: -Z span_free_formats
// Tests that MIR inliner can handle closure arguments,
// even when (#45894)
fn main() {
println!("{}", foo(0, &14));
}
fn foo<T: Copy>(_t: T, q: &i32) -> i32 {
let x = |r: &i32, _s: &i32| {
let variable = &*r;
*variable
};
x(q, q)
}
// END RUST SOURCE
// START rustc.foo.Inline.after.mir
// fn foo(_1: T, _2: &i32) -> i32{
// debug _t => _1;
// debug q => _2;
// let mut _0: i32;
// let _3: [closure@foo<T>::{{closure}}#0];
// let mut _4: &[closure@foo<T>::{{closure}}#0];
// let mut _5: (&i32, &i32);
// let mut _6: &i32;
// let mut _7: &i32;
// let mut _8: &i32;
// let mut _9: &i32;
// scope 1 {
// debug x => _3;
// scope 2 {
// debug r => _8;
// debug _s => _9;
// }
// }
// scope 3 {
// debug variable => _8;
// }
// bb0: {
// ...
// _3 = [closure@foo::<T>::{{closure}}#0];
// ...
// _4 = &_3;
// ...
// _6 = &(*_2);
// ...
// _7 = &(*_2);
// _5 = (move _6, move _7);
// _8 = move (_5.0: &i32);
// _9 = move (_5.1: &i32);
// ...
// _0 = (*_8);
// ...
// return;
// }
// }
// END rustc.foo.Inline.after.mir