about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJorge Aparicio <japaricious@gmail.com>2015-01-04 17:23:01 -0500
committerJorge Aparicio <japaricious@gmail.com>2015-01-05 17:22:14 -0500
commitbf52e262e20efaaadf3fec47f20880ffc171a34f (patch)
treede1b8d4b576b1bb05407851a5c36f2caa9e8dc3b /src
parent977e151b9a74af6cdb92b7afb57a4dbacc799841 (diff)
downloadrust-bf52e262e20efaaadf3fec47f20880ffc171a34f.tar.gz
rust-bf52e262e20efaaadf3fec47f20880ffc171a34f.zip
trans: remove remaining boxed closures
Diffstat (limited to 'src')
-rw-r--r--src/librustc_trans/trans/base.rs37
-rw-r--r--src/librustc_trans/trans/glue.rs15
-rw-r--r--src/librustc_trans/trans/tvec.rs25
3 files changed, 40 insertions, 37 deletions
diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs
index 29811ad6dd5..9814a4ed183 100644
--- a/src/librustc_trans/trans/base.rs
+++ b/src/librustc_trans/trans/base.rs
@@ -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.
-pub fn iter_structural_ty<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>,
-                                          av: ValueRef,
-                                          t: Ty<'tcx>,
-                                          f: val_and_ty_fn<'a, 'blk, 'tcx>)
-                                          -> Block<'blk, 'tcx> {
+pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
+                                         av: ValueRef,
+                                         t: Ty<'tcx>,
+                                         mut f: F)
+                                         -> Block<'blk, 'tcx> where
+    F: FnMut(Block<'blk, 'tcx>, ValueRef, Ty<'tcx>) -> Block<'blk, 'tcx>,
+{
     let _icx = push_ctxt("iter_structural_ty");
 
-    fn iter_variant<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>,
-                                    repr: &adt::Repr<'tcx>,
-                                    av: ValueRef,
-                                    variant: &ty::VariantInfo<'tcx>,
-                                    substs: &subst::Substs<'tcx>,
-                                    f: val_and_ty_fn<'a, 'blk, 'tcx>)
-                                    -> Block<'blk, 'tcx> {
+    fn iter_variant<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
+                                   repr: &adt::Repr<'tcx>,
+                                   av: ValueRef,
+                                   variant: &ty::VariantInfo<'tcx>,
+                                   substs: &subst::Substs<'tcx>,
+                                   f: &mut F)
+                                   -> Block<'blk, 'tcx> where
+        F: FnMut(Block<'blk, 'tcx>, ValueRef, Ty<'tcx>) -> Block<'blk, 'tcx>,
+    {
         let _icx = push_ctxt("iter_variant");
         let tcx = cx.tcx();
         let mut cx = cx;
 
         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),
                    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::Single, None) => {
                   cx = iter_variant(cx, &*repr, av, &*(*variants)[0],
-                                    substs, f);
+                                    substs, &mut f);
               }
               (_match::Switch, Some(lldiscrim_a)) => {
                   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,
                                        &**variant,
                                        substs,
-                                       |x,y,z| f(x,y,z));
+                                       &mut f);
                       Br(variant_cx, next_cx.llbb);
                   }
                   cx = next_cx;
diff --git a/src/librustc_trans/trans/glue.rs b/src/librustc_trans/trans/glue.rs
index c0497041813..116ce2bf51d 100644
--- a/src/librustc_trans/trans/glue.rs
+++ b/src/librustc_trans/trans/glue.rs
@@ -531,13 +531,14 @@ fn declare_generic_glue<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>,
     return (fn_nm, llfn);
 }
 
-fn make_generic_glue<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
-                               t: Ty<'tcx>,
-                               llfn: ValueRef,
-                               helper: for<'blk> |Block<'blk, 'tcx>, ValueRef, Ty<'tcx>|
-                                                  -> Block<'blk, 'tcx>,
-                               name: &str)
-                               -> ValueRef {
+fn make_generic_glue<'a, 'tcx, F>(ccx: &CrateContext<'a, 'tcx>,
+                                  t: Ty<'tcx>,
+                                  llfn: ValueRef,
+                                  helper: F,
+                                  name: &str)
+                                  -> ValueRef where
+    F: for<'blk> FnOnce(Block<'blk, 'tcx>, ValueRef, Ty<'tcx>) -> Block<'blk, 'tcx>,
+{
     let _icx = push_ctxt("make_generic_glue");
     let glue_name = format!("glue {} {}", name, ty_to_short_str(ccx.tcx(), t));
     let _s = StatRecorder::new(ccx, glue_name);
diff --git a/src/librustc_trans/trans/tvec.rs b/src/librustc_trans/trans/tvec.rs
index de71a1c2217..e3288466aa7 100644
--- a/src/librustc_trans/trans/tvec.rs
+++ b/src/librustc_trans/trans/tvec.rs
@@ -416,15 +416,14 @@ pub fn get_base_and_len(bcx: Block,
     }
 }
 
-pub type iter_vec_block<'a, 'blk, 'tcx> =
-    |Block<'blk, 'tcx>, ValueRef, Ty<'tcx>|: 'a -> Block<'blk, 'tcx>;
-
-pub fn iter_vec_loop<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
+pub fn iter_vec_loop<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
                                      data_ptr: ValueRef,
                                      vt: &VecTypes<'tcx>,
                                      count: ValueRef,
-                                     f: iter_vec_block<'a, 'blk, 'tcx>)
-                                     -> Block<'blk, 'tcx> {
+                                     f: F)
+                                     -> Block<'blk, 'tcx> where
+    F: FnOnce(Block<'blk, 'tcx>, ValueRef, Ty<'tcx>) -> Block<'blk, 'tcx>,
+{
     let _icx = push_ctxt("tvec::iter_vec_loop");
     let fcx = bcx.fcx;
 
@@ -475,12 +474,14 @@ pub fn iter_vec_loop<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     next_bcx
 }
 
-pub fn iter_vec_raw<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
-                                    data_ptr: ValueRef,
-                                    unit_ty: Ty<'tcx>,
-                                    len: ValueRef,
-                                    f: iter_vec_block<'a, 'blk, 'tcx>)
-                                    -> Block<'blk, 'tcx> {
+pub fn iter_vec_raw<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
+                                   data_ptr: ValueRef,
+                                   unit_ty: Ty<'tcx>,
+                                   len: ValueRef,
+                                   f: F)
+                                   -> Block<'blk, 'tcx> where
+    F: FnOnce(Block<'blk, 'tcx>, ValueRef, Ty<'tcx>) -> Block<'blk, 'tcx>,
+{
     let _icx = push_ctxt("tvec::iter_vec_raw");
     let fcx = bcx.fcx;