]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/inline-closure-borrows-arg.rs
Rollup merge of #52016 - oli-obk:dedup_static_errors, r=estebank
[rust.git] / src / test / mir-opt / inline-closure-borrows-arg.rs
1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // compile-flags: -Z span_free_formats
12
13 // Tests that MIR inliner can handle closure arguments,
14 // even when (#45894)
15
16 fn main() {
17     println!("{}", foo(0, &14));
18 }
19
20 fn foo<T: Copy>(_t: T, q: &i32) -> i32 {
21     let x = |r: &i32, _s: &i32| {
22         let variable = &*r;
23         *variable
24     };
25     x(q, q)
26 }
27
28 // END RUST SOURCE
29 // START rustc.foo.Inline.after.mir
30 // ...
31 // bb0: {
32 //     ...
33 //     _3 = [closure@NodeId(39)];
34 //     ...
35 //     _4 = &_3;
36 //     ...
37 //     _6 = &(*_2);
38 //     ...
39 //     _7 = &(*_2);
40 //     _5 = (move _6, move _7);
41 //     _8 = move (_5.0: &i32);
42 //     _9 = move (_5.1: &i32);
43 //     _0 = (*_8);
44 //     ...
45 //     return;
46 // }
47 // ...
48 // END rustc.foo.Inline.after.mir