2015-11-02 07:46:39 -06:00
|
|
|
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2016-05-13 19:47:32 -05:00
|
|
|
// In the current version of the collector that still has to support
|
|
|
|
// legacy-trans, closures do not generate their own TransItems, so we are
|
|
|
|
// ignoring this test until MIR trans has taken over completely
|
|
|
|
// ignore-test
|
|
|
|
|
2015-11-02 07:46:39 -06:00
|
|
|
// ignore-tidy-linelength
|
|
|
|
// compile-flags:-Zprint-trans-items=eager
|
|
|
|
|
|
|
|
#![deny(dead_code)]
|
2017-12-22 08:31:51 -06:00
|
|
|
#![feature(start)]
|
2015-11-02 07:46:39 -06:00
|
|
|
|
|
|
|
//~ TRANS_ITEM fn non_generic_closures::temporary[0]
|
|
|
|
fn temporary() {
|
|
|
|
//~ TRANS_ITEM fn non_generic_closures::temporary[0]::{{closure}}[0]
|
|
|
|
(|a: u32| {
|
|
|
|
let _ = a;
|
|
|
|
})(4);
|
|
|
|
}
|
|
|
|
|
|
|
|
//~ TRANS_ITEM fn non_generic_closures::assigned_to_variable_but_not_executed[0]
|
|
|
|
fn assigned_to_variable_but_not_executed() {
|
|
|
|
//~ TRANS_ITEM fn non_generic_closures::assigned_to_variable_but_not_executed[0]::{{closure}}[0]
|
|
|
|
let _x = |a: i16| {
|
|
|
|
let _ = a + 1;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
//~ TRANS_ITEM fn non_generic_closures::assigned_to_variable_executed_directly[0]
|
|
|
|
fn assigned_to_variable_executed_indirectly() {
|
|
|
|
//~ TRANS_ITEM fn non_generic_closures::assigned_to_variable_executed_directly[0]::{{closure}}[0]
|
|
|
|
let f = |a: i32| {
|
|
|
|
let _ = a + 2;
|
|
|
|
};
|
|
|
|
run_closure(&f);
|
|
|
|
}
|
|
|
|
|
|
|
|
//~ TRANS_ITEM fn non_generic_closures::assigned_to_variable_executed_indirectly[0]
|
|
|
|
fn assigned_to_variable_executed_directly() {
|
|
|
|
//~ TRANS_ITEM fn non_generic_closures::assigned_to_variable_executed_indirectly[0]::{{closure}}[0]
|
|
|
|
let f = |a: i64| {
|
|
|
|
let _ = a + 3;
|
|
|
|
};
|
|
|
|
f(4);
|
|
|
|
}
|
|
|
|
|
2017-12-22 08:31:51 -06:00
|
|
|
//~ TRANS_ITEM fn non_generic_closures::start[0]
|
|
|
|
#[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
|
|
|
}
|
|
|
|
|
|
|
|
//~ TRANS_ITEM fn non_generic_closures::run_closure[0]
|
|
|
|
fn run_closure(f: &Fn(i32)) {
|
|
|
|
f(3);
|
|
|
|
}
|