Skip to content

Commit fb0e88b

Browse files
committed
---
yaml --- r: 11868 b: refs/heads/master c: 47f35c9 h: refs/heads/master v: v3
1 parent 1a6a93c commit fb0e88b

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: fe90c189f488d336fc34979d6b928555d984a4d7
2+
refs/heads/master: 47f35c9d34b55d143e5368bd917c013afabeb5a8
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/rustc/middle/trans/base.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2145,12 +2145,11 @@ fn lval_static_fn(bcx: block, fn_id: ast::def_id, id: ast::node_id,
21452145
// The awkwardness below mostly stems from the fact that we're mixing
21462146
// monomorphized and non-monomorphized functions at the moment. If
21472147
// monomorphizing becomes the only approach, this'll be much simpler.
2148-
if (option::is_some(substs) || tys.len() > 0u) &&
2149-
fn_id.crate == ast::local_crate {
2148+
if fn_id.crate == ast::local_crate {
21502149
let mono = alt substs {
21512150
some((stys, vtables)) {
2152-
if (stys.len() + tys.len()) > 0u {
2153-
monomorphic_fn(ccx, fn_id, stys + tys, some(vtables))
2151+
if stys.len() > 0u {
2152+
monomorphic_fn(ccx, fn_id, stys, some(vtables))
21542153
} else { none }
21552154
}
21562155
none {
@@ -2160,7 +2159,10 @@ fn lval_static_fn(bcx: block, fn_id: ast::def_id, id: ast::node_id,
21602159
bcx.fcx, vtables);
21612160
monomorphic_fn(ccx, fn_id, tys, some(rvtables))
21622161
}
2163-
none { monomorphic_fn(ccx, fn_id, tys, none) }
2162+
none {
2163+
if tys.len() == 0u { none }
2164+
else { monomorphic_fn(ccx, fn_id, tys, none) }
2165+
}
21642166
}
21652167
}
21662168
};

trunk/src/rustc/middle/trans/impl.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,31 @@ fn method_with_name(ccx: @crate_ctxt, impl_id: ast::def_id,
106106
}
107107
}
108108

109+
fn method_ty_param_count(ccx: crate_ctxt, m_id: ast::def_id) -> uint {
110+
if m_id.crate == ast::local_crate {
111+
alt check ccx.tcx.items.get(m_id.node) {
112+
ast_map::node_method(m, _, _) { vec::len(m.tps) }
113+
}
114+
} else {
115+
csearch::get_type_param_count(ccx.sess.cstore, m_id)
116+
}
117+
}
118+
109119
fn trans_monomorphized_callee(bcx: block, callee_id: ast::node_id,
110120
base: @ast::expr, iface_id: ast::def_id,
111121
n_method: uint, n_param: uint, n_bound: uint,
112122
substs: param_substs) -> lval_maybe_callee {
113123
alt find_vtable_in_fn_ctxt(substs, n_param, n_bound) {
114-
typeck::vtable_static(impl_did, tys, sub_origins) {
115-
let tcx = bcx.tcx();
116-
let mname = ty::iface_methods(tcx, iface_id)[n_method].ident;
124+
typeck::vtable_static(impl_did, impl_substs, sub_origins) {
125+
let ccx = bcx.ccx();
126+
let mname = ty::iface_methods(ccx.tcx, iface_id)[n_method].ident;
117127
let mth_id = method_with_name(bcx.ccx(), impl_did, mname);
128+
let n_m_tps = method_ty_param_count(ccx, mth_id);
129+
let node_substs = node_id_type_params(bcx, callee_id);
130+
let ty_substs = impl_substs +
131+
vec::tail_n(node_substs, node_substs.len() - n_m_tps);
118132
ret trans_static_callee(bcx, callee_id, base, mth_id,
119-
some((tys, sub_origins)));
133+
some((ty_substs, sub_origins)));
120134
}
121135
typeck::vtable_iface(iid, tps) {
122136
ret trans_iface_callee(bcx, base, callee_id, n_method);
@@ -155,11 +169,11 @@ fn find_vtable_in_fn_ctxt(ps: param_substs, n_param: uint, n_bound: uint)
155169
// Vtables are stored in a flat array, finding the right one is
156170
// somewhat awkward
157171
for bounds in *ps.bounds {
158-
i += 1u;
159172
if i >= n_param { break; }
160173
for bound in *bounds {
161174
alt bound { ty::bound_iface(_) { vtable_off += 1u; } _ {} }
162175
}
176+
i += 1u;
163177
}
164178
option::get(ps.vtables)[vtable_off]
165179
}

0 commit comments

Comments
 (0)