Skip to content

Commit 2e3f109

Browse files
committed
Fix bug in vtable builder
Closes #1947 , which I completely misdiagnosed.
1 parent 24ed441 commit 2e3f109

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/rustc/middle/trans/impl.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,21 @@ fn make_impl_vtable(ccx: @crate_ctxt, impl_id: ast::def_id, substs: [ty::t],
231231
vtables: typeck::vtable_res) -> ValueRef {
232232
let tcx = ccx.tcx;
233233
let ifce_id = ty::ty_to_def_id(option::get(ty::impl_iface(tcx, impl_id)));
234+
let has_tps = (*ty::lookup_item_type(ccx.tcx, impl_id).bounds).len() > 0u;
234235
make_vtable(ccx, vec::map(*ty::iface_methods(tcx, ifce_id), {|im|
235236
let fty = ty::substitute_type_params(tcx, substs,
236237
ty::mk_fn(tcx, im.fty));
237238
if (*im.tps).len() > 0u || ty::type_has_vars(fty) {
238239
C_null(type_of_fn_from_ty(ccx, fty))
239240
} else {
240241
let m_id = method_with_name(ccx, impl_id, im.ident);
241-
monomorphic_fn(ccx, m_id, substs, some(vtables)).val
242+
if has_tps {
243+
monomorphic_fn(ccx, m_id, substs, some(vtables)).val
244+
} else if m_id.crate == ast::local_crate {
245+
get_item_val(ccx, m_id.node)
246+
} else {
247+
trans_external_path(ccx, m_id, fty)
248+
}
242249
}
243250
}))
244251
}

0 commit comments

Comments
 (0)