Skip to content

Commit dfdca5d

Browse files
committed
Fix broken determination of external method type param count
Closes #2185
1 parent 5129275 commit dfdca5d

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

src/rustc/middle/trans/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2341,7 +2341,7 @@ fn trans_callee(bcx: block, e: @ast::expr) -> lval_maybe_callee {
23412341
let _icx = bcx.insn_ctxt("trans_callee");
23422342
alt e.node {
23432343
ast::expr_path(path) { ret trans_path(bcx, e.id); }
2344-
ast::expr_field(base, ident, _) {
2344+
ast::expr_field(base, _, _) {
23452345
// Lval means this is a record field, so not a method
23462346
if !expr_is_lval(bcx, e) {
23472347
alt bcx.ccx().maps.method_map.find(e.id) {

src/rustc/middle/trans/impl.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,15 @@ fn method_with_name(ccx: @crate_ctxt, impl_id: ast::def_id,
9595
}
9696
}
9797

98-
fn method_ty_param_count(ccx: @crate_ctxt, m_id: ast::def_id) -> uint {
98+
fn method_ty_param_count(ccx: @crate_ctxt, m_id: ast::def_id,
99+
i_id: ast::def_id) -> uint {
99100
if m_id.crate == ast::local_crate {
100101
alt check ccx.tcx.items.get(m_id.node) {
101102
ast_map::node_method(m, _, _) { vec::len(m.tps) }
102103
}
103104
} else {
104-
csearch::get_type_param_count(ccx.sess.cstore, m_id)
105+
csearch::get_type_param_count(ccx.sess.cstore, m_id) -
106+
csearch::get_type_param_count(ccx.sess.cstore, i_id)
105107
}
106108
}
107109

@@ -115,7 +117,7 @@ fn trans_monomorphized_callee(bcx: block, callee_id: ast::node_id,
115117
let ccx = bcx.ccx();
116118
let mname = ty::iface_methods(ccx.tcx, iface_id)[n_method].ident;
117119
let mth_id = method_with_name(bcx.ccx(), impl_did, mname);
118-
let n_m_tps = method_ty_param_count(ccx, mth_id);
120+
let n_m_tps = method_ty_param_count(ccx, mth_id, impl_did);
119121
let node_substs = node_id_type_params(bcx, callee_id);
120122
let ty_substs = impl_substs +
121123
vec::tailn(node_substs, node_substs.len() - n_m_tps);

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import iter::*;
2+
3+
fn main() {
4+
let range = bind uint::range(0u, 1000u, _);
5+
let filt = bind iter::filter(range, {|&&n: uint| n % 3u != 0u && n % 5u != 0u }, _);
6+
let sum = iter::foldl(filt, 0u) {|accum, &&n: uint| accum + n };
7+
8+
io::println(#fmt("%u", sum));
9+
}

0 commit comments

Comments
 (0)