Skip to content

Commit 19b7a7d

Browse files
committed
Revert "Mangle exported names using node IDs rather than types"
This reverts commit c83d61d.
1 parent 1e42c9a commit 19b7a7d

File tree

3 files changed

+10
-20
lines changed

3 files changed

+10
-20
lines changed

src/rustc/back/link.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -485,14 +485,15 @@ fn mangle(ss: path) -> str {
485485
n
486486
}
487487

488-
fn exported_name(path: path, id: ast::node_id, _vers: str) -> str {
488+
fn exported_name(path: path, hash: str, _vers: str) -> str {
489489
// FIXME: versioning isn't working yet
490-
ret mangle(path + [path_name(int::str(id))]); // + "@" + vers;
490+
ret mangle(path + [path_name(hash)]); // + "@" + vers;
491+
491492
}
492493

493-
fn mangle_exported_name(ccx: @crate_ctxt, path: path, id: ast::node_id)
494-
-> str {
495-
ret exported_name(path, id, ccx.link_meta.vers);
494+
fn mangle_exported_name(ccx: @crate_ctxt, path: path, t: ty::t) -> str {
495+
let hash = get_symbol_hash(ccx, t);
496+
ret exported_name(path, hash, ccx.link_meta.vers);
496497
}
497498

498499
fn mangle_internal_name_by_type_only(ccx: @crate_ctxt, t: ty::t, name: str) ->

src/rustc/middle/trans/base.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,7 +1911,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, real_substs: [ty::t],
19111911
let llfty = type_of_fn_from_ty(ccx, mono_ty);
19121912

19131913
let pt = *pt + [path_name(ccx.names(name))];
1914-
let s = mangle_exported_name(ccx, pt, fn_id.node);
1914+
let s = mangle_exported_name(ccx, pt, mono_ty);
19151915
let lldecl = decl_internal_cdecl_fn(ccx.llmod, s, llfty);
19161916
ccx.monomorphized.insert(hash_id, lldecl);
19171917
ccx.item_symbols.insert(fn_id.node, s);
@@ -4418,7 +4418,7 @@ fn register_fn_full(ccx: @crate_ctxt, sp: span, path: path,
44184418
fn register_fn_fuller(ccx: @crate_ctxt, sp: span, path: path,
44194419
node_id: ast::node_id, node_type: ty::t,
44204420
cc: lib::llvm::CallConv, llfty: TypeRef) -> ValueRef {
4421-
let ps: str = mangle_exported_name(ccx, path, node_id);
4421+
let ps: str = mangle_exported_name(ccx, path, node_type);
44224422
let llfn: ValueRef = decl_fn(ccx.llmod, ps, cc, llfty);
44234423
ccx.item_symbols.insert(node_id, ps);
44244424

@@ -4547,7 +4547,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
45474547
alt check i.node {
45484548
ast::item_const(_, _) {
45494549
let typ = ty::node_id_to_type(ccx.tcx, i.id);
4550-
let s = mangle_exported_name(ccx, my_path, i.id);
4550+
let s = mangle_exported_name(ccx, my_path, typ);
45514551
let g = str::as_c_str(s, {|buf|
45524552
llvm::LLVMAddGlobal(ccx.llmod, type_of(ccx, typ), buf)
45534553
});
@@ -4634,7 +4634,7 @@ fn trans_constant(ccx: @crate_ctxt, it: @ast::item) {
46344634
for vec::each(variants) {|variant|
46354635
let p = path + [path_name(variant.node.name),
46364636
path_name("discrim")];
4637-
let s = mangle_exported_name(ccx, p, it.id);
4637+
let s = mangle_exported_name(ccx, p, ty::mk_int(ccx.tcx));
46384638
let disr_val = vi[i].disr_val;
46394639
note_unique_llvm_symbol(ccx, s);
46404640
let discrim_gvar = str::as_c_str(s, {|buf|

src/test/run-pass/issue-2074.rs

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)