Skip to content

Commit 478decf

Browse files
committed
librustc: Resolve nested vtable parameters in overloaded calls.
Closes #16508.
1 parent 43f040d commit 478decf

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

src/librustc/middle/trans/common.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ impl param_substs {
201201
}
202202

203203
fn param_substs_to_string(this: &param_substs, tcx: &ty::ctxt) -> String {
204-
format!("param_substs({})", this.substs.repr(tcx))
204+
format!("param_substs(substs={},vtables={})",
205+
this.substs.repr(tcx),
206+
this.vtables.repr(tcx))
205207
}
206208

207209
impl Repr for param_substs {
@@ -859,8 +861,7 @@ pub fn find_vtable(tcx: &ty::ctxt,
859861
debug!("find_vtable(n_param={:?}, n_bound={}, ps={})",
860862
n_param, n_bound, ps.repr(tcx));
861863

862-
let param_bounds = ps.vtables.get(n_param.space,
863-
n_param.index);
864+
let param_bounds = ps.vtables.get(n_param.space, n_param.index);
864865
param_bounds.get(n_bound).clone()
865866
}
866867

src/librustc/middle/typeck/check/vtable.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,8 @@ pub fn early_resolve_expr(ex: &ast::Expr, fcx: &FnCtxt, is_early: bool) {
769769
ast::ExprAssignOp(_, _, _) |
770770
ast::ExprIndex(_, _) |
771771
ast::ExprMethodCall(_, _, _) |
772-
ast::ExprForLoop(..) => {
772+
ast::ExprForLoop(..) |
773+
ast::ExprCall(..) => {
773774
match fcx.inh.method_map.borrow().find(&MethodCall::expr(ex.id)) {
774775
Some(method) => {
775776
debug!("vtable resolution on parameter bounds for method call {}",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Tests that nested vtables work with overloaded calls.
12+
13+
#![feature(overloaded_calls)]
14+
15+
use std::ops::Fn;
16+
17+
struct G;
18+
19+
impl<'a, A: Add<int, int>> Fn<(A,), int> for G {
20+
extern "rust-call" fn call(&self, (arg,): (A,)) -> int {
21+
arg.add(&1)
22+
}
23+
}
24+
25+
fn main() {
26+
// ICE trigger
27+
G(1i);
28+
}
29+

0 commit comments

Comments
 (0)