Skip to content

Commit 82ebd2b

Browse files
committed
librustc_trans: Remove some dead code now that procs are gone.
1 parent 19f73b4 commit 82ebd2b

File tree

2 files changed

+7
-53
lines changed

2 files changed

+7
-53
lines changed

src/librustc_trans/trans/base.rs

+2-26
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ use trans::cleanup::CleanupMethods;
5555
use trans::cleanup;
5656
use trans::closure;
5757
use trans::common::{Block, C_bool, C_bytes_in_context, C_i32, C_integral};
58-
use trans::common::{C_null, C_struct_in_context, C_u64, C_u8, C_uint, C_undef};
58+
use trans::common::{C_null, C_struct_in_context, C_u64, C_u8, C_undef};
5959
use trans::common::{CrateContext, ExternMap, FunctionContext};
6060
use trans::common::{NodeInfo, Result};
6161
use trans::common::{node_id_type, return_type_is_void};
@@ -73,7 +73,7 @@ use trans::glue;
7373
use trans::inline;
7474
use trans::intrinsic;
7575
use trans::machine;
76-
use trans::machine::{llsize_of, llsize_of_real, llalign_of_min};
76+
use trans::machine::{llsize_of, llsize_of_real};
7777
use trans::meth;
7878
use trans::monomorphize;
7979
use trans::tvec;
@@ -394,30 +394,6 @@ pub fn malloc_raw_dyn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
394394
Result::new(r.bcx, PointerCast(r.bcx, r.val, llty_ptr))
395395
}
396396

397-
pub fn malloc_raw_dyn_proc<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty<'tcx>)
398-
-> Result<'blk, 'tcx> {
399-
let _icx = push_ctxt("malloc_raw_dyn_proc");
400-
let ccx = bcx.ccx();
401-
402-
// Grab the TypeRef type of ptr_ty.
403-
let ptr_ty = ty::mk_uniq(bcx.tcx(), t);
404-
let ptr_llty = type_of(ccx, ptr_ty);
405-
406-
let llty = type_of(bcx.ccx(), t);
407-
let size = llsize_of(bcx.ccx(), llty);
408-
let llalign = C_uint(ccx, llalign_of_min(bcx.ccx(), llty));
409-
410-
// Allocate space and store the destructor pointer:
411-
let Result {bcx, val: llbox} = malloc_raw_dyn(bcx, ptr_llty, t, size, llalign);
412-
let dtor_ptr = GEPi(bcx, llbox, &[0u, abi::BOX_FIELD_DROP_GLUE]);
413-
let drop_glue_field_ty = type_of(ccx, ty::mk_nil_ptr(bcx.tcx()));
414-
let drop_glue = PointerCast(bcx, glue::get_drop_glue(ccx, ty::mk_uniq(bcx.tcx(), t)),
415-
drop_glue_field_ty);
416-
Store(bcx, drop_glue, dtor_ptr);
417-
418-
Result::new(bcx, llbox)
419-
}
420-
421397
// Type descriptor and type glue stuff
422398

423399
pub fn get_tydesc<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,

src/librustc_trans/trans/closure.rs

+5-27
Original file line numberDiff line numberDiff line change
@@ -137,26 +137,6 @@ fn tuplify_box_ty<'tcx>(tcx: &ty::ctxt<'tcx>, t: Ty<'tcx>) -> Ty<'tcx> {
137137
ty::mk_tup(tcx, vec!(ty::mk_uint(), ty::mk_nil_ptr(tcx), ptr, ptr, t))
138138
}
139139

140-
fn allocate_cbox<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
141-
store: ty::TraitStore,
142-
cdata_ty: Ty<'tcx>)
143-
-> Result<'blk, 'tcx> {
144-
let _icx = push_ctxt("closure::allocate_cbox");
145-
let tcx = bcx.tcx();
146-
147-
// Allocate and initialize the box:
148-
let cbox_ty = tuplify_box_ty(tcx, cdata_ty);
149-
match store {
150-
ty::UniqTraitStore => {
151-
malloc_raw_dyn_proc(bcx, cbox_ty)
152-
}
153-
ty::RegionTraitStore(..) => {
154-
let llbox = alloc_ty(bcx, cbox_ty, "__closure");
155-
Result::new(bcx, llbox)
156-
}
157-
}
158-
}
159-
160140
pub struct ClosureResult<'blk, 'tcx: 'blk> {
161141
llbox: ValueRef, // llvalue of ptr to closure
162142
cdata_ty: Ty<'tcx>, // type of the closure data
@@ -168,8 +148,7 @@ pub struct ClosureResult<'blk, 'tcx: 'blk> {
168148
// heap allocated closure that copies the upvars into environment.
169149
// Otherwise, it is stack allocated and copies pointers to the upvars.
170150
pub fn store_environment<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
171-
bound_values: Vec<EnvValue<'tcx>> ,
172-
store: ty::TraitStore)
151+
bound_values: Vec<EnvValue<'tcx>>)
173152
-> ClosureResult<'blk, 'tcx> {
174153
let _icx = push_ctxt("closure::store_environment");
175154
let ccx = bcx.ccx();
@@ -193,7 +172,7 @@ pub fn store_environment<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
193172
}
194173

195174
// allocate closure in the heap
196-
let Result {bcx, val: llbox} = allocate_cbox(bcx, store, cdata_ty);
175+
let llbox = alloc_ty(bcx, cbox_ty, "__closure");
197176

198177
let llbox = PointerCast(bcx, llbox, llboxptr_ty);
199178
debug!("tuplify_box_ty = {}", ty_to_string(tcx, cbox_ty));
@@ -227,8 +206,7 @@ pub fn store_environment<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
227206
// collects the upvars and packages them up for store_environment.
228207
fn build_closure<'blk, 'tcx>(bcx0: Block<'blk, 'tcx>,
229208
freevar_mode: ast::CaptureClause,
230-
freevars: &Vec<ty::Freevar>,
231-
store: ty::TraitStore)
209+
freevars: &Vec<ty::Freevar>)
232210
-> ClosureResult<'blk, 'tcx> {
233211
let _icx = push_ctxt("closure::build_closure");
234212

@@ -242,7 +220,7 @@ fn build_closure<'blk, 'tcx>(bcx0: Block<'blk, 'tcx>,
242220
env_vals.push(EnvValue {action: freevar_mode, datum: datum});
243221
}
244222

245-
store_environment(bcx, env_vals, store)
223+
store_environment(bcx, env_vals)
246224
}
247225

248226
// Given an enclosing block context, a new function context, a closure type,
@@ -456,7 +434,7 @@ pub fn trans_expr_fn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
456434
llbox,
457435
cdata_ty,
458436
bcx
459-
} = build_closure(bcx, freevar_mode, &freevars, store);
437+
} = build_closure(bcx, freevar_mode, &freevars);
460438

461439
trans_closure(ccx,
462440
decl,

0 commit comments

Comments
 (0)