diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2012-04-23 09:25:14 +0200 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2012-04-23 09:25:14 +0200 |
| commit | dfdca5d538d9cb89f50f0d9bdd8f9ba649c1c788 (patch) | |
| tree | f382fca0a0cf0211278614b63da72b53c977df6d | |
| parent | 512927573e08aba67832146a6097c8f6142f4fd4 (diff) | |
| download | rust-dfdca5d538d9cb89f50f0d9bdd8f9ba649c1c788.tar.gz rust-dfdca5d538d9cb89f50f0d9bdd8f9ba649c1c788.zip | |
Fix broken determination of external method type param count
Closes #2185
| -rw-r--r-- | src/rustc/middle/trans/base.rs | 2 | ||||
| -rw-r--r-- | src/rustc/middle/trans/impl.rs | 8 | ||||
| -rw-r--r-- | src/test/run-pass/issue-2185.rs | 9 |
3 files changed, 15 insertions, 4 deletions
diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index 42f2ddd5dda..0e8fee77190 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -2341,7 +2341,7 @@ fn trans_callee(bcx: block, e: @ast::expr) -> lval_maybe_callee { let _icx = bcx.insn_ctxt("trans_callee"); alt e.node { ast::expr_path(path) { ret trans_path(bcx, e.id); } - ast::expr_field(base, ident, _) { + ast::expr_field(base, _, _) { // Lval means this is a record field, so not a method if !expr_is_lval(bcx, e) { alt bcx.ccx().maps.method_map.find(e.id) { diff --git a/src/rustc/middle/trans/impl.rs b/src/rustc/middle/trans/impl.rs index fe545a9a4fd..cb87000c7c6 100644 --- a/src/rustc/middle/trans/impl.rs +++ b/src/rustc/middle/trans/impl.rs @@ -95,13 +95,15 @@ fn method_with_name(ccx: @crate_ctxt, impl_id: ast::def_id, } } -fn method_ty_param_count(ccx: @crate_ctxt, m_id: ast::def_id) -> uint { +fn method_ty_param_count(ccx: @crate_ctxt, m_id: ast::def_id, + i_id: ast::def_id) -> uint { if m_id.crate == ast::local_crate { alt check ccx.tcx.items.get(m_id.node) { ast_map::node_method(m, _, _) { vec::len(m.tps) } } } else { - csearch::get_type_param_count(ccx.sess.cstore, m_id) + csearch::get_type_param_count(ccx.sess.cstore, m_id) - + csearch::get_type_param_count(ccx.sess.cstore, i_id) } } @@ -115,7 +117,7 @@ fn trans_monomorphized_callee(bcx: block, callee_id: ast::node_id, let ccx = bcx.ccx(); let mname = ty::iface_methods(ccx.tcx, iface_id)[n_method].ident; let mth_id = method_with_name(bcx.ccx(), impl_did, mname); - let n_m_tps = method_ty_param_count(ccx, mth_id); + let n_m_tps = method_ty_param_count(ccx, mth_id, impl_did); let node_substs = node_id_type_params(bcx, callee_id); let ty_substs = impl_substs + vec::tailn(node_substs, node_substs.len() - n_m_tps); diff --git a/src/test/run-pass/issue-2185.rs b/src/test/run-pass/issue-2185.rs new file mode 100644 index 00000000000..8abe0f51ca7 --- /dev/null +++ b/src/test/run-pass/issue-2185.rs @@ -0,0 +1,9 @@ +import iter::*; + +fn main() { + let range = bind uint::range(0u, 1000u, _); + let filt = bind iter::filter(range, {|&&n: uint| n % 3u != 0u && n % 5u != 0u }, _); + let sum = iter::foldl(filt, 0u) {|accum, &&n: uint| accum + n }; + + io::println(#fmt("%u", sum)); +} \ No newline at end of file |
