]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/inline/inline-closure-borrows-arg.rs
Render const pointers in MIR more compactly
[rust.git] / src / test / mir-opt / inline / inline-closure-borrows-arg.rs
1 // compile-flags: -Z span_free_formats
2
3 // Tests that MIR inliner can handle closure arguments,
4 // even when (#45894)
5
6 fn main() {
7     println!("{}", foo(0, &14));
8 }
9
10 fn foo<T: Copy>(_t: T, q: &i32) -> i32 {
11     let x = |r: &i32, _s: &i32| {
12         let variable = &*r;
13         *variable
14     };
15     x(q, q)
16 }
17
18 // END RUST SOURCE
19 // START rustc.foo.Inline.after.mir
20 // fn foo(_1: T, _2: &i32) -> i32{
21 //     debug _t => _1;
22 //     debug q => _2;
23 //     let mut _0: i32;
24 //     let _3: [closure@foo<T>::{{closure}}#0];
25 //     let mut _4: &[closure@foo<T>::{{closure}}#0];
26 //     let mut _5: (&i32, &i32);
27 //     let mut _6: &i32;
28 //     let mut _7: &i32;
29 //     let mut _8: &i32;
30 //     let mut _9: &i32;
31 //     scope 1 {
32 //         debug x => _3;
33 //         scope 2 {
34 //             debug r => _8;
35 //             debug _s => _9;
36 //         }
37 //     }
38 //     scope 3 {
39 //         debug variable => _8;
40 //     }
41 //     bb0: {
42 //         ...
43 //         _3 = [closure@foo::<T>::{{closure}}#0];
44 //         ...
45 //         _4 = &_3;
46 //         ...
47 //         _6 = &(*_2);
48 //         ...
49 //         _7 = &(*_2);
50 //         _5 = (move _6, move _7);
51 //         _8 = move (_5.0: &i32);
52 //         _9 = move (_5.1: &i32);
53 //         ...
54 //         _0 = (*_8);
55 //         ...
56 //         return;
57 //     }
58 // }
59 // END rustc.foo.Inline.after.mir