Skip to content

Commit 3ec3b02

Browse files
committed
rustc: Strip cnames before generating glue to avoid duplicates
1 parent 142ff3b commit 3ec3b02

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/comp/middle/trans.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,9 +1370,11 @@ fn get_derived_tydesc(&@block_ctxt cx, &ty::t t, bool escapes,
13701370
ret rslt(cx, v);
13711371
}
13721372

1373-
fn get_tydesc(&@block_ctxt cx, &ty::t t, bool escapes,
1373+
fn get_tydesc(&@block_ctxt cx, &ty::t orig_t, bool escapes,
13741374
&mutable option::t[@tydesc_info] static_ti) -> result {
13751375

1376+
auto t = ty::strip_cname(cx.fcx.lcx.ccx.tcx, orig_t);
1377+
13761378
// Is the supplied type a type param? If so, return the passed-in tydesc.
13771379
alt (ty::type_param(cx.fcx.lcx.ccx.tcx, t)) {
13781380
case (some(?id)) { ret rslt(cx, cx.fcx.lltydescs.(id)); }
@@ -1390,8 +1392,10 @@ fn get_tydesc(&@block_ctxt cx, &ty::t t, bool escapes,
13901392
ret rslt(cx, info.tydesc);
13911393
}
13921394

1393-
fn get_static_tydesc(&@block_ctxt cx, &ty::t t, &uint[] ty_params)
1395+
fn get_static_tydesc(&@block_ctxt cx, &ty::t orig_t, &uint[] ty_params)
13941396
-> @tydesc_info {
1397+
auto t = ty::strip_cname(cx.fcx.lcx.ccx.tcx, orig_t);
1398+
13951399
alt (cx.fcx.lcx.ccx.tydescs.find(t)) {
13961400
case (some(?info)) { ret info; }
13971401
case (none) {

src/comp/middle/ty.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ export sequence_is_interior;
108108
export struct;
109109
export sort_methods;
110110
export stmt_node_id;
111+
export strip_cname;
111112
export sty;
112113
export substitute_type_params;
113114
export t;
@@ -855,10 +856,14 @@ fn fold_ty(&ctxt cx, fold_mode fld, t ty_0) -> t {
855856

856857

857858
// Type utilities
859+
858860
fn rename(&ctxt cx, t typ, str new_cname) -> t {
859861
ret gen_ty_full(cx, struct(cx, typ), some[str](new_cname));
860862
}
861863

864+
fn strip_cname(&ctxt cx, t typ) -> t {
865+
ret gen_ty_full(cx, struct(cx, typ), none);
866+
}
862867

863868
// Returns a type with the structural part taken from `struct_ty` and the
864869
// canonical name from `cname_ty`.

0 commit comments

Comments
 (0)