]> git.proxmox.com Git - rustc.git/blob - src/test/codegen-units/item-collection/non-generic-closures.rs
New upstream version 1.12.0+dfsg1
[rustc.git] / src / test / codegen-units / item-collection / non-generic-closures.rs
1 // Copyright 2012-2015 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 // In the current version of the collector that still has to support
12 // legacy-trans, closures do not generate their own TransItems, so we are
13 // ignoring this test until MIR trans has taken over completely
14 // ignore-test
15
16 // ignore-tidy-linelength
17 // compile-flags:-Zprint-trans-items=eager
18
19 #![deny(dead_code)]
20
21 //~ TRANS_ITEM fn non_generic_closures::temporary[0]
22 fn temporary() {
23 //~ TRANS_ITEM fn non_generic_closures::temporary[0]::{{closure}}[0]
24 (|a: u32| {
25 let _ = a;
26 })(4);
27 }
28
29 //~ TRANS_ITEM fn non_generic_closures::assigned_to_variable_but_not_executed[0]
30 fn assigned_to_variable_but_not_executed() {
31 //~ TRANS_ITEM fn non_generic_closures::assigned_to_variable_but_not_executed[0]::{{closure}}[0]
32 let _x = |a: i16| {
33 let _ = a + 1;
34 };
35 }
36
37 //~ TRANS_ITEM fn non_generic_closures::assigned_to_variable_executed_directly[0]
38 fn assigned_to_variable_executed_indirectly() {
39 //~ TRANS_ITEM fn non_generic_closures::assigned_to_variable_executed_directly[0]::{{closure}}[0]
40 let f = |a: i32| {
41 let _ = a + 2;
42 };
43 run_closure(&f);
44 }
45
46 //~ TRANS_ITEM fn non_generic_closures::assigned_to_variable_executed_indirectly[0]
47 fn assigned_to_variable_executed_directly() {
48 //~ TRANS_ITEM fn non_generic_closures::assigned_to_variable_executed_indirectly[0]::{{closure}}[0]
49 let f = |a: i64| {
50 let _ = a + 3;
51 };
52 f(4);
53 }
54
55 //~ TRANS_ITEM fn non_generic_closures::main[0]
56 fn main() {
57 temporary();
58 assigned_to_variable_but_not_executed();
59 assigned_to_variable_executed_directly();
60 assigned_to_variable_executed_indirectly();
61 }
62
63 //~ TRANS_ITEM fn non_generic_closures::run_closure[0]
64 fn run_closure(f: &Fn(i32)) {
65 f(3);
66 }