rust/tests/codegen-units/item-collection/non-generic-closures.rs

61 lines
1.7 KiB
Rust
Raw Normal View History

// In the current version of the collector that still has to support
2018-05-08 08:10:16 -05:00
// legacy-codegen, closures do not generate their own MonoItems, so we are
// ignoring this test until MIR codegen has taken over completely
// ignore-test
//
2018-05-08 08:10:16 -05:00
// compile-flags:-Zprint-mono-items=eager
#![deny(dead_code)]
#![feature(start)]
2018-05-08 08:10:16 -05:00
//~ MONO_ITEM fn non_generic_closures::temporary[0]
fn temporary() {
2018-05-08 08:10:16 -05:00
//~ MONO_ITEM fn non_generic_closures::temporary[0]::{{closure}}[0]
(|a: u32| {
let _ = a;
})(4);
}
2018-05-08 08:10:16 -05:00
//~ MONO_ITEM fn non_generic_closures::assigned_to_variable_but_not_executed[0]
fn assigned_to_variable_but_not_executed() {
2018-05-08 08:10:16 -05:00
//~ MONO_ITEM fn non_generic_closures::assigned_to_variable_but_not_executed[0]::{{closure}}[0]
let _x = |a: i16| {
let _ = a + 1;
};
}
2018-05-08 08:10:16 -05:00
//~ MONO_ITEM fn non_generic_closures::assigned_to_variable_executed_directly[0]
fn assigned_to_variable_executed_indirectly() {
2018-05-08 08:10:16 -05:00
//~ MONO_ITEM fn non_generic_closures::assigned_to_variable_executed_directly[0]::{{closure}}[0]
let f = |a: i32| {
let _ = a + 2;
};
run_closure(&f);
}
2018-05-08 08:10:16 -05:00
//~ MONO_ITEM fn non_generic_closures::assigned_to_variable_executed_indirectly[0]
fn assigned_to_variable_executed_directly() {
2018-05-08 08:10:16 -05:00
//~ MONO_ITEM fn non_generic_closures::assigned_to_variable_executed_indirectly[0]::{{closure}}[0]
let f = |a: i64| {
let _ = a + 3;
};
f(4);
}
2018-05-08 08:10:16 -05:00
//~ MONO_ITEM fn non_generic_closures::start[0]
#[start]
fn start(_: isize, _: *const *const u8) -> isize {
temporary();
assigned_to_variable_but_not_executed();
assigned_to_variable_executed_directly();
assigned_to_variable_executed_indirectly();
0
}
2018-05-08 08:10:16 -05:00
//~ MONO_ITEM fn non_generic_closures::run_closure[0]
fn run_closure(f: &Fn(i32)) {
f(3);
}