2016-05-13 19:47:32 -05:00
|
|
|
// 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
|
2016-05-13 19:47:32 -05:00
|
|
|
// ignore-test
|
|
|
|
|
2021-04-03 06:05:11 -05:00
|
|
|
//
|
2018-05-08 08:10:16 -05:00
|
|
|
// compile-flags:-Zprint-mono-items=eager
|
2015-11-02 07:46:39 -06:00
|
|
|
|
|
|
|
#![deny(dead_code)]
|
2017-12-22 08:31:51 -06:00
|
|
|
#![feature(start)]
|
2015-11-02 07:46:39 -06:00
|
|
|
|
2018-05-08 08:10:16 -05:00
|
|
|
//~ MONO_ITEM fn non_generic_closures::temporary[0]
|
2015-11-02 07:46:39 -06:00
|
|
|
fn temporary() {
|
2018-05-08 08:10:16 -05:00
|
|
|
//~ MONO_ITEM fn non_generic_closures::temporary[0]::{{closure}}[0]
|
2015-11-02 07:46:39 -06:00
|
|
|
(|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]
|
2015-11-02 07:46:39 -06:00
|
|
|
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]
|
2015-11-02 07:46:39 -06:00
|
|
|
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]
|
2015-11-02 07:46:39 -06:00
|
|
|
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]
|
2015-11-02 07:46:39 -06:00
|
|
|
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]
|
2015-11-02 07:46:39 -06:00
|
|
|
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]
|
2015-11-02 07:46:39 -06:00
|
|
|
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]
|
2017-12-22 08:31:51 -06:00
|
|
|
#[start]
|
|
|
|
fn start(_: isize, _: *const *const u8) -> isize {
|
2015-11-02 07:46:39 -06:00
|
|
|
temporary();
|
|
|
|
assigned_to_variable_but_not_executed();
|
|
|
|
assigned_to_variable_executed_directly();
|
|
|
|
assigned_to_variable_executed_indirectly();
|
2017-12-22 08:31:51 -06:00
|
|
|
|
|
|
|
0
|
2015-11-02 07:46:39 -06:00
|
|
|
}
|
|
|
|
|
2018-05-08 08:10:16 -05:00
|
|
|
//~ MONO_ITEM fn non_generic_closures::run_closure[0]
|
2015-11-02 07:46:39 -06:00
|
|
|
fn run_closure(f: &Fn(i32)) {
|
|
|
|
f(3);
|
|
|
|
}
|