trans: remove remaining boxed closures
This commit is contained in:
parent
977e151b9a
commit
bf52e262e2
3 changed files with 40 additions and 37 deletions
|
@ -669,30 +669,31 @@ pub fn compare_simd_types<'blk, 'tcx>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type val_and_ty_fn<'a, 'blk, 'tcx> =
|
|
||||||
|Block<'blk, 'tcx>, ValueRef, Ty<'tcx>|: 'a -> Block<'blk, 'tcx>;
|
|
||||||
|
|
||||||
// Iterates through the elements of a structural type.
|
// Iterates through the elements of a structural type.
|
||||||
pub fn iter_structural_ty<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
|
||||||
av: ValueRef,
|
av: ValueRef,
|
||||||
t: Ty<'tcx>,
|
t: Ty<'tcx>,
|
||||||
f: val_and_ty_fn<'a, 'blk, 'tcx>)
|
mut f: F)
|
||||||
-> Block<'blk, 'tcx> {
|
-> Block<'blk, 'tcx> where
|
||||||
|
F: FnMut(Block<'blk, 'tcx>, ValueRef, Ty<'tcx>) -> Block<'blk, 'tcx>,
|
||||||
|
{
|
||||||
let _icx = push_ctxt("iter_structural_ty");
|
let _icx = push_ctxt("iter_structural_ty");
|
||||||
|
|
||||||
fn iter_variant<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
fn iter_variant<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
|
||||||
repr: &adt::Repr<'tcx>,
|
repr: &adt::Repr<'tcx>,
|
||||||
av: ValueRef,
|
av: ValueRef,
|
||||||
variant: &ty::VariantInfo<'tcx>,
|
variant: &ty::VariantInfo<'tcx>,
|
||||||
substs: &subst::Substs<'tcx>,
|
substs: &subst::Substs<'tcx>,
|
||||||
f: val_and_ty_fn<'a, 'blk, 'tcx>)
|
f: &mut F)
|
||||||
-> Block<'blk, 'tcx> {
|
-> Block<'blk, 'tcx> where
|
||||||
|
F: FnMut(Block<'blk, 'tcx>, ValueRef, Ty<'tcx>) -> Block<'blk, 'tcx>,
|
||||||
|
{
|
||||||
let _icx = push_ctxt("iter_variant");
|
let _icx = push_ctxt("iter_variant");
|
||||||
let tcx = cx.tcx();
|
let tcx = cx.tcx();
|
||||||
let mut cx = cx;
|
let mut cx = cx;
|
||||||
|
|
||||||
for (i, &arg) in variant.args.iter().enumerate() {
|
for (i, &arg) in variant.args.iter().enumerate() {
|
||||||
cx = f(cx,
|
cx = (*f)(cx,
|
||||||
adt::trans_field_ptr(cx, repr, av, variant.disr_val, i),
|
adt::trans_field_ptr(cx, repr, av, variant.disr_val, i),
|
||||||
arg.subst(tcx, substs));
|
arg.subst(tcx, substs));
|
||||||
}
|
}
|
||||||
|
@ -764,7 +765,7 @@ pub fn iter_structural_ty<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
||||||
match adt::trans_switch(cx, &*repr, av) {
|
match adt::trans_switch(cx, &*repr, av) {
|
||||||
(_match::Single, None) => {
|
(_match::Single, None) => {
|
||||||
cx = iter_variant(cx, &*repr, av, &*(*variants)[0],
|
cx = iter_variant(cx, &*repr, av, &*(*variants)[0],
|
||||||
substs, f);
|
substs, &mut f);
|
||||||
}
|
}
|
||||||
(_match::Switch, Some(lldiscrim_a)) => {
|
(_match::Switch, Some(lldiscrim_a)) => {
|
||||||
cx = f(cx, lldiscrim_a, cx.tcx().types.int);
|
cx = f(cx, lldiscrim_a, cx.tcx().types.int);
|
||||||
|
@ -793,7 +794,7 @@ pub fn iter_structural_ty<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
||||||
data_ptr,
|
data_ptr,
|
||||||
&**variant,
|
&**variant,
|
||||||
substs,
|
substs,
|
||||||
|x,y,z| f(x,y,z));
|
&mut f);
|
||||||
Br(variant_cx, next_cx.llbb);
|
Br(variant_cx, next_cx.llbb);
|
||||||
}
|
}
|
||||||
cx = next_cx;
|
cx = next_cx;
|
||||||
|
|
|
@ -531,13 +531,14 @@ fn declare_generic_glue<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>,
|
||||||
return (fn_nm, llfn);
|
return (fn_nm, llfn);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_generic_glue<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
fn make_generic_glue<'a, 'tcx, F>(ccx: &CrateContext<'a, 'tcx>,
|
||||||
t: Ty<'tcx>,
|
t: Ty<'tcx>,
|
||||||
llfn: ValueRef,
|
llfn: ValueRef,
|
||||||
helper: for<'blk> |Block<'blk, 'tcx>, ValueRef, Ty<'tcx>|
|
helper: F,
|
||||||
-> Block<'blk, 'tcx>,
|
name: &str)
|
||||||
name: &str)
|
-> ValueRef where
|
||||||
-> ValueRef {
|
F: for<'blk> FnOnce(Block<'blk, 'tcx>, ValueRef, Ty<'tcx>) -> Block<'blk, 'tcx>,
|
||||||
|
{
|
||||||
let _icx = push_ctxt("make_generic_glue");
|
let _icx = push_ctxt("make_generic_glue");
|
||||||
let glue_name = format!("glue {} {}", name, ty_to_short_str(ccx.tcx(), t));
|
let glue_name = format!("glue {} {}", name, ty_to_short_str(ccx.tcx(), t));
|
||||||
let _s = StatRecorder::new(ccx, glue_name);
|
let _s = StatRecorder::new(ccx, glue_name);
|
||||||
|
|
|
@ -416,15 +416,14 @@ pub fn get_base_and_len(bcx: Block,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type iter_vec_block<'a, 'blk, 'tcx> =
|
pub fn iter_vec_loop<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
|
||||||
|Block<'blk, 'tcx>, ValueRef, Ty<'tcx>|: 'a -> Block<'blk, 'tcx>;
|
|
||||||
|
|
||||||
pub fn iter_vec_loop<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|
||||||
data_ptr: ValueRef,
|
data_ptr: ValueRef,
|
||||||
vt: &VecTypes<'tcx>,
|
vt: &VecTypes<'tcx>,
|
||||||
count: ValueRef,
|
count: ValueRef,
|
||||||
f: iter_vec_block<'a, 'blk, 'tcx>)
|
f: F)
|
||||||
-> Block<'blk, 'tcx> {
|
-> Block<'blk, 'tcx> where
|
||||||
|
F: FnOnce(Block<'blk, 'tcx>, ValueRef, Ty<'tcx>) -> Block<'blk, 'tcx>,
|
||||||
|
{
|
||||||
let _icx = push_ctxt("tvec::iter_vec_loop");
|
let _icx = push_ctxt("tvec::iter_vec_loop");
|
||||||
let fcx = bcx.fcx;
|
let fcx = bcx.fcx;
|
||||||
|
|
||||||
|
@ -475,12 +474,14 @@ pub fn iter_vec_loop<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
next_bcx
|
next_bcx
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter_vec_raw<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
pub fn iter_vec_raw<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
|
||||||
data_ptr: ValueRef,
|
data_ptr: ValueRef,
|
||||||
unit_ty: Ty<'tcx>,
|
unit_ty: Ty<'tcx>,
|
||||||
len: ValueRef,
|
len: ValueRef,
|
||||||
f: iter_vec_block<'a, 'blk, 'tcx>)
|
f: F)
|
||||||
-> Block<'blk, 'tcx> {
|
-> Block<'blk, 'tcx> where
|
||||||
|
F: FnOnce(Block<'blk, 'tcx>, ValueRef, Ty<'tcx>) -> Block<'blk, 'tcx>,
|
||||||
|
{
|
||||||
let _icx = push_ctxt("tvec::iter_vec_raw");
|
let _icx = push_ctxt("tvec::iter_vec_raw");
|
||||||
let fcx = bcx.fcx;
|
let fcx = bcx.fcx;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue