]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/inline-closure.rs
Rollup merge of #52030 - bowbahdoe:patch-1, r=alexcrichton
[rust.git] / src / test / mir-opt / inline-closure.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. (#45894)
14
15 fn main() {
16     println!("{}", foo(0, 14));
17 }
18
19 fn foo<T: Copy>(_t: T, q: i32) -> i32 {
20     let x = |_t, _q| _t;
21     x(q, q)
22 }
23
24 // END RUST SOURCE
25 // START rustc.foo.Inline.after.mir
26 // ...
27 // bb0: {
28 //     ...
29 //     _3 = [closure@NodeId(28)];
30 //     ...
31 //     _4 = &_3;
32 //     ...
33 //     _6 = _2;
34 //     ...
35 //     _7 = _2;
36 //     _5 = (move _6, move _7);
37 //     _8 = move (_5.0: i32);
38 //     _9 = move (_5.1: i32);
39 //     _0 = _8;
40 //     ...
41 //     return;
42 // }
43 // ...
44 // END rustc.foo.Inline.after.mir