Skip to content

Commit

Permalink
Stop duplicating non-generic resource destructors
Browse files Browse the repository at this point in the history
  • Loading branch information
marijnh committed Apr 18, 2012
1 parent a0fa099 commit 054a312
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/rustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,9 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
encode_type(ecx, ebml_w, ty::ty_fn_ret(fn_ty));
encode_name(ebml_w, item.ident);
astencode::encode_inlined_item(ecx, ebml_w, path, ii_item(item));
if (tps.len() == 0u) {
encode_symbol(ecx, ebml_w, item.id);
}
encode_path(ebml_w, path, ast_map::path_name(item.ident));
ebml_w.end_tag();

Expand Down
23 changes: 17 additions & 6 deletions src/rustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,11 +706,23 @@ fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) {
fn get_res_dtor(ccx: @crate_ctxt, did: ast::def_id, substs: [ty::t])
-> ValueRef {
let _icx = ccx.insn_ctxt("trans_res_dtor");
let did = if did.crate != ast::local_crate {
maybe_instantiate_inline(ccx, did)
} else { did };
assert did.crate == ast::local_crate;
monomorphic_fn(ccx, did, substs, none, none).val
if (substs.len() > 0u) {
let did = if did.crate != ast::local_crate {
maybe_instantiate_inline(ccx, did)
} else { did };
assert did.crate == ast::local_crate;
monomorphic_fn(ccx, did, substs, none, none).val
} else if did.crate == ast::local_crate {
get_item_val(ccx, did.node)
} else {
let fty = ty::mk_fn(ccx.tcx, {proto: ast::proto_bare,
inputs: [{mode: ast::expl(ast::by_ref),
ty: ty::mk_nil_ptr(ccx.tcx)}],
output: ty::mk_nil(ccx.tcx),
ret_style: ast::return_val,
constraints: []});
trans_external_path(ccx, did, fty)
}
}

fn trans_res_drop(bcx: block, rs: ValueRef, did: ast::def_id,
Expand Down Expand Up @@ -1946,7 +1958,6 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, real_substs: [ty::t],
let s = mangle_exported_name(ccx, pt, mono_ty);
let lldecl = decl_internal_cdecl_fn(ccx.llmod, s, llfty);
ccx.monomorphized.insert(hash_id, lldecl);
ccx.item_symbols.insert(fn_id.node, s);

let psubsts = some({tys: substs, vtables: vtables, bounds: tpt.bounds});
alt check map_node {
Expand Down

0 comments on commit 054a312

Please sign in to comment.