]> git.lizzy.rs Git - rust.git/blob - tests/mir-opt/inline/inline_closure_borrows_arg.rs
Rollup merge of #106797 - FawazTirmizi:dev/issues/104284, r=bjorn3
[rust.git] / tests / mir-opt / inline / inline_closure_borrows_arg.rs
1 // compile-flags: -Z span_free_formats -Zunsound-mir-opts
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 // EMIT_MIR inline_closure_borrows_arg.foo.Inline.after.mir
11 fn foo<T: Copy>(_t: T, q: &i32) -> i32 {
12     let x = |r: &i32, _s: &i32| {
13         let variable = &*r;
14         *variable
15     };
16     x(q, q)
17 }