]> git.lizzy.rs Git - rust.git/commitdiff
trans: remove dead code
authorJorge Aparicio <japaricious@gmail.com>
Sun, 4 Jan 2015 15:50:24 +0000 (10:50 -0500)
committerJorge Aparicio <japaricious@gmail.com>
Mon, 5 Jan 2015 22:22:16 +0000 (17:22 -0500)
src/librustc_trans/trans/callee.rs
src/librustc_trans/trans/closure.rs
src/librustc_trans/trans/consts.rs
src/librustc_trans/trans/expr.rs

index 11f52ad62202ea7e6a2ca41b54f6d3ce501e7d00..f598083c5e44ae84d1b8d4227472172764e47185 100644 (file)
@@ -19,7 +19,7 @@
 pub use self::CallArgs::*;
 
 use arena::TypedArena;
-use back::{abi,link};
+use back::link;
 use session;
 use llvm::{ValueRef};
 use llvm::get_param;
@@ -100,7 +100,7 @@ fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr)
 
     fn datum_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr)
                                 -> Callee<'blk, 'tcx> {
-        let DatumBlock {mut bcx, datum} = expr::trans(bcx, expr);
+        let DatumBlock { datum, .. } = expr::trans(bcx, expr);
         match datum.ty.sty {
             ty::ty_bare_fn(..) => {
                 let llval = datum.to_llscalarish(bcx);
index a8363699db8e3b071ac5931aeca59b94d1cfcc1c..6f2def16e7674f867c14e673cc2cb0fdc40269cf 100644 (file)
@@ -19,7 +19,7 @@
 use trans::build::*;
 use trans::cleanup::{CleanupMethods, ScopeId};
 use trans::common::*;
-use trans::datum::{Datum, DatumBlock, Expr, Lvalue, rvalue_scratch_datum};
+use trans::datum::{Datum, Lvalue, rvalue_scratch_datum};
 use trans::datum::{Rvalue, ByValue};
 use trans::debuginfo;
 use trans::expr;
 use middle::ty::{self, Ty, UnboxedClosureTyper};
 use middle::subst::{Substs};
 use session::config::FullDebugInfo;
-use util::ppaux::Repr;
 use util::ppaux::ty_to_string;
 
-use arena::TypedArena;
 use syntax::ast;
 use syntax::ast_util;
 
@@ -581,97 +579,3 @@ pub fn trans_unboxed_closure<'blk, 'tcx>(
 
     bcx
 }
-
-pub fn get_wrapper_for_bare_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
-                                         closure_ty: Ty<'tcx>,
-                                         def_id: ast::DefId,
-                                         fn_ptr: ValueRef,
-                                         is_local: bool) -> ValueRef {
-
-    match ccx.closure_bare_wrapper_cache().borrow().get(&fn_ptr) {
-        Some(&llval) => return llval,
-        None => {}
-    }
-
-    let tcx = ccx.tcx();
-
-    debug!("get_wrapper_for_bare_fn(closure_ty={})", closure_ty.repr(tcx));
-
-    let f = match closure_ty.sty {
-        _ => {
-            ccx.sess().bug(format!("get_wrapper_for_bare_fn: \
-                                    expected a closure ty, got {}",
-                                    closure_ty.repr(tcx))[]);
-        }
-    };
-
-    let name = ty::with_path(tcx, def_id, |path| {
-        mangle_internal_name_by_path_and_seq(path, "as_closure")
-    });
-    let llfn = if is_local {
-        decl_internal_rust_fn(ccx, closure_ty, name[])
-    } else {
-        decl_rust_fn(ccx, closure_ty, name[])
-    };
-
-    ccx.closure_bare_wrapper_cache().borrow_mut().insert(fn_ptr, llfn);
-
-    // This is only used by statics inlined from a different crate.
-    if !is_local {
-        // Don't regenerate the wrapper, just reuse the original one.
-        return llfn;
-    }
-
-    let _icx = push_ctxt("closure::get_wrapper_for_bare_fn");
-
-    let arena = TypedArena::new();
-    let empty_param_substs = Substs::trans_empty();
-    let fcx = new_fn_ctxt(ccx, llfn, ast::DUMMY_NODE_ID, true, f.sig.0.output,
-                          &empty_param_substs, None, &arena);
-    let bcx = init_function(&fcx, true, f.sig.0.output);
-
-    let args = create_datums_for_fn_args(&fcx,
-                                         ty::ty_fn_args(closure_ty)
-                                            []);
-    let mut llargs = Vec::new();
-    match fcx.llretslotptr.get() {
-        Some(llretptr) => {
-            assert!(!fcx.needs_ret_allocas);
-            llargs.push(llretptr);
-        }
-        None => {}
-    }
-    llargs.extend(args.iter().map(|arg| arg.val));
-
-    let retval = Call(bcx, fn_ptr, llargs.as_slice(), None);
-    match f.sig.0.output {
-        ty::FnConverging(output_type) => {
-            if return_type_is_void(ccx, output_type) || fcx.llretslotptr.get().is_some() {
-                RetVoid(bcx);
-            } else {
-                Ret(bcx, retval);
-            }
-        }
-        ty::FnDiverging => {
-            RetVoid(bcx);
-        }
-    }
-
-    // HACK(eddyb) finish_fn cannot be used here, we returned directly.
-    debuginfo::clear_source_location(&fcx);
-    fcx.cleanup();
-
-    llfn
-}
-
-pub fn make_closure_from_bare_fn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
-                                             closure_ty: Ty<'tcx>,
-                                             def_id: ast::DefId,
-                                             fn_ptr: ValueRef)
-                                             -> DatumBlock<'blk, 'tcx, Expr>  {
-    let scratch = rvalue_scratch_datum(bcx, closure_ty, "__adjust");
-    let wrapper = get_wrapper_for_bare_fn(bcx.ccx(), closure_ty, def_id, fn_ptr, true);
-    fill_fn_pair(bcx, scratch.val, wrapper, C_null(Type::i8p(bcx.ccx())));
-
-    DatumBlock::new(bcx, scratch.to_expr_datum())
-}
index 2738f1bca6e1e48e169a6e31cfc58765192b20fe..7e47c8f3b959a277c5ef21856a0f2a7cf429201c 100644 (file)
@@ -15,7 +15,7 @@
 use llvm::{IntEQ, IntNE, IntUGT, IntUGE, IntULT, IntULE, IntSGT, IntSGE, IntSLT, IntSLE,
            RealOEQ, RealOGT, RealOGE, RealOLT, RealOLE, RealONE};
 use middle::{const_eval, def};
-use trans::{adt, closure, consts, debuginfo, expr, inline, machine};
+use trans::{adt, consts, debuginfo, expr, inline, machine};
 use trans::base::{self, push_ctxt};
 use trans::common::*;
 use trans::type_::Type;
index 1bf96b7d180e23c734846f5ec37874cb0e993afc..9221ae09df98aa7ad3f5ec174cc86ae605911785 100644 (file)
@@ -473,22 +473,6 @@ fn unsize_unique_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
         DatumBlock::new(bcx, scratch.to_expr_datum())
     }
-
-    fn add_env<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
-                           def_id: ast::DefId,
-                           expr: &ast::Expr,
-                           datum: Datum<'tcx, Expr>)
-                           -> DatumBlock<'blk, 'tcx, Expr> {
-        // This is not the most efficient thing possible; since closures
-        // are two words it'd be better if this were compiled in
-        // 'dest' mode, but I can't find a nice way to structure the
-        // code and keep it DRY that accommodates that use case at the
-        // moment.
-
-        let closure_ty = expr_ty_adjusted(bcx, expr);
-        let fn_ptr = datum.to_llscalarish(bcx);
-        closure::make_closure_from_bare_fn(bcx, closure_ty, def_id, fn_ptr)
-    }
 }
 
 /// Translates an expression in "lvalue" mode -- meaning that it returns a reference to the memory