Skip to content

Commit 054a312

Browse files
committed
Stop duplicating non-generic resource destructors
Closes #2177
1 parent a0fa099 commit 054a312

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

src/rustc/metadata/encoder.rs

+3
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,9 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
616616
encode_type(ecx, ebml_w, ty::ty_fn_ret(fn_ty));
617617
encode_name(ebml_w, item.ident);
618618
astencode::encode_inlined_item(ecx, ebml_w, path, ii_item(item));
619+
if (tps.len() == 0u) {
620+
encode_symbol(ecx, ebml_w, item.id);
621+
}
619622
encode_path(ebml_w, path, ast_map::path_name(item.ident));
620623
ebml_w.end_tag();
621624

src/rustc/middle/trans/base.rs

+17-6
Original file line numberDiff line numberDiff line change
@@ -706,11 +706,23 @@ fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) {
706706
fn get_res_dtor(ccx: @crate_ctxt, did: ast::def_id, substs: [ty::t])
707707
-> ValueRef {
708708
let _icx = ccx.insn_ctxt("trans_res_dtor");
709-
let did = if did.crate != ast::local_crate {
710-
maybe_instantiate_inline(ccx, did)
711-
} else { did };
712-
assert did.crate == ast::local_crate;
713-
monomorphic_fn(ccx, did, substs, none, none).val
709+
if (substs.len() > 0u) {
710+
let did = if did.crate != ast::local_crate {
711+
maybe_instantiate_inline(ccx, did)
712+
} else { did };
713+
assert did.crate == ast::local_crate;
714+
monomorphic_fn(ccx, did, substs, none, none).val
715+
} else if did.crate == ast::local_crate {
716+
get_item_val(ccx, did.node)
717+
} else {
718+
let fty = ty::mk_fn(ccx.tcx, {proto: ast::proto_bare,
719+
inputs: [{mode: ast::expl(ast::by_ref),
720+
ty: ty::mk_nil_ptr(ccx.tcx)}],
721+
output: ty::mk_nil(ccx.tcx),
722+
ret_style: ast::return_val,
723+
constraints: []});
724+
trans_external_path(ccx, did, fty)
725+
}
714726
}
715727

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

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

0 commit comments

Comments
 (0)