rustc_trans: unbox closures used in let bindings
This commit is contained in:
parent
1e4bbefae1
commit
e47035b9a5
@ -127,7 +127,7 @@ pub const RLIB_BYTECODE_OBJECT_V1_DATA_OFFSET: uint =
|
||||
pub fn find_crate_name(sess: Option<&Session>,
|
||||
attrs: &[ast::Attribute],
|
||||
input: &Input) -> String {
|
||||
let validate = |s: String, span: Option<Span>| {
|
||||
let validate = |&: s: String, span: Option<Span>| {
|
||||
creader::validate_crate_name(sess, s[], span);
|
||||
s
|
||||
};
|
||||
|
@ -431,7 +431,7 @@ unsafe fn optimize_and_codegen(cgcx: &CodegenContext,
|
||||
|
||||
// If we're verifying or linting, add them to the function pass
|
||||
// manager.
|
||||
let addpass = |pass: &str| {
|
||||
let addpass = |&: pass: &str| {
|
||||
pass.with_c_str(|s| llvm::LLVMRustAddPass(fpm, s))
|
||||
};
|
||||
if !config.no_verify { assert!(addpass("verify")); }
|
||||
@ -652,7 +652,7 @@ pub fn run_passes(sess: &Session,
|
||||
|
||||
// Produce final compile outputs.
|
||||
|
||||
let copy_if_one_unit = |ext: &str, output_type: config::OutputType, keep_numbered: bool| {
|
||||
let copy_if_one_unit = |&: ext: &str, output_type: config::OutputType, keep_numbered: bool| {
|
||||
// Three cases:
|
||||
if sess.opts.cg.codegen_units == 1 {
|
||||
// 1) Only one codegen unit. In this case it's no difficulty
|
||||
@ -677,7 +677,7 @@ pub fn run_passes(sess: &Session,
|
||||
}
|
||||
};
|
||||
|
||||
let link_obj = |output_path: &Path| {
|
||||
let link_obj = |&: output_path: &Path| {
|
||||
// Running `ld -r` on a single input is kind of pointless.
|
||||
if sess.opts.cg.codegen_units == 1 {
|
||||
fs::copy(&crate_output.with_extension("0.o"),
|
||||
@ -993,7 +993,7 @@ unsafe fn configure_llvm(sess: &Session) {
|
||||
let mut llvm_c_strs = Vec::new();
|
||||
let mut llvm_args = Vec::new();
|
||||
{
|
||||
let add = |arg: &str| {
|
||||
let mut add = |&mut : arg: &str| {
|
||||
let s = arg.to_c_str();
|
||||
llvm_args.push(s.as_ptr());
|
||||
llvm_c_strs.push(s);
|
||||
|
@ -748,7 +748,7 @@ fn pick_column_to_specialize(def_map: &DefMap, m: &[Match]) -> Option<uint> {
|
||||
}
|
||||
}
|
||||
|
||||
let column_score: |&[Match], uint| -> uint = |m, col| {
|
||||
let column_score = |&: m: &[Match], col: uint| -> uint {
|
||||
let total_score = m.iter()
|
||||
.map(|row| row.pats[col])
|
||||
.map(|pat| pat_score(def_map, pat))
|
||||
|
@ -554,7 +554,7 @@ pub fn compare_scalar_types<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
||||
t: Ty<'tcx>,
|
||||
op: ast::BinOp)
|
||||
-> Result<'blk, 'tcx> {
|
||||
let f = |a| Result::new(cx, compare_scalar_values(cx, lhs, rhs, a, op));
|
||||
let f = |&: a| Result::new(cx, compare_scalar_values(cx, lhs, rhs, a, op));
|
||||
|
||||
match t.sty {
|
||||
ty::ty_tup(ref tys) if tys.is_empty() => f(nil_type),
|
||||
@ -2749,7 +2749,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
|
||||
let val = match item {
|
||||
ast_map::NodeItem(i) => {
|
||||
let ty = ty::node_id_to_type(ccx.tcx(), i.id);
|
||||
let sym = || exported_name(ccx, id, ty, i.attrs[]);
|
||||
let sym = |&:| exported_name(ccx, id, ty, i.attrs[]);
|
||||
|
||||
let v = match i.node {
|
||||
ast::ItemStatic(_, _, ref expr) => {
|
||||
@ -3013,14 +3013,14 @@ fn internalize_symbols(cx: &SharedCrateContext, reachable: &HashSet<String>) {
|
||||
unsafe {
|
||||
let mut declared = HashSet::new();
|
||||
|
||||
let iter_globals = |llmod| {
|
||||
let iter_globals = |&: llmod| {
|
||||
ValueIter {
|
||||
cur: llvm::LLVMGetFirstGlobal(llmod),
|
||||
step: llvm::LLVMGetNextGlobal,
|
||||
}
|
||||
};
|
||||
|
||||
let iter_functions = |llmod| {
|
||||
let iter_functions = |&: llmod| {
|
||||
ValueIter {
|
||||
cur: llvm::LLVMGetFirstFunction(llmod),
|
||||
step: llvm::LLVMGetNextFunction,
|
||||
|
@ -305,7 +305,7 @@ pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, e: &ast::Expr)
|
||||
// the bool returned is whether this expression can be inlined into other crates
|
||||
// if it's assigned to a static.
|
||||
fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef {
|
||||
let map_list = |exprs: &[P<ast::Expr>]| {
|
||||
let map_list = |&: exprs: &[P<ast::Expr>]| {
|
||||
exprs.iter().map(|e| const_expr(cx, &**e).0)
|
||||
.fold(Vec::new(), |mut l, val| { l.push(val); l })
|
||||
};
|
||||
|
@ -2489,7 +2489,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
})
|
||||
.collect();
|
||||
|
||||
let discriminant_type_metadata = |inttype| {
|
||||
let discriminant_type_metadata = |&: inttype| {
|
||||
// We can reuse the type of the discriminant for all monomorphized
|
||||
// instances of an enum because it doesn't depend on any type parameters.
|
||||
// The def_id, uniquely identifying the enum's polytype acts as key in
|
||||
|
@ -615,7 +615,7 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
// Array for the arguments we will pass to the rust function.
|
||||
let mut llrust_args = Vec::new();
|
||||
let mut next_foreign_arg_counter: c_uint = 0;
|
||||
let next_foreign_arg: |pad: bool| -> c_uint = |pad: bool| {
|
||||
let mut next_foreign_arg = |&mut : pad: bool| -> c_uint {
|
||||
next_foreign_arg_counter += if pad {
|
||||
2
|
||||
} else {
|
||||
|
@ -181,7 +181,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
// This should be caught by the intrinsicck pass
|
||||
assert_eq!(in_type_size, out_type_size);
|
||||
|
||||
let nonpointer_nonaggregate = |llkind: TypeKind| -> bool {
|
||||
let nonpointer_nonaggregate = |&: llkind: TypeKind| -> bool {
|
||||
use llvm::TypeKind::*;
|
||||
match llkind {
|
||||
Half | Float | Double | X86_FP80 | FP128 |
|
||||
|
@ -139,7 +139,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
|
||||
// This shouldn't need to option dance.
|
||||
let mut hash_id = Some(hash_id);
|
||||
let mk_lldecl = |abi: abi::Abi| {
|
||||
let mut mk_lldecl = |&mut : abi: abi::Abi| {
|
||||
let lldecl = if abi != abi::Rust {
|
||||
foreign::decl_rust_fn_with_foreign_abi(ccx, mono_ty, s[])
|
||||
} else {
|
||||
@ -149,7 +149,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
ccx.monomorphized().borrow_mut().insert(hash_id.take().unwrap(), lldecl);
|
||||
lldecl
|
||||
};
|
||||
let setup_lldecl = |lldecl, attrs: &[ast::Attribute]| {
|
||||
let setup_lldecl = |&: lldecl, attrs: &[ast::Attribute]| {
|
||||
base::update_linkage(ccx, lldecl, None, base::OriginalTranslation);
|
||||
set_llvm_fn_attrs(ccx, attrs, lldecl);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user